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

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 (334) 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/summary-agent.d.ts +44 -0
  13. package/dist/env/agent/types.d.ts +503 -0
  14. package/dist/env/commands/commands-component.d.ts +97 -0
  15. package/dist/env/commands/commands-config-registration.d.ts +19 -0
  16. package/dist/env/commands/index.d.ts +7 -0
  17. package/dist/env/commands/parser.d.ts +18 -0
  18. package/dist/env/commands/types.d.ts +133 -0
  19. package/dist/env/component.d.ts +186 -0
  20. package/dist/env/constants.d.ts +112 -0
  21. package/dist/env/context/env-context.d.ts +420 -0
  22. package/dist/env/context/env-event.d.ts +144 -0
  23. package/dist/env/context/index.d.ts +13 -0
  24. package/dist/env/debug/debug-component.d.ts +160 -0
  25. package/dist/env/debug/formatters/index.d.ts +8 -0
  26. package/dist/env/debug/formatters/repl-formatter.d.ts +80 -0
  27. package/dist/env/debug/formatters/trace-formatter.d.ts +43 -0
  28. package/dist/env/debug/formatters/tree-formatter.d.ts +72 -0
  29. package/dist/env/debug/index.d.ts +15 -0
  30. package/dist/env/debug/index.js +1 -1
  31. package/dist/env/debug/parser/regex-parser.d.ts +49 -0
  32. package/dist/env/debug/parser/span-builder.d.ts +79 -0
  33. package/dist/env/debug/reader/log-reader.d.ts +55 -0
  34. package/dist/env/debug/reader/span-db-reader.d.ts +70 -0
  35. package/dist/env/debug/types.d.ts +145 -0
  36. package/dist/env/environment.d.ts +185 -0
  37. package/dist/env/errors.d.ts +120 -0
  38. package/dist/env/event-source/bounty-cli-handler.d.ts +42 -0
  39. package/dist/env/event-source/bounty-im-handler.d.ts +232 -0
  40. package/dist/env/event-source/event-source-component.d.ts +177 -0
  41. package/dist/env/event-source/event-source-config-registration.d.ts +18 -0
  42. package/dist/env/event-source/event-source-handlers.d.ts +486 -0
  43. package/dist/env/event-source/event-store.d.ts +110 -0
  44. package/dist/env/event-source/idempotency-key.d.ts +19 -0
  45. package/dist/env/event-source/index.d.ts +15 -0
  46. package/dist/env/event-source/index.js +2 -2
  47. package/dist/env/event-source/timer-handler.d.ts +74 -0
  48. package/dist/env/event-source/types.d.ts +803 -0
  49. package/dist/env/hook/global-hook-manager.d.ts +73 -0
  50. package/dist/env/hook/hook-manager.d.ts +139 -0
  51. package/dist/env/hook/index.d.ts +9 -0
  52. package/dist/env/hook/types.d.ts +107 -0
  53. package/dist/env/index.d.ts +24 -0
  54. package/dist/env/index.js +4 -4
  55. package/dist/env/interface.d.ts +156 -0
  56. package/dist/env/lark-mention-utils.d.ts +59 -0
  57. package/dist/env/llm/adapter-ai-sdk.d.ts +10 -0
  58. package/dist/env/llm/adapter-pi-ai.d.ts +39 -0
  59. package/dist/env/llm/adapter.d.ts +80 -0
  60. package/dist/env/llm/factory.d.ts +13 -0
  61. package/dist/env/llm/hooks.d.ts +150 -0
  62. package/dist/env/llm/index.d.ts +16 -0
  63. package/dist/env/llm/invoke.d.ts +264 -0
  64. package/dist/env/llm/llm-cache.d.ts +38 -0
  65. package/dist/env/llm/llm.d.ts +238 -0
  66. package/dist/env/llm/opencode-session.d.ts +79 -0
  67. package/dist/env/llm/provider.d.ts +40 -0
  68. package/dist/env/llm/tool-args-parser.d.ts +77 -0
  69. package/dist/env/llm/tool-schema.d.ts +54 -0
  70. package/dist/env/llm/transform.d.ts +57 -0
  71. package/dist/env/llm/types.d.ts +818 -0
  72. package/dist/env/log-trace/decorator.d.ts +88 -0
  73. package/dist/env/log-trace/index.d.ts +14 -0
  74. package/dist/env/log-trace/log-trace-component.d.ts +268 -0
  75. package/dist/env/log-trace/log-trace-config-registration.d.ts +25 -0
  76. package/dist/env/log-trace/logger.d.ts +83 -0
  77. package/dist/env/log-trace/opentelemetry/cli-propagation.d.ts +105 -0
  78. package/dist/env/log-trace/opentelemetry/mod.d.ts +24 -0
  79. package/dist/env/log-trace/opentelemetry/propagation-env.d.ts +81 -0
  80. package/dist/env/log-trace/opentelemetry/propagation.d.ts +79 -0
  81. package/dist/env/log-trace/opentelemetry/tracer-provider.d.ts +157 -0
  82. package/dist/env/log-trace/span-storage.d.ts +37 -0
  83. package/dist/env/log-trace/trace-context.d.ts +28 -0
  84. package/dist/env/log-trace/types.d.ts +127 -0
  85. package/dist/env/mcp/command-resolver.d.ts +12 -0
  86. package/dist/env/mcp/config.d.ts +103 -0
  87. package/dist/env/mcp/index.d.ts +13 -0
  88. package/dist/env/mcp/loader.d.ts +78 -0
  89. package/dist/env/mcp/mcp-component.d.ts +54 -0
  90. package/dist/env/mcp/mcp-config-registration.d.ts +19 -0
  91. package/dist/env/mcp/npm-prefix/index.d.ts +17 -0
  92. package/dist/env/mcp/scanner.d.ts +38 -0
  93. package/dist/env/mcp/tool/adapter.d.ts +32 -0
  94. package/dist/env/mcp/tool/index.d.ts +4 -0
  95. package/dist/env/mcp/types.d.ts +131 -0
  96. package/dist/env/memory/built-in/index.d.ts +41 -0
  97. package/dist/env/memory/built-in/recall-memory.d.ts +29 -0
  98. package/dist/env/memory/built-in/record-memory.d.ts +44 -0
  99. package/dist/env/memory/index.d.ts +10 -0
  100. package/dist/env/memory/memory-component.d.ts +114 -0
  101. package/dist/env/memory/memory-config-registration.d.ts +18 -0
  102. package/dist/env/memory/memory-config.d.ts +18 -0
  103. package/dist/env/memory/plugin/index.d.ts +16 -0
  104. package/dist/env/memory/plugin/memory-agent.d.ts +126 -0
  105. package/dist/env/memory/plugin/memory-manager.d.ts +71 -0
  106. package/dist/env/memory/plugin/memory-plugin.d.ts +103 -0
  107. package/dist/env/memory/plugin/recall-memory.d.ts +16 -0
  108. package/dist/env/memory/plugin/types.d.ts +75 -0
  109. package/dist/env/memory/tools/memory-agent-tools.d.ts +109 -0
  110. package/dist/env/memory/types.d.ts +80 -0
  111. package/dist/env/paths.d.ts +46 -0
  112. package/dist/env/plugin/bounty-cli-notification-channel.d.ts +60 -0
  113. package/dist/env/plugin/event-bus-notification-channel.d.ts +50 -0
  114. package/dist/env/plugin/index.d.ts +13 -0
  115. package/dist/env/plugin/lark-cli-notification-channel.d.ts +61 -0
  116. package/dist/env/plugin/notification-channel.d.ts +143 -0
  117. package/dist/env/plugin/plugin-component.d.ts +232 -0
  118. package/dist/env/plugin/types.d.ts +146 -0
  119. package/dist/env/prompt/index.d.ts +7 -0
  120. package/dist/env/prompt/prompt-component.d.ts +194 -0
  121. package/dist/env/prompt/prompt-config-registration.d.ts +18 -0
  122. package/dist/env/prompt/prompt-store.d.ts +26 -0
  123. package/dist/env/prompt/prompts-index.d.ts +146 -0
  124. package/dist/env/prompt/renderer.d.ts +21 -0
  125. package/dist/env/prompt/types.d.ts +176 -0
  126. package/dist/env/session/hooks.d.ts +14 -0
  127. package/dist/env/session/index.d.ts +19 -0
  128. package/dist/env/session/search-query-parser.d.ts +41 -0
  129. package/dist/env/session/session-component.d.ts +464 -0
  130. package/dist/env/session/session-config-registration.d.ts +18 -0
  131. package/dist/env/session/session-id.d.ts +26 -0
  132. package/dist/env/session/session-message-converter.d.ts +142 -0
  133. package/dist/env/session/session-store.d.ts +188 -0
  134. package/dist/env/session/storage/index.d.ts +5 -0
  135. package/dist/env/session/storage/memory.d.ts +119 -0
  136. package/dist/env/session/storage/sqlite.d.ts +108 -0
  137. package/dist/env/session/types.d.ts +705 -0
  138. package/dist/env/session-tree-stopper.d.ts +79 -0
  139. package/dist/env/skill/config.d.ts +13 -0
  140. package/dist/env/skill/index.d.ts +6 -0
  141. package/dist/env/skill/parser.d.ts +9 -0
  142. package/dist/env/skill/scanner.d.ts +25 -0
  143. package/dist/env/skill/skill-component.d.ts +89 -0
  144. package/dist/env/skill/skill-config-registration.d.ts +18 -0
  145. package/dist/env/skill/tool/index.d.ts +1 -0
  146. package/dist/env/skill/tool/skill-tool.d.ts +15 -0
  147. package/dist/env/skill/types.d.ts +61 -0
  148. package/dist/env/task/backend/index.d.ts +24 -0
  149. package/dist/env/task/backend/index.js +704 -0
  150. package/dist/env/task/backend/roy-sidecar-task-port.d.ts +148 -0
  151. package/dist/env/task/backend/sqlite-task-port.d.ts +28 -0
  152. package/dist/env/task/backend/task-store-backend.d.ts +107 -0
  153. package/dist/env/task/backend/types.d.ts +293 -0
  154. package/dist/env/task/delegate/bg-task-id-storage.d.ts +9 -0
  155. package/dist/env/task/delegate/delegate-tool.d.ts +681 -0
  156. package/dist/env/task/delegate/index.d.ts +8 -0
  157. package/dist/env/task/delegate/process-registry.d.ts +58 -0
  158. package/dist/env/task/delegate/stop-tool.d.ts +12 -0
  159. package/dist/env/task/delegate/subagent-resolver.d.ts +25 -0
  160. package/dist/env/task/events/index.d.ts +7 -0
  161. package/dist/env/task/events/task-event-payloads.d.ts +101 -0
  162. package/dist/env/task/events/task-event-types.d.ts +23 -0
  163. package/dist/env/task/hooks/contexts.d.ts +191 -0
  164. package/dist/env/task/hooks/index.d.ts +7 -0
  165. package/dist/env/task/hooks/task-hook-points.d.ts +42 -0
  166. package/dist/env/task/index.d.ts +7 -0
  167. package/dist/env/task/plugins/auto-task-plugin.d.ts +38 -0
  168. package/dist/env/task/plugins/card-chat-routing.d.ts +135 -0
  169. package/dist/env/task/plugins/fake-user-message-helper.d.ts +90 -0
  170. package/dist/env/task/plugins/index.d.ts +8 -0
  171. package/dist/env/task/plugins/index.js +1 -1
  172. package/dist/env/task/plugins/lark-card-action-handler.d.ts +166 -0
  173. package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +651 -0
  174. package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +248 -0
  175. package/dist/env/task/plugins/max-iteration-reminder-plugin.d.ts +112 -0
  176. package/dist/env/task/plugins/per-task-group-chat-plugin.d.ts +561 -0
  177. package/dist/env/task/plugins/task-tag-plugin.d.ts +70 -0
  178. package/dist/env/task/plugins/workflow-extractor-agent.d.ts +43 -0
  179. package/dist/env/task/registry-hook-installer.d.ts +43 -0
  180. package/dist/env/task/storage/index.d.ts +5 -0
  181. package/dist/env/task/storage/migrations/001_add_project_path_context.d.ts +14 -0
  182. package/dist/env/task/storage/migrations/002_add_task_type.d.ts +14 -0
  183. package/dist/env/task/storage/migrations/003_add_process_description.d.ts +20 -0
  184. package/dist/env/task/storage/migrations/004_rename_action_to_milestone.d.ts +37 -0
  185. package/dist/env/task/storage/migrations/005_convert_blob_description_to_text.d.ts +51 -0
  186. package/dist/env/task/storage/sqlite-task-store.d.ts +241 -0
  187. package/dist/env/task/tag-service.d.ts +138 -0
  188. package/dist/env/task/task-child-context.d.ts +70 -0
  189. package/dist/env/task/task-component.d.ts +270 -0
  190. package/dist/env/task/task-config-registration.d.ts +19 -0
  191. package/dist/env/task/task-creation-registry.d.ts +181 -0
  192. package/dist/env/task/task-reuse-context.d.ts +52 -0
  193. package/dist/env/task/task-reuse-registry.d.ts +31 -0
  194. package/dist/env/task/tools/batch-archive-tool.d.ts +9 -0
  195. package/dist/env/task/tools/batch-delete-tool.d.ts +9 -0
  196. package/dist/env/task/tools/complete-tool.d.ts +12 -0
  197. package/dist/env/task/tools/create-tool.d.ts +6 -0
  198. package/dist/env/task/tools/delete-tool.d.ts +6 -0
  199. package/dist/env/task/tools/get-tool.d.ts +6 -0
  200. package/dist/env/task/tools/index.d.ts +13 -0
  201. package/dist/env/task/tools/list-tool.d.ts +6 -0
  202. package/dist/env/task/tools/operation/create-tool.d.ts +12 -0
  203. package/dist/env/task/tools/operation/delete-tool.d.ts +6 -0
  204. package/dist/env/task/tools/operation/get-tool.d.ts +6 -0
  205. package/dist/env/task/tools/operation/index.d.ts +8 -0
  206. package/dist/env/task/tools/operation/list-tool.d.ts +6 -0
  207. package/dist/env/task/tools/operation/operation-types.d.ts +225 -0
  208. package/dist/env/task/tools/operation/update-tool.d.ts +6 -0
  209. package/dist/env/task/tools/search-tool.d.ts +9 -0
  210. package/dist/env/task/tools/task-tree-tool.d.ts +65 -0
  211. package/dist/env/task/tools/task-types.d.ts +255 -0
  212. package/dist/env/task/tools/update-tool.d.ts +6 -0
  213. package/dist/env/task/types.d.ts +290 -0
  214. package/dist/env/tool/built-in/bash-effect.d.ts +36 -0
  215. package/dist/env/tool/built-in/bash.d.ts +16 -0
  216. package/dist/env/tool/built-in/echo.d.ts +7 -0
  217. package/dist/env/tool/built-in/edit-file.d.ts +6 -0
  218. package/dist/env/tool/built-in/glob.d.ts +6 -0
  219. package/dist/env/tool/built-in/grep.d.ts +6 -0
  220. package/dist/env/tool/built-in/index.d.ts +39 -0
  221. package/dist/env/tool/built-in/query-background-process-tool.d.ts +113 -0
  222. package/dist/env/tool/built-in/read-file.d.ts +5 -0
  223. package/dist/env/tool/built-in/understand-image.d.ts +59 -0
  224. package/dist/env/tool/built-in/write-file.d.ts +5 -0
  225. package/dist/env/tool/index.d.ts +16 -0
  226. package/dist/env/tool/registry.d.ts +61 -0
  227. package/dist/env/tool/tool-component.d.ts +242 -0
  228. package/dist/env/tool/tool-config-registration.d.ts +18 -0
  229. package/dist/env/tool/types.d.ts +274 -0
  230. package/dist/env/tool/validator.d.ts +14 -0
  231. package/dist/env/types.d.ts +184 -0
  232. package/dist/env/workflow/decorators/decorator-node.d.ts +76 -0
  233. package/dist/env/workflow/decorators/edge.d.ts +42 -0
  234. package/dist/env/workflow/decorators/index.d.ts +13 -0
  235. package/dist/env/workflow/decorators/node-as.d.ts +40 -0
  236. package/dist/env/workflow/decorators/workflow.d.ts +30 -0
  237. package/dist/env/workflow/engine/dag-manager.d.ts +176 -0
  238. package/dist/env/workflow/engine/engine.d.ts +375 -0
  239. package/dist/env/workflow/engine/event-bus.d.ts +54 -0
  240. package/dist/env/workflow/engine/executor.d.ts +122 -0
  241. package/dist/env/workflow/engine/index.d.ts +15 -0
  242. package/dist/env/workflow/engine/node-registry.d.ts +159 -0
  243. package/dist/env/workflow/engine/scheduler.d.ts +164 -0
  244. package/dist/env/workflow/extractor/workflow-converter.d.ts +55 -0
  245. package/dist/env/workflow/fixtures.d.ts +401 -0
  246. package/dist/env/workflow/hooks/index.d.ts +4 -0
  247. package/dist/env/workflow/hooks/workflow-hook-points.d.ts +161 -0
  248. package/dist/env/workflow/index.d.ts +30 -0
  249. package/dist/env/workflow/index.js +1 -1
  250. package/dist/env/workflow/metadata/keys.d.ts +6 -0
  251. package/dist/env/workflow/nodes/agent-component-adapter.d.ts +175 -0
  252. package/dist/env/workflow/nodes/agent-node.d.ts +206 -0
  253. package/dist/env/workflow/nodes/ask-user-node.d.ts +66 -0
  254. package/dist/env/workflow/nodes/condition-node.d.ts +39 -0
  255. package/dist/env/workflow/nodes/index.d.ts +8 -0
  256. package/dist/env/workflow/nodes/merge-node.d.ts +40 -0
  257. package/dist/env/workflow/nodes/python-call-node.d.ts +95 -0
  258. package/dist/env/workflow/nodes/skill-node.d.ts +29 -0
  259. package/dist/env/workflow/nodes/tool-node.d.ts +58 -0
  260. package/dist/env/workflow/nodes/workflow-node.d.ts +118 -0
  261. package/dist/env/workflow/plugins/index.d.ts +6 -0
  262. package/dist/env/workflow/plugins/lark-cli-workflow-notify-plugin.d.ts +107 -0
  263. package/dist/env/workflow/plugins/workflow-json-output-plugin.d.ts +166 -0
  264. package/dist/env/workflow/runtime/runtime-cancellation-scope.d.ts +121 -0
  265. package/dist/env/workflow/service/index.d.ts +9 -0
  266. package/dist/env/workflow/service/registry.d.ts +37 -0
  267. package/dist/env/workflow/service/workflow-service.d.ts +422 -0
  268. package/dist/env/workflow/storage/index.d.ts +11 -0
  269. package/dist/env/workflow/storage/mock-repositories.d.ts +106 -0
  270. package/dist/env/workflow/storage/safe-json.d.ts +62 -0
  271. package/dist/env/workflow/storage/sqlite.d.ts +57 -0
  272. package/dist/env/workflow/storage/tag-repo.d.ts +65 -0
  273. package/dist/env/workflow/storage/workflow-repo.d.ts +161 -0
  274. package/dist/env/workflow/tools/ask-user-tool.d.ts +35 -0
  275. package/dist/env/workflow/tools/index.d.ts +16 -0
  276. package/dist/env/workflow/tools/run-workflow.d.ts +130 -0
  277. package/dist/env/workflow/tools/submit-json-output-tool.d.ts +38 -0
  278. package/dist/env/workflow/tools/workflow-add-tool.d.ts +47 -0
  279. package/dist/env/workflow/tools/workflow-get-tool.d.ts +29 -0
  280. package/dist/env/workflow/tools/workflow-list-tool.d.ts +55 -0
  281. package/dist/env/workflow/tools/workflow-run-status-tool.d.ts +26 -0
  282. package/dist/env/workflow/tools/workflow-run-stop-tool.d.ts +29 -0
  283. package/dist/env/workflow/tools/workflow-search-tool.d.ts +33 -0
  284. package/dist/env/workflow/tools/workflow-tag-list-tool.d.ts +59 -0
  285. package/dist/env/workflow/tools/workflow-validate-tool.d.ts +60 -0
  286. package/dist/env/workflow/types/context.d.ts +17 -0
  287. package/dist/env/workflow/types/decorators-types.d.ts +182 -0
  288. package/dist/env/workflow/types/edge.d.ts +33 -0
  289. package/dist/env/workflow/types/event.d.ts +869 -0
  290. package/dist/env/workflow/types/index.d.ts +16 -0
  291. package/dist/env/workflow/types/run.d.ts +235 -0
  292. package/dist/env/workflow/types/workflow-error.d.ts +79 -0
  293. package/dist/env/workflow/types/workflow-hil.d.ts +57 -0
  294. package/dist/env/workflow/types/workflow-message.d.ts +193 -0
  295. package/dist/env/workflow/types/workflow-session.d.ts +17 -0
  296. package/dist/env/workflow/types/workflow.d.ts +654 -0
  297. package/dist/env/workflow/types_compat.d.ts +10 -0
  298. package/dist/env/workflow/utils/agent-session-metadata.d.ts +35 -0
  299. package/dist/env/workflow/utils/build-agent-node-output.d.ts +11 -0
  300. package/dist/env/workflow/utils/create-workflow.d.ts +35 -0
  301. package/dist/env/workflow/utils/dependency-prescan.d.ts +67 -0
  302. package/dist/env/workflow/utils/execution-state.d.ts +46 -0
  303. package/dist/env/workflow/utils/extract-agent-json-output.d.ts +6 -0
  304. package/dist/env/workflow/utils/index.d.ts +14 -0
  305. package/dist/env/workflow/utils/json-schema-to-zod.d.ts +23 -0
  306. package/dist/env/workflow/utils/node-id-utils.d.ts +20 -0
  307. package/dist/env/workflow/utils/node-output-contracts.d.ts +137 -0
  308. package/dist/env/workflow/utils/node-registry-helper.d.ts +36 -0
  309. package/dist/env/workflow/utils/output-schema-hint.d.ts +7 -0
  310. package/dist/env/workflow/utils/parse-agent-output-config.d.ts +9 -0
  311. package/dist/env/workflow/utils/recovery-validator.d.ts +30 -0
  312. package/dist/env/workflow/utils/sensitive-redact.d.ts +37 -0
  313. package/dist/env/workflow/utils/session-parser.d.ts +23 -0
  314. package/dist/env/workflow/utils/session-recovery.d.ts +122 -0
  315. package/dist/env/workflow/utils/template-contract-validator.d.ts +87 -0
  316. package/dist/env/workflow/utils/template-resolver.d.ts +285 -0
  317. package/dist/env/workflow/utils/validate-workflow-definition.d.ts +57 -0
  318. package/dist/env/workflow/utils/validation-rules.d.ts +103 -0
  319. package/dist/env/workflow/utils/workflow-message-metadata.d.ts +20 -0
  320. package/dist/env/workflow/utils/workflow-sanitize.d.ts +51 -0
  321. package/dist/env/workflow/workflow-component.d.ts +138 -0
  322. package/dist/index.d.ts +59 -0
  323. package/dist/index.js +5 -5
  324. package/dist/shared/@ai-setting/{roy-agent-core-rcfewbzr.js → roy-agent-core-4sx6sdb2.js} +1 -1
  325. package/dist/shared/@ai-setting/{roy-agent-core-ezgsem94.js → roy-agent-core-ph5qbqcx.js} +1 -1
  326. package/dist/util/process/process-tree-killer.d.ts +67 -0
  327. package/dist/utils/id.d.ts +11 -0
  328. package/dist/utils/loose-json.d.ts +30 -0
  329. package/dist/utils/media.d.ts +70 -0
  330. package/dist/utils/temp-file-manager/index.d.ts +99 -0
  331. package/package.json +4 -2
  332. /package/dist/shared/@ai-setting/{roy-agent-core-s214vmmd.js → roy-agent-core-4vpk40ss.js} +0 -0
  333. /package/dist/shared/@ai-setting/{roy-agent-core-pkpkctvf.js → roy-agent-core-hch2geta.js} +0 -0
  334. /package/dist/shared/@ai-setting/{roy-agent-core-0cfaqnz9.js → roy-agent-core-k25gv86p.js} +0 -0
@@ -0,0 +1,561 @@
1
+ /**
2
+ * @fileoverview PerTaskGroupChatPlugin - 每任务一个独立飞书群聊
3
+ *
4
+ * Task #3945 实现:
5
+ * - task:after.create → 创建群聊(lark-cli im +chat-create)+ 存 chat_id 到 task.context
6
+ * - task:after.update → 发到 task 群聊(task.context.larkPerTaskChatId)
7
+ * - task:operation:after.create → 节流后发到 task 群聊
8
+ * - task:after.complete → 在 task 群聊发"任务完成"摘要
9
+ *
10
+ * 关键修复(Task #3945 claude-minimax 评估 P0):
11
+ * - P0-1: onAfterUpdate 时 replyChannel fallback 到 task.context.larkPerTaskChatProfile
12
+ * - P0-2: botAppIds 自动从 replyChannel.appId 推导(用户配置可覆盖)
13
+ * - P0-3: 文档明确"方式 A:从 --plugins 移除 LarkCliTaskNotifyPlugin"避免双发
14
+ *
15
+ * 后续修复(Task #XXXX 调试日志 + 新 config 选项):
16
+ * - requireReplyChannel=false:replyChannel 缺失时降级用 fallbackProfile 创建群聊
17
+ * - disableSubTaskSkip=true:sub-task 也建群聊
18
+ * - hasTaskUpdater():诊断方法,检查 taskUpdater 是否注入
19
+ * - 完整诊断日志:每个 skip 分支都输出原因 + 修复建议(ROY_TASK_NOTIFY_DEBUG=1 可见)
20
+ *
21
+ * Task #3987(用户方案 A+B 合并)新增字段:
22
+ * - defaultInviteUserIds:始终邀请的用户列表(不会自动推导 sender)
23
+ * - inviteUserIds:动态列表,可用 "sender" 占位符从 replyChannel 自动推导
24
+ * - 两个字段 union 后去重,得到最终邀请列表
25
+ *
26
+ * ★ 关键约束:setTaskUpdater() 必须由 EventSource handler 注入(DI 模式)。
27
+ * event-source-handlers.ts:registerPluginHooks 检测到 plugin.setTaskUpdater 存在时
28
+ * 会自动注入 taskComponent.updateTask 包装函数。
29
+ * 未注入时 chat_id 只更新 in-memory,DB 没持久化 → 下次 AFTER_UPDATE silently skip。
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // 在 EventSource 中注册(自动注入 setTaskUpdater)
34
+ * import { createPerTaskGroupChatPlugin } from "./per-task-group-chat-plugin";
35
+ *
36
+ * const hook = createPerTaskGroupChatPlugin({
37
+ * pluginName: "PerTaskGroupChatPlugin",
38
+ * sourceId: "es-lark-1",
39
+ * botAppIds: ["cli_xxx"], // 可选,留空则从 replyChannel.appId 自动推导
40
+ * requireReplyChannel: false, // 默认 true;CLI/测试场景可设 false
41
+ * fallbackProfile: "default", // requireReplyChannel=false 时降级用此 profile
42
+ * defaultInviteUserIds: ["ou_admin_xxx"], // ★ 始终邀请(如 admin / 共享账号)
43
+ * inviteUserIds: ["sender"], // ★ 动态占位(自动推导当前 sender)
44
+ * });
45
+ * ```
46
+ *
47
+ * @调试日志
48
+ * - 启用 `ROY_TASK_NOTIFY_DEBUG=1` 环境变量可看到所有 debug 日志
49
+ * - 每个 skip 分支都标注了原因和修复建议
50
+ * - attachChatIdToTask 失败时会有 ⚠️ warn 标记
51
+ */
52
+ import type { Hook, HookContext } from "../../hook/types";
53
+ import type { Task } from "../types";
54
+ import type { SessionComponent } from "../../session/session-component";
55
+ /**
56
+ * PerTaskGroupChatPlugin 配置
57
+ */
58
+ export interface PerTaskGroupConfig {
59
+ /** 是否启用 */
60
+ enabled?: boolean;
61
+ /** 优先级(默认 100,确保在 LarkCliTaskNotifyPlugin (50) 之后) */
62
+ priority?: number;
63
+ /** 插件名称(用于 pluginEnabled 检查) */
64
+ pluginName?: string;
65
+ /** 事件源 ID(用于 pluginEnabled 检查) */
66
+ sourceId?: string;
67
+ /** 群聊命名模板(默认 "Task #{id}: {title}") */
68
+ nameTemplate?: string;
69
+ /** 群聊描述模板 */
70
+ descriptionTemplate?: string;
71
+ /**
72
+ * bot app_id 列表(默认从 replyChannel.appId 自动推导)
73
+ *
74
+ * ★ P0-2 修复:如果未提供,则从 replyChannel.appId 取值。
75
+ * 如果 replyChannel.appId 也未提供,则 fallback 到空数组并在创建群聊时跳过 --bots 参数。
76
+ */
77
+ botAppIds?: string[];
78
+ /**
79
+ * ★ P0 修复:邀请 user 进群聊的 open_id 列表
80
+ *
81
+ * 关键:lark-cli 创建群聊默认是 private chat,不邀请 user 则 user 看不到群聊。
82
+ *
83
+ * 特殊值:
84
+ * - "sender":自动邀请 event sender(replyChannel.userId)进群
85
+ *
86
+ * 默认值:["sender"](自动邀请发起 task 的用户)
87
+ *
88
+ * 设为空数组 [] 则不邀请任何 user(user 看不到群聊,仅适用于 admin 手动加人的场景)。
89
+ *
90
+ * ★ Task #3987:本字段与 `defaultInviteUserIds` 是**互补关系**——
91
+ * 本字段可包含 "sender" 占位符做动态推导,defaultInviteUserIds 是静态列表。
92
+ * 最终邀请列表 = defaultInviteUserIds ∪ inviteUserIds (去重)。
93
+ * 注意:本字段不接受 "sender" 之外的占位符,所有非 sender 值都会被视为 open_id 字面量。
94
+ */
95
+ inviteUserIds?: string[];
96
+ /**
97
+ * ★ Task #3987:始终邀请进群聊的 user open_id 列表
98
+ *
99
+ * 与 `inviteUserIds` 的区别:
100
+ * - defaultInviteUserIds: 静态列表,**不接受 "sender" 占位符**,
101
+ * 每次建群都强制邀请这些 user(适合 admin / 共享账号 / 必看人员)
102
+ * - inviteUserIds: 动态列表,可含 "sender" 占位符,从 replyChannel 推导
103
+ *
104
+ * 使用场景:
105
+ * - 团队有一个"任务监督者"账号(如 SRE on-call bot),希望所有 task 群聊都拉它入群
106
+ * → 把它放进 defaultInviteUserIds,不用每个 event-source 都重复配置
107
+ * - 多 event-source 共享同一组"必邀请"用户时,集中配置避免遗漏
108
+ *
109
+ * 默认值:[](不邀请任何额外 user)
110
+ *
111
+ * ★ 注意:与 inviteUserIds 类似,defaultInviteUserIds 里的 open_id 也必须属于
112
+ * 当前 lark-cli profile 对应的 app(飞书 user open_id 是 per-app 隔离的),
113
+ * 否则 lark-cli 会报 99992361 "open_id cross app"。
114
+ */
115
+ defaultInviteUserIds?: string[];
116
+ /** 创建失败时是否降级(默认 true:主聊天框仍然由 LarkCliTaskNotifyPlugin 处理) */
117
+ fallbackToMain?: boolean;
118
+ /**
119
+ * 操作记录节流(同 LarkCliTaskNotifyPlugin)
120
+ *
121
+ * 默认 5000ms,设为 0 表示不节流。
122
+ */
123
+ operationThrottleMs?: number;
124
+ /**
125
+ * 是否对 sub-task 跳过群聊创建(默认 true)
126
+ *
127
+ * 父 task 已建群聊,sub-task 不重复建群(避免群聊爆炸)。
128
+ * 设为 false 时,每个 task(包括 sub-task)都会建独立群聊。
129
+ */
130
+ disableSubTaskSkip?: boolean;
131
+ /**
132
+ * onAfterCreate 是否要求 replyChannel.chatId 必须存在(默认 true)
133
+ *
134
+ * 默认行为:没有 replyChannel(env 上下文里 chatId 为空)就 silently skip。
135
+ * 设为 false 时:
136
+ * - profile 降级到 config.profile 或 undefined(让 lark-cli 用 active profile)
137
+ * - "群聊已创建"通知到主聊天框这一步会跳过(没有 chatId 可发)
138
+ * 适用场景:CLI/测试/无 IM 上下文中创建 task 时仍想建群聊。
139
+ */
140
+ requireReplyChannel?: boolean;
141
+ /**
142
+ * 自定义 lark-cli profile(仅 requireReplyChannel=false 时生效)
143
+ *
144
+ * replyChannel 缺失时,createGroupChat 用这个 profile 调用 lark-cli。
145
+ * 不设置时让 lark-cli 用 active profile。
146
+ */
147
+ fallbackProfile?: string;
148
+ /**
149
+ * 创建群聊后是否立即发送"任务创建"欢迎消息(默认 true)
150
+ *
151
+ * ★ 推荐开启:新群聊如果没有首条消息,飞书侧可能不会立刻在侧边栏/会话列表中
152
+ * 显示该群聊(要等其他成员发言或主动搜索才能找到)。
153
+ * 发一条欢迎消息会让群聊立刻可见,并标明用途("此群用于追踪 task #N")。
154
+ *
155
+ * 设为 false 时:群聊创建后保持沉默,仅在 task 更新/完成时才有消息。
156
+ * 适用场景:极简通知风格 / 噪音敏感场景。
157
+ */
158
+ sendWelcomeMessage?: boolean;
159
+ /**
160
+ * #4108 P1-b(opt-in):无 per-task 群时是否用 EventStore 反查原始 trigger 群兜底。
161
+ *
162
+ * 默认 false —— 因为 LarkCliTaskNotifyPlugin 与 PerTaskGroupChatPlugin 常同时启用,
163
+ * 若 PerTaskGroupChatPlugin 也兜底到 trigger 群,会和 LarkCliTaskNotifyPlugin 的
164
+ * 直发**重复**(同一群两条消息)。
165
+ *
166
+ * 适用场景:只启用 PerTaskGroupChatPlugin(未启用 LarkCliTaskNotifyPlugin)时,
167
+ * 设为 true 可让"自身无群"的任务更新/操作/完成通知回落到 trigger 群,而不是
168
+ * silently skip(消除 #4039 C 提到的"更新通知被 skip"的不对称)。
169
+ */
170
+ resolveToTriggerChatFallback?: boolean;
171
+ /**
172
+ * Task #4192:建群后是否立刻发一张交互式卡片(notifier.startTask)
173
+ *
174
+ * 默认 true(推荐):
175
+ * - 建群后立刻发卡片,飞书用户能看到一张"任务已创建"卡片,后续 update 都 patch 同一卡片
176
+ * - 不发普通文字消息(避免"群聊已创建 + 任务已创建"两条噪音)
177
+ *
178
+ * 设为 false 时:
179
+ * - 走旧的 sendWelcomeMessage 路径(默认文本欢迎消息)
180
+ * - 适用于保留旧行为的场景
181
+ */
182
+ cardInitialMessage?: boolean;
183
+ /**
184
+ * Task #4331:是否在 task 创建时**自动**建专属群(默认 false)
185
+ *
186
+ * 历史行为(autoCreateGroup=true 显式开启):
187
+ * - onAfterCreate 触发 → 调 createGroupChat 建专属群 → 写 task.context.larkPerTaskChatId
188
+ * - 适用:每个 task 想要独立工作群的场景
189
+ *
190
+ * 默认行为(autoCreateGroup 未传或 false):
191
+ * - onAfterCreate → silently skip(**不**建群)
192
+ * - 任务卡片只发到触发群(replyChannel.chatId)
193
+ * - 用户在卡片顶部点"为这个任务建群"按钮 → 走 ensureGroupChat 按需建群
194
+ * - 适用:减少群聊爆炸 / 集中讨论 / 减少噪音
195
+ *
196
+ * ★ 与 LarkCliTaskNotifyPlugin.cardRoutingPorts.ensureTaskGroupChat 协同:
197
+ * - LarkCliTaskNotifyPlugin 在路由决策 source="new-group" 时也会调 ensureGroupChat
198
+ * - 用户本次改造明确要求"默认不建群",所以 LarkCliTaskNotifyPlugin 的 new-group 路径
199
+ * 也被改造为 fallback-to-trigger(不调 ensure)
200
+ */
201
+ autoCreateGroup?: boolean;
202
+ /**
203
+ * Task #4192:共享 LarkCardPatchNotifier 实例
204
+ *
205
+ * - 不传 → plugin 自己 new 一个(适用于仅启用本 plugin 的场景)
206
+ * - 传同一实例(与 LarkCliTaskNotifyHook 共享)→ 跨 plugin messageId 协调,
207
+ * 保证 LarkCliTaskNotifyHook 的 updateTask 能 patch 本 plugin startTask 发的卡片
208
+ */
209
+ cardNotifier?: import("./lark-card-patch-notifier").LarkCardPatchNotifier;
210
+ }
211
+ /**
212
+ * PerTaskGroupChatPlugin - 每 task 一个独立飞书群聊
213
+ *
214
+ * 与 LarkCliTaskNotifyPlugin 的关系(★ P0-3 双发问题):
215
+ * - LarkCliTaskNotifyPlugin: 发到主聊天框(replyChannel.chatId)
216
+ * - PerTaskGroupChatPlugin: 发到 task 群聊(task.context.larkPerTaskChatId)
217
+ *
218
+ * 两种 plugin 监听相同的 hook 点(task:after.update),都会触发。
219
+ * 文档明确推荐"方式 A"——用户配置 event-source 时只启用 PerTaskGroupChatPlugin:
220
+ *
221
+ * ```bash
222
+ * roy-agent eventsource update <lark-cli-source-id> \
223
+ * --plugins "PerTaskGroupChatPlugin"
224
+ * # 不要包含 LarkCliTaskNotifyPlugin,否则主聊天框也会收到 AFTER_UPDATE 通知
225
+ * ```
226
+ *
227
+ * 如果保留 LarkCliTaskNotifyPlugin,则 PerTaskGroupChatPlugin 应配置为 disabled,
228
+ * 或用户接受"主聊天框 + task 群聊"双通道通知(用于调试/迁移期)。
229
+ */
230
+ export declare class PerTaskGroupChatPlugin implements Hook {
231
+ readonly name: string;
232
+ readonly priority: number;
233
+ readonly pluginName?: string;
234
+ readonly sourceId?: string;
235
+ private readonly config;
236
+ /**
237
+ * 操作记录节流状态
238
+ * key: `${taskId}`, value: 上次发送时间戳
239
+ */
240
+ private lastNotifyTimestamps;
241
+ /**
242
+ * Task update 任务(DI 注入,由 EventSource 提供)
243
+ * 用于 attachChatIdToTask 把 chat_id 写回 task.context
244
+ */
245
+ private taskUpdater?;
246
+ /**
247
+ * Task 查询器(DI 注入,由 EventSource 提供)
248
+ *
249
+ * Task #4039 C 项(统一群解析):sub-task 自身没有独立群时,需要沿
250
+ * `parent_task_id` 上溯到最近拥有群的祖先,才能与 CLI notify 路径
251
+ * (resolveNotifyChatIds)解析出**同一个群**。未注入时退化为只读自身 context。
252
+ */
253
+ private taskGetter?;
254
+ /**
255
+ * Session component(DI 注入,由 EventSource 提供)
256
+ *
257
+ * Task #4023:用于把 chat_id ↔ task_id 反向绑定写到 session.metadata.larkChat,
258
+ * 让群聊消息事件 handler 能从 session 反向查到当前群绑定的 task。
259
+ *
260
+ * 未注入时:跳过反向绑定(task.context 的 larkPerTaskChatId 仍正常工作),
261
+ * 但群消息 handler 拿不到 parentTaskId 注入。
262
+ */
263
+ private sessionComponent?;
264
+ /**
265
+ * ★ Task #4230:卡片 notifier 实例(默认 plugin 自己 new,可被外部共享)
266
+ *
267
+ * 用于建群后立即发一张交互式卡片(notifier.startTask),
268
+ * 后续 update / operation / complete 都 patch **同一张卡片**(不刷屏)。
269
+ */
270
+ private cardNotifier;
271
+ /**
272
+ * ★ Task #4230:卡片 messageId 跟踪(key: taskId)
273
+ *
274
+ * 单卡片语义:同一 task 的 create → update → operation → complete
275
+ * 必须复用同一 messageId。旧实现在 update/complete 走纯文本消息,
276
+ * 卡片只发不发更新 —— 已删除。
277
+ */
278
+ private cardMessageIds;
279
+ /** 卡片启动失败哨兵(避免 update 重试风暴) */
280
+ private static readonly CARD_START_FAILED_SENTINEL;
281
+ /**
282
+ * ★ Task #4237 修复:同一 task 的建群请求 in-flight 去重
283
+ *
284
+ * 根因:`ensureGroupChat`(notify hook 按需建群)与 `onAfterCreate`(本插件)
285
+ * 是两条独立路径,都可能给同一 task 建群;若两者几乎同时进入,
286
+ * "读 context → 建群" 之间没有互斥 → 建出两个同名群。
287
+ *
288
+ * key = taskId;value = 正在进行的建群 promise(后来者直接复用)
289
+ */
290
+ private groupChatInflight;
291
+ constructor(config?: PerTaskGroupConfig);
292
+ /**
293
+ * Task #4230 follow-up:按需为 task 建/取专属群(供卡片路由使用)
294
+ *
295
+ * 场景:任务是在**别的 task 的专属群**里被触发的(例如在 #3999 的跟进群里
296
+ * 让 agent 建了 #4226),此时代码不能把 #4226 的卡片塞进 #3999 的群,也不该
297
+ * 因为"sub-task 跳过建群"就让 #4226 无家可归 → 这里按需建一个专属群。
298
+ *
299
+ * 与 onAfterCreate 的差别(有意为之):
300
+ * - 不做 sub-task skip(这是"按需补建"路径)
301
+ * - 不发初始卡片(卡片由调用方 LarkCliTaskNotifyHook 基于同一 chatId 发送,
302
+ * 避免重复卡片)
303
+ *
304
+ * 会顺手写 chat↔task 绑定 + 把 chatId 持久化进 task.context,因此后续
305
+ * 解析(lineage 上溯)能直接命中。
306
+ *
307
+ * @returns { chatId, profile } 建群成功;undefined = 建群失败(caller 自行降级)
308
+ */
309
+ ensureGroupChat(task: Task,
310
+ /**
311
+ * replyChannel 覆盖(hook 调用方从 `ctx.metadata.envContext` 拿到的那份)
312
+ *
313
+ * 为什么需要:hook 被直接调用(测试 / eventsource 直调 plugin.execute)时,
314
+ * ALS 里没有 EnvContext,但 `ctx.metadata.envContext.replyChannel` 有值。
315
+ * 旧 onAfterCreate 走 getReplyChannelFromCtx 能拿到,所以这里必须支持传入,
316
+ * 否则会误判「没有 replyChannel → 不建群」。
317
+ */
318
+ replyChannelOverride?: {
319
+ chatId?: string;
320
+ messageId?: string;
321
+ userId?: string;
322
+ appId?: string;
323
+ profile?: string;
324
+ }): Promise<{
325
+ chatId: string;
326
+ profile?: string;
327
+ name?: string;
328
+ } | undefined>;
329
+ /** ensureGroupChat 的实际建群逻辑(调用方已做幂等/in-flight 去重) */
330
+ private doEnsureGroupChat;
331
+ /**
332
+ * 注入 Task 更新函数(用于 attachChatIdToTask 把 chat_id 写回 DB)
333
+ *
334
+ * 由 EventSource handler 在 plugin 实例化时注入(event-source-handlers.ts:registerPluginHooks)。
335
+ * 未注入时:chat_id 只更新 in-memory task.context,DB 里没持久化 → 下次 AFTER_UPDATE
336
+ * 从 DB 加载 task 时 getTaskChatId() 返回 undefined,所有后续更新通知 silently 丢失。
337
+ *
338
+ * 通过 hasTaskUpdater() 可检查是否已注入。
339
+ */
340
+ setTaskUpdater(updater: (taskId: number, context: string) => Promise<void>): void;
341
+ /**
342
+ * 检查 taskUpdater 是否已注入(用于诊断和测试)
343
+ */
344
+ hasTaskUpdater(): boolean;
345
+ /**
346
+ * 注入 Task 查询器(用于 sub-task 上溯祖先群,Task #4039 C 项)。
347
+ */
348
+ setTaskGetter(getter: (id: number) => Promise<{
349
+ context?: string;
350
+ parent_task_id?: number | null;
351
+ } | undefined>): void;
352
+ /**
353
+ * 检查 taskGetter 是否已注入(用于诊断和测试)
354
+ */
355
+ hasTaskGetter(): boolean;
356
+ /**
357
+ * 注入 Session component(用于 chat_id ↔ task_id 反向绑定)
358
+ *
359
+ * Task #4023: 在 onAfterCreate 建群成功后,调 SessionComponent.upsertChatTaskBinding
360
+ * 把 chatId 写到 session.metadata.larkChat.taskId。让群消息 handler 反向查到 task。
361
+ *
362
+ * 未注入时:跳过反向绑定(task.context.larkPerTaskChatId 仍正常工作)。
363
+ */
364
+ setSessionComponent(sessionComponent: SessionComponent): void;
365
+ /**
366
+ * 检查 SessionComponent 是否已注入(用于诊断和测试)
367
+ */
368
+ hasSessionComponent(): boolean;
369
+ execute(ctx: HookContext<unknown>): Promise<void>;
370
+ /**
371
+ * onAfterCreate: 创建 task 群聊 + 存 chat_id 到 task.context
372
+ *
373
+ * 决策日志(ROY_TASK_NOTIFY_DEBUG=1 时可见):
374
+ - replyChannel.chatId 缺失 + requireReplyChannel=true → skip
375
+ - sub-task + disableSubTaskSkip=false → skip
376
+ - 群聊创建失败 → fallback(fallbackToMain=false 时抛出)
377
+ */
378
+ private onAfterCreate;
379
+ /**
380
+ * 写 chat_id ↔ task_id 反向绑定(Task #4023)。
381
+ *
382
+ * 状态机:creating → ready(成功)/ failed(post-create 失败)。
383
+ * 失败不阻断主流程(task.context.larkPerTaskChatId 仍正常工作),仅 warn。
384
+ * 未注入 sessionComponent 时静默跳过(debug 可见)。
385
+ *
386
+ * Span 属性(flattenParamFilter=true):taskId / chatId / status,
387
+ * 便于 `debug trace` 验证写侧状态迁移(creating→ready/failed)。
388
+ */
389
+ private writeChatBinding;
390
+ /**
391
+ * onAfterUpdate: 发到 task 群聊
392
+ *
393
+ * ★ P0-1 修复:replyChannel 在 onAfterUpdate 可能为空(TaskComponent 内部触发),
394
+ * 此时 fallback 到 task.context.larkPerTaskChatProfile。
395
+ *
396
+ * 重要诊断:如果 task.context 没有 larkPerTaskChatId,说明:
397
+ * 1. task 创建时 plugin 没被 enabled(eventsource handleRule.plugins 缺失)
398
+ * 2. task 创建时 plugin 已 enabled 但 chat_id 没持久化到 DB(taskUpdater 未注入)
399
+ * 3. task 是通过其它途径创建的(旧 task 迁移场景)
400
+ * → 这 3 种情况都让 onAfterUpdate silently skip,需要查 eventsource 配置 + DB 状态
401
+ */
402
+ private onAfterUpdate;
403
+ /**
404
+ * onAfterOperationCreate: 节流后发到 task 群聊
405
+ */
406
+ private onAfterOperationCreate;
407
+ /**
408
+ * onAfterComplete: task 进入 terminal 状态,在 task 群聊发"任务完成"摘要
409
+ *
410
+ * 设计:AFTER_COMPLETE 与 AFTER_UPDATE 都触发,但 AFTER_COMPLETE 发的消息
411
+ * 更突出"完成/失败/cancelled/timeout"语义。
412
+ *
413
+ * ★ Task #3957:AFTER_COMPLETE hook 点在 LarkCliInstance.getPluginHookPoints() 注册。
414
+ * 之前 fallback 列表只返回 3 个 hook 点(缺 AFTER_COMPLETE),导致本方法永远不被触发。
415
+ */
416
+ private onAfterComplete;
417
+ /**
418
+ * 调用 lark-cli 创建群聊
419
+ *
420
+ * Span 输出参数(flattenParamFilter=true):
421
+ * - profile: 使用的 lark-cli profile
422
+ * - botAppIds.length: 邀请的额外 bot 数
423
+ * - userIds.length: 邀请的 user 数(★ P0 关键:user 看不到群聊的 root cause)
424
+ * - name / description: 群聊名/描述
425
+ * Span 输出结果(flattenParamFilter=true):
426
+ * - chatId: 创建成功的 chat_id(用于后续 sendToChat / 写入 task.context)
427
+ */
428
+ private createGroupChat;
429
+ /**
430
+ * 构造 `+chat-create` 命令的 args(提取出来便于单测)
431
+ *
432
+ * ★ 关键设计:
433
+ * - profile 有值时 → 必须加 `--as bot`,否则 lark-cli 用 user 身份建群,
434
+ * profile 对应的 bot 不是群成员,后续 bot 发消息会失败
435
+ * - botAppIds 是邀请额外的 bots(除 --as bot 的当前 bot 之外),可选
436
+ * - userIds 是邀请原 user 进群(**P0 关键**:不邀请则 user 看不到群聊)
437
+ * - `--set-bot-manager` 需要 `--as bot` 才生效
438
+ *
439
+ * Span 参数:
440
+ * - hasProfile: 是否有 profile(决定是否加 --as bot)
441
+ * - botAppIdsCount: 额外 bot 数
442
+ * - hasUsers: 是否邀请用户(--users)
443
+ * - argsSummary: args 的可读摘要(lark-cli im +chat-create ...)
444
+ */
445
+ private buildCreateGroupChatArgs;
446
+ /**
447
+ * 把 chat_id 写回 task.context JSON
448
+ *
449
+ * 持久化路径:
450
+ * 1. taskUpdater 已注入 → 调 updater(task.id, newContext) 写 DB
451
+ * 2. taskUpdater 未注入 → 只更新 in-memory task.context(DB 没持久化)
452
+ * ⚠️ 这种情况是 bug:下次 AFTER_UPDATE 从 DB 加载 task 时 getTaskChatId() 返回 undefined,
453
+ * 所有后续 update/complete/operation 通知都会 silently skip。
454
+ * 修复:event-source-handlers.ts:registerPluginHooks 必须检测 plugin.setTaskUpdater 并注入。
455
+ */
456
+ private attachChatIdToTask;
457
+ /**
458
+ * 从 HookContext 获取 replyChannel
459
+ *
460
+ * 优先级:
461
+ * 1. ctx.metadata.envContext.replyChannel(EventSource 触发)
462
+ * 2. 直接 ctx.metadata.replyChannel
463
+ *
464
+ * ★ P0-1 关键:如果都没有,返回 undefined(调用方应 fallback 到 task.context)
465
+ */
466
+ private getReplyChannelFromCtx;
467
+ /** 从 context JSON 字符串读 larkPerTaskChatId */
468
+ private parseChatIdFromContext;
469
+ /** 从 context JSON 字符串读 larkPerTaskChatProfile(★ P0-1 fallback) */
470
+ private parseProfileFromContext;
471
+ /**
472
+ * 从 task 读 larkPerTaskChatId(任务**自身**的群)
473
+ */
474
+ private getTaskChatId;
475
+ /**
476
+ * 从 task 读 larkPerTaskChatProfile(任务**自身**的群)
477
+ */
478
+ private getTaskChatProfile;
479
+ /**
480
+ * 解析 task 的"生效群"(Task #4039 C 项:与 CLI notify 路径统一)。
481
+ *
482
+ * 规则:先取任务自身的 `larkPerTaskChatId`;没有则沿 `parent_task_id` 上溯最近的
483
+ * 祖先群(有界 8 层)。与 CLI 的 `resolveNotifyChatIds` 语义一致,保证
484
+ * "更新 / 完成 / 操作"通知与 "notify 镜像"落到**同一个群**(消除 sub-task 更新被
485
+ * silently skip 的不对称)。
486
+ *
487
+ * 未注入 taskGetter 时退化为只读自身 context(保持向后兼容)。
488
+ */
489
+ private resolveEffectiveChat;
490
+ /**
491
+ * ★ P0-2 修复:botAppIds 推导
492
+ *
493
+ * 优先级:
494
+ * 1. 用户在 config 显式提供
495
+ * 2. 从 replyChannel.appId 推导(lark-cli 群聊需要 bot 才能"加入",必须至少有 1 个 botAppId)
496
+ * 3. 空数组(让 lark-cli 自行报错或跳过 --bots 参数)
497
+ */
498
+ private resolveBotAppIds;
499
+ /**
500
+ * ★ P0 修复 + Task #3987 扩展:resolveUserIds - 推导要邀请进群聊的 user open_id
501
+ *
502
+ * 不邀请 user → user 看不到群聊(chat 是私有的,只有 bot 在里面)
503
+ *
504
+ * 来源(最终 union 去重):
505
+ * 1. config.defaultInviteUserIds:始终邀请的静态列表(不含 "sender" 占位符)
506
+ * 2. config.inviteUserIds 中除 "sender" 之外的所有 open_id(静态)
507
+ * 3. config.inviteUserIds 含 "sender" → 自动从 replyChannel/params/ALS 推导 sender
508
+ * 优先级:replyChannel.userId > replyChannel.params?.userId > ALS userId
509
+ * 4. ALS getEnvContextOrEmpty().userId(仅当上面都没拿到时 fallback)
510
+ */
511
+ private resolveUserIds;
512
+ /**
513
+ * 检查 task 是否是 sub-task
514
+ *
515
+ * 父 task 已建群聊,sub-task 不重复建群(避免群聊爆炸)
516
+ */
517
+ private isSubTask;
518
+ /**
519
+ * 检查 update 是否有"有意义"的变更(status / progress / priority)
520
+ *
521
+ * 避免每次 task.update 都发通知(ctx.after.update 在多次 sub-update 时会反复触发)
522
+ */
523
+ private hasMeaningfulChange;
524
+ /**
525
+ * 操作记录节流
526
+ */
527
+ private shouldThrottleOperation;
528
+ /**
529
+ * 渲染模板字符串
530
+ *
531
+ * ★ P1 修复:同时支持 `#{var}` 和 `{var}` 两种格式
532
+ *
533
+ * 默认模板用 `{var}`(不带 hash),但 renderTemplate 只替换 `#{var}`,
534
+ * 导致群聊标题/描述里残留字面 `{title}` / `{project_path}` 占位符。
535
+ *
536
+ * 现在两种格式都替换:
537
+ * - `#{id}` / `{id}`
538
+ * - `#{title}` / `{title}`
539
+ * - `#{project_path}` / `{project_path}`
540
+ *
541
+ * 同时支持任意其它 `#{xxx}` / `{xxx}` 占位符(不渲染则原样输出,便于 debug)。
542
+ */
543
+ private renderTemplate;
544
+ /**
545
+ * 截断字符串
546
+ */
547
+ private truncate;
548
+ /**
549
+ * 解析 lark-cli +chat-create 输出 → chat_id
550
+ *
551
+ * lark-cli 输出格式示例:
552
+ * ```json
553
+ * {"ok": true, "data": {"chat_id": "oc_xxx"}}
554
+ * ```
555
+ */
556
+ private parseChatId;
557
+ }
558
+ /**
559
+ * 创建 PerTaskGroupChatPlugin 实例(Hook 工厂)
560
+ */
561
+ export declare function createPerTaskGroupChatPlugin(config?: PerTaskGroupConfig): PerTaskGroupChatPlugin;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @fileoverview TaskTagPlugin - 类似任务信息注入
3
+ *
4
+ * 统一插件架构下的 TaskTagPlugin 实现
5
+ *
6
+ * Hook 逻辑实现:
7
+ * - delegateBefore: 注入类似任务信息(使用 keywords 检索,最多 5 个)
8
+ * - operationAfterCreate: 任务完成时提取 Workflow
9
+ *
10
+ * 改造说明:
11
+ * - 继承 BasePlugin,实现统一插件接口
12
+ * - 通过 PluginEnv.init() 获取依赖组件
13
+ * - 使用 PluginEnv.registerHook() 注册 hooks
14
+ */
15
+ import { BasePlugin, type PluginEnv } from "../../plugin/types";
16
+ export declare class TaskTagPlugin extends BasePlugin {
17
+ readonly name = "task-tag";
18
+ readonly version = "1.0.0";
19
+ readonly description = "Inject similar task information into delegate prompt and extract workflow on task completion";
20
+ /** Plugin Env(init 时设置) */
21
+ private env;
22
+ /** TaskComponent 引用 */
23
+ private taskComponent;
24
+ /** AgentComponent 引用 */
25
+ private agentComponent;
26
+ /** TagService 引用 */
27
+ private tagService;
28
+ constructor();
29
+ /**
30
+ * 初始化
31
+ */
32
+ init(env: PluginEnv): void;
33
+ /**
34
+ * 销毁
35
+ */
36
+ dispose(): void;
37
+ /**
38
+ * 委派前:注入类似任务信息
39
+ */
40
+ private onDelegateBefore;
41
+ /**
42
+ * 从 task 提取关键词
43
+ */
44
+ private extractKeywords;
45
+ /**
46
+ * 格式化类似任务(简洁版)
47
+ */
48
+ private formatSimilarTasks;
49
+ private onOperationAfterCreate;
50
+ /**
51
+ * 提取工作流(公开方法,用于测试)
52
+ */
53
+ extractWorkflow(taskId: number, sessionId?: string): Promise<void>;
54
+ /**
55
+ * Validate a workflow definition (defense-in-depth check before add).
56
+ *
57
+ * Delegates to the shared validateWorkflowDefinition helper which wraps
58
+ * DAGManager.validate() and is the single source of truth across all
59
+ * workflow entry points (tool, CLI, plugin).
60
+ *
61
+ * Note: The 'workflow-extract' agent should have validated already via
62
+ * workflow_validate tool, but we add this check here as a safety net.
63
+ *
64
+ * @returns { valid: boolean, errors: string[] }
65
+ */
66
+ private validateWorkflowDefinition;
67
+ private _workflowRepo;
68
+ private getWorkflowRepository;
69
+ private ensureDataDir;
70
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @fileoverview WorkflowExtractorAgent - 工作流提取 Agent
3
+ *
4
+ * 负责从自然语言描述或 Task 对话历史中提取 Workflow YAML。
5
+ *
6
+ * 升级说明(v2):
7
+ * - prompt 内容已迁移到 `prompts-index.ts` 的 `builtInPrompts['workflow-extract']`
8
+ * - 通过 `AgentRegistry.registerWorkflowExtractAgent()` 注册为内置 agent
9
+ * - 此文件保留工具函数(formatExtractorInput / parseExtractorOutput)供 task-tag-plugin 使用
10
+ * - `WORKFLOW_EXTRACTOR_PROMPT` 保留为 alias(向后兼容),实际指向 built-in prompt
11
+ */
12
+ import type { Task, TaskOperation } from "../types";
13
+ import type { SessionMessage } from "../../session/session-component";
14
+ import type { WorkflowDefinition } from "../../workflow/types";
15
+ /**
16
+ * Workflow Extractor Agent System Prompt(向后兼容 alias)
17
+ *
18
+ * @deprecated
19
+ * 历史:之前直接定义在此文件。现在统一从 `prompts-index.ts` 的
20
+ * `builtInPrompts['workflow-extract']` 读取,并 re-export 为 `WORKFLOW_EXTRACT_PROMPT`。
21
+ *
22
+ * 这个常量保留只是为了**向后兼容**:旧代码可能仍 import 此名称。
23
+ * 新代码应使用 `import { WORKFLOW_EXTRACT_PROMPT } from "../../prompt/prompts-index"`。
24
+ */
25
+ export declare const WORKFLOW_EXTRACTOR_PROMPT: string;
26
+ /**
27
+ * 格式化提取器输入 - 从 Task 提取
28
+ */
29
+ export declare function formatExtractorInput(params: {
30
+ task: Task;
31
+ operations: TaskOperation[];
32
+ messages: SessionMessage[];
33
+ }): string;
34
+ /**
35
+ * 格式化提取器输入 - 从自然语言描述提取
36
+ */
37
+ export declare function formatExtractorInputFromDescription(params: {
38
+ description: string;
39
+ }): string;
40
+ /**
41
+ * 解析提取器输出
42
+ */
43
+ export declare function parseExtractorOutput(output: string): Promise<WorkflowDefinition | null>;