@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,145 @@
1
+ /**
2
+ * @fileoverview Debug Component Types
3
+ *
4
+ * Type definitions for trace parsing, formatting, and debugging utilities.
5
+ */
6
+ /**
7
+ * Trace action type
8
+ */
9
+ export type TraceAction = 'enter' | 'quit' | 'error';
10
+ /**
11
+ * Log level type
12
+ */
13
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
14
+ /**
15
+ * Trace entry representing a single log line with trace info
16
+ */
17
+ export interface TraceEntry {
18
+ /** Unique request/trace identifier */
19
+ traceId: string;
20
+ /** Timestamp of the entry (ISO format) */
21
+ timestamp: string;
22
+ /** Function/method name */
23
+ function: string;
24
+ /** Action type: enter, quit, or error */
25
+ action: TraceAction;
26
+ /** Parameters (for enter action) */
27
+ params?: unknown[];
28
+ /** Result (for quit action) */
29
+ result?: unknown;
30
+ /** Error message (for error action) */
31
+ error?: string;
32
+ /** Calculated duration in milliseconds (for quit action) */
33
+ durationMs?: number;
34
+ /** Span ID (for SQLite spans) */
35
+ spanId?: string;
36
+ /** Parent span ID (for SQLite spans) */
37
+ parentSpanId?: string;
38
+ }
39
+ /**
40
+ * Call tree node for hierarchical trace visualization
41
+ */
42
+ export interface TraceTreeNode {
43
+ /** Unique request/trace identifier */
44
+ traceId: string;
45
+ /** Function/method name */
46
+ function: string;
47
+ /** Start timestamp */
48
+ startTime: string;
49
+ /** End timestamp (for completed nodes) */
50
+ endTime?: string;
51
+ /** Duration in milliseconds */
52
+ durationMs?: number;
53
+ /** Child nodes */
54
+ children: TraceTreeNode[];
55
+ /** Original trace entry (optional for programmatically created nodes) */
56
+ entry?: TraceEntry;
57
+ /** Span ID (for SQLite spans) */
58
+ spanId?: string;
59
+ /** Parent span ID (for SQLite spans) */
60
+ parentSpanId?: string;
61
+ }
62
+ /**
63
+ * Options for parsing logs
64
+ */
65
+ export interface ParserOptions {
66
+ /** Log file path to read */
67
+ logFile?: string;
68
+ /** Filter by trace ID */
69
+ traceId?: string;
70
+ /** Filter by function name (supports partial match) */
71
+ function?: string;
72
+ /** Start time filter (ISO format or relative like "1h") */
73
+ since?: string;
74
+ /** End time filter (ISO format) */
75
+ until?: string;
76
+ /** Log level filter */
77
+ level?: LogLevel;
78
+ }
79
+ /**
80
+ * Options for log discovery
81
+ */
82
+ export interface LogDiscoveryOptions {
83
+ /** Log directory to search */
84
+ logDir?: string;
85
+ /** File pattern to match */
86
+ pattern?: string;
87
+ }
88
+ /**
89
+ * Parsed log line with extracted fields
90
+ */
91
+ export interface ParsedLogLine {
92
+ /** Original log line */
93
+ raw: string;
94
+ /** Timestamp extracted from log */
95
+ timestamp: string;
96
+ /** Log level (INFO, DEBUG, WARN, ERROR) */
97
+ level: string;
98
+ /** Source file/location */
99
+ source: string;
100
+ /** Category (traced:...) */
101
+ category: string;
102
+ /** Action symbol (>>> or <<< or !!!) */
103
+ action: string;
104
+ /** Method/function name */
105
+ method: string;
106
+ /** Action type (enter, quit, error) */
107
+ actionType: TraceAction;
108
+ /** Raw arguments string */
109
+ rawArgs: string;
110
+ /** Request ID extracted from log (if present) */
111
+ requestId: string | null;
112
+ }
113
+ /**
114
+ * Trace ID information summary
115
+ */
116
+ export interface TraceIdInfo {
117
+ /** Trace ID */
118
+ traceId: string;
119
+ /** First occurrence timestamp */
120
+ firstTime: string;
121
+ /** Last occurrence timestamp */
122
+ lastTime?: string;
123
+ /** Number of entries for this trace */
124
+ count: number;
125
+ }
126
+ /**
127
+ * Output format options
128
+ */
129
+ export interface FormatOptions {
130
+ /** Use pretty printing */
131
+ pretty?: boolean;
132
+ /** Maximum depth for recursive objects */
133
+ maxDepth?: number;
134
+ /** Include raw data */
135
+ includeRaw?: boolean;
136
+ }
137
+ /**
138
+ * Trace summary for list output
139
+ */
140
+ export interface TraceSummary {
141
+ /** List of trace ID info */
142
+ traceIds: TraceIdInfo[];
143
+ /** Total count */
144
+ count: number;
145
+ }
@@ -0,0 +1,185 @@
1
+ /**
2
+ * @fileoverview BaseEnvironment Implementation
3
+ *
4
+ * Environment 的基础实现类(非抽象),提供:
5
+ * - 组件注册与管理
6
+ * - 核心调度方法(handle_query, handle_action)
7
+ * - EnvEvent 事件机制
8
+ *
9
+ * 设计原则:
10
+ * 1. Environment 只做两件事:
11
+ * - 组件管理:持有、注册、获取组件
12
+ * - 核心调度:handle_query / handle_action / EnvEvent
13
+ * 2. 其他能力归属到对应 Component
14
+ *
15
+ * 子类可覆盖:
16
+ * - registerDefaultComponents(): 注册默认组件
17
+ * - handle_query(): 查询处理逻辑
18
+ * - handle_action(): 动作处理逻辑
19
+ * - onInit/onStart/onStop: 生命周期钩子
20
+ */
21
+ import { BaseComponent, type Component } from "./component";
22
+ import type { Environment, ServiceConfig, ComponentConfigEntry, GeneratedComponentOptions } from "./interface";
23
+ import type { EnvironmentConfig, BaseEnvironmentConfig, EnvEvent, EnvEventInput, EnvEventHandler, Action, ToolResult, Context } from "./types";
24
+ import type { AgentContext } from "./agent/types";
25
+ import type { ContentPart } from "./llm/types";
26
+ /**
27
+ * 默认 agent 名字(向后兼容)
28
+ */
29
+ export declare const DEFAULT_AGENT_NAME = "Roy";
30
+ /**
31
+ * 注入 {{agent_name}} 占位符
32
+ *
33
+ * - 若 prompt 不含占位符 → 原样返回(零开销)
34
+ * - 从 context.metadata.defaultAgentName 读取值
35
+ * - 缺失/null/undefined/空字符串 → 回退到 DEFAULT_AGENT_NAME
36
+ *
37
+ * 用 `global` 正则(/g)确保替换所有出现,避免残留占位符。
38
+ */
39
+ export declare function injectAgentNamePlaceholder(prompt: string, context?: AgentContext): string;
40
+ /**
41
+ * BaseEnvironment 实现类(非抽象)
42
+ *
43
+ * 实现 Environment 接口,提供简洁的环境基础功能。
44
+ * 子类可继承此类并覆盖特定方法来自定义行为。
45
+ */
46
+ export declare class BaseEnvironment extends BaseComponent implements Environment {
47
+ readonly name: string;
48
+ readonly version: string;
49
+ protected components: Map<string, Component>;
50
+ /**
51
+ * 构造函数
52
+ */
53
+ constructor(config?: BaseEnvironmentConfig);
54
+ /**
55
+ * 注册默认组件(子类可覆盖)
56
+ */
57
+ protected registerDefaultComponents(): void;
58
+ /**
59
+ * 获取环境配置
60
+ */
61
+ getConfig(): EnvironmentConfig & {
62
+ env: Environment;
63
+ };
64
+ /**
65
+ * 注册组件
66
+ */
67
+ registerComponent(component: Component): void;
68
+ /**
69
+ * 注销组件
70
+ */
71
+ unregisterComponent(name: string): void;
72
+ /**
73
+ * 获取组件
74
+ */
75
+ getComponent<T extends Component>(name: string): T | undefined;
76
+ /**
77
+ * 列出所有组件
78
+ */
79
+ listComponents(): Component[];
80
+ /**
81
+ * 处理自然语言查询(核心入口)
82
+ *
83
+ * 委托给 AgentComponent.run() 处理
84
+ */
85
+ handle_query(query: string | ContentPart[], context?: AgentContext): Promise<string>;
86
+ /**
87
+ * ★ Workflow 类型 agent 查询处理
88
+ *
89
+ * 检查 agentDef.type 是否为 "workflow",是则通过 WorkflowComponent 执行 workflow。
90
+ * 非 workflow 类型返回 null,让 handle_query 走原有 ReAct 路径。
91
+ */
92
+ private handleWorkflowAgentQuery;
93
+ /**
94
+ * 处理动作
95
+ *
96
+ * 默认实现抛出错误,子类必须实现。
97
+ */
98
+ handle_action(action: Action, context: Context): Promise<ToolResult>;
99
+ /**
100
+ * 事件订阅者映射
101
+ */
102
+ protected eventHandlers: Map<string, Set<EnvEventHandler>>;
103
+ /**
104
+ * 通配符订阅者(接收所有事件)
105
+ */
106
+ protected wildcardHandlers: Set<EnvEventHandler>;
107
+ /**
108
+ * 订阅 EnvEvent(返回取消订阅函数)
109
+ */
110
+ subscribe(handler: EnvEventHandler): () => void;
111
+ /**
112
+ * 订阅指定类型事件
113
+ */
114
+ subscribeTo(eventType: string | string[], handler: EnvEventHandler): () => void;
115
+ /**
116
+ * 订阅所有事件(通配符)
117
+ *
118
+ * 与 subscribe 相同,为保持 API 一致性
119
+ */
120
+ subscribeAll(handler: EnvEventHandler): () => void;
121
+ /**
122
+ * 推送事件
123
+ */
124
+ pushEnvEvent(event: EnvEvent | EnvEventInput): void;
125
+ /**
126
+ * 创建并推送事件(便捷方法)
127
+ */
128
+ protected emit<T = unknown>(type: string, payload: T, metadata?: Partial<EnvEvent["metadata"]>): void;
129
+ /**
130
+ * 初始化所有组件(分阶段初始化)
131
+ *
132
+ * 1. 第一阶段:初始化 ConfigComponent(如果存在)
133
+ * 2. 第二阶段:初始化其他组件
134
+ */
135
+ protected initializeComponents(): Promise<void>;
136
+ /**
137
+ * 启动所有组件
138
+ *
139
+ * 注意:由于 Environment.init() 会将组件状态设为 "running",我们需要确保
140
+ * 即使组件已经是 "running" 状态,它们的 start() 方法仍然被调用。
141
+ * 这是因为 start() 负责注册工具等运行时资源。
142
+ */
143
+ protected startComponents(): Promise<void>;
144
+ /**
145
+ * 停止所有组件
146
+ */
147
+ protected stopComponents(): Promise<void>;
148
+ /**
149
+ * 初始化(可覆盖)
150
+ */
151
+ protected onInit(): Promise<void>;
152
+ /**
153
+ * 启动(可覆盖)
154
+ */
155
+ protected onStart(): Promise<void>;
156
+ /**
157
+ * 停止(可覆盖)
158
+ */
159
+ protected onStop(): Promise<void>;
160
+ /**
161
+ * BaseComponent 钩子
162
+ *
163
+ * Environment 特殊处理:它本身就是 env,所以不需要外部传入。
164
+ * 此方法覆盖 BaseComponent.init(),直接设置自引用。
165
+ */
166
+ init(): Promise<void>;
167
+ start(): Promise<void>;
168
+ stop(): Promise<void>;
169
+ /**
170
+ * 从配置文件加载服务配置
171
+ */
172
+ loadServiceConfig(configPath: string): Promise<ServiceConfig>;
173
+ /**
174
+ * 生成组件初始化选项
175
+ */
176
+ generateComponentOptions(componentName: string, configEntry: ComponentConfigEntry): GeneratedComponentOptions;
177
+ /**
178
+ * 注册组件并用配置初始化
179
+ */
180
+ registerComponentWithConfig(component: Component, configEntry: ComponentConfigEntry): Promise<void>;
181
+ /**
182
+ * 从配置文件初始化整个环境
183
+ */
184
+ initFromConfig(configPath: string): Promise<void>;
185
+ }
@@ -0,0 +1,184 @@
1
+ /**
2
+ * @fileoverview Task #4418: React 循环异常中断 → 给飞书发 reply
3
+ *
4
+ * ## 问题(用户飞书 p2p 2026-10-21)
5
+ *
6
+ * ```
7
+ * RetryError [AI_RetryError]: Failed after 4 attempts.
8
+ * Last error: Upstream request failed: Endpoint is unavailable.
9
+ * statusCode: 429 / isRetryable: true
10
+ * ```
11
+ *
12
+ * 上游 429 不是 roy-agent 的 bug;但**异常中断后飞书侧完全静默**是。
13
+ * 用户原话:「这个失败导致的 react 中断,也需要找到对应的 triggerEvent
14
+ * 构建 response 让飞书方知道(送一个 reply 哈)」。
15
+ *
16
+ * ## 为什么必须由框架直接发(不能靠 prompt 引导 agent)
17
+ *
18
+ * 正常路径的 reply 是 **LLM 自己调 lark-cli**(prompt 由
19
+ * `buildNotifyHandlePrompt` / event-source-handlers 生成,告诉 agent
20
+ * 用 `recommendedAction.replyTo` 回消息)。
21
+ *
22
+ * 但异常路径的根本问题是:**LLM 调用本身失败了**,React 循环从未拿到
23
+ * 一个可用的 assistant turn,自然也不可能再调工具发消息。所以框架必须
24
+ * 自己 spawn `lark-cli`,这是与正常路径的本质区别。
25
+ *
26
+ * ## 断点(为什么曾经没 reply)
27
+ *
28
+ * 1. `agent-component.ts:2096` 捕获异常 → `result.error` + `result.originalError`
29
+ * 2. `environment.ts:430` 非 ContextError → `throw new Error(result.error)`
30
+ * ⚠️ 类型在这里丢掉,下游只能拿到字符串
31
+ * 3. `context-handler.service.ts:224` 直接 rethrow
32
+ * 4. `query-executor.ts:287` 只处理 ContextError,其余 rethrow
33
+ * 5. `interactive.ts:1301` / `event-handler.ts:620` 的 catch **只 console.error**
34
+ * → 静默丢失
35
+ *
36
+ * ## 现在的接线(四处,去重保证不重复)
37
+ *
38
+ * 1. `QueryExecutor.execute` 的 catch —— 唯一执行入口,覆盖
39
+ * interactive / run / run --es 三种模式,带完整 `agentContext.envEvent`
40
+ * 2. `EventHandler.processQueue` 的 catch —— 兜住「还没走到 QueryExecutor
41
+ * 就失败」的路径(session 解析 / 事件分发),并作为 TUI 层吞异常时的
42
+ * 最后一道防线
43
+ * 3. REPL `executeInternal` 的 catch —— 兜住 agentContext 组装 / plugin
44
+ * 加载 / REPL 包装层(这些异常会被 REPL 自己吞掉,到不了 EventHandler)
45
+ * 4. `LarkCliInstance.handleEvent` 的 catch —— event-source 自身的解析 /
46
+ * 落库 / 分发失败
47
+ *
48
+ * 四处都调用本模块,意味着**任何 React 中断都至少有一个出口到飞书**。
49
+ *
50
+ * ## 设计原则
51
+ *
52
+ * - **规则表驱动(rule base)**:错误分类 + 是否通知 + 用户文案收敛成
53
+ * `FAILURE_RULES` 有序表;表尾 `UNKNOWN_RULE` 是 `notify: true` 的
54
+ * catch-all —— 结构上保证**任何未分类错误也不会沉默**。只有
55
+ * `ask_user`(正常交互)显式 `notify: false`
56
+ * - **best-effort**:任何异常(spawn 失败 / lark-cli 非 0 / 库挂了)
57
+ * 都不得向上抛,绝不污染原始错误传播链
58
+ * - **有硬超时**:兜底 reply 在 5s 内一定 settle(超时 kill 子进程)。
59
+ * 否则 lark-cli 卡住会把 `QueryExecutor` 的 rethrow 拖死 → 事件队列堵死
60
+ * - **复用现有机制**:spawn 参数形态与 `LarkCliNotificationChannel` /
61
+ * `event-source-handlers.sendLarkMessage` 保持一致(`--profile` 前置、
62
+ * messageId → `+messages-reply`、chatId → `+messages-send`)
63
+ * - **去重**:同一 triggerEvent(messageId)只回一次;chat-only 通道走
64
+ * 5 分钟窗口,**不会**把整个群永久封锁;发送失败回滚去重标记
65
+ * - **无 channel 不崩但也不静默**:本地 REPL / `act` 没有飞书上下文 → debug;
66
+ * 有 triggerEvent 却拿不到 replyChannel = 衔接 bug → warn
67
+ * - **用户可读**:给用户看中文原因,技术细节单独放 `technical` 字段(截断)
68
+ */
69
+ /**
70
+ * 失败分类。
71
+ *
72
+ * 顺序即优先级:越具体的越先匹配。
73
+ */
74
+ export type ReactFailureKind = "ask_user" | "upstream_retry" | "timeout" | "upstream_aborted" | "aborted" | "context_overflow" | "unknown";
75
+ export interface ReactFailureInfo {
76
+ kind: ReactFailureKind;
77
+ /** 命中的规则 id(可观测性 / 测试锚点) */
78
+ ruleId: string;
79
+ /** 一行标题(中文,给用户看) */
80
+ title: string;
81
+ /** 可读原因(中文,不含 stack trace) */
82
+ reason: string;
83
+ /** 是否值得用户稍后重试 */
84
+ retryable: boolean;
85
+ /**
86
+ * 是否应该把这条失败反馈到飞书。
87
+ *
88
+ * 只有 `ask_user`(正常交互)为 false —— **所有真正的失败/中断都必须通知**,
89
+ * 这是 #4418 的硬契约:不允许静默。
90
+ */
91
+ notify: boolean;
92
+ /** 技术细节(截断,供定位;不直接展示给用户) */
93
+ technical?: string;
94
+ }
95
+ /** replyChannel 的最小形态(同时兼容 EnvReplyChannel / event-source ReplyChannel) */
96
+ export interface FailureReplyChannelLike {
97
+ type?: string;
98
+ chatId?: string;
99
+ messageId?: string;
100
+ profile?: string;
101
+ appId?: string;
102
+ userId?: string;
103
+ }
104
+ export interface NotifyReactFailureOptions {
105
+ /** 触发 React 中断的错误(任意类型,内部会做类型安全处理) */
106
+ error: unknown;
107
+ /**
108
+ * 触发本次执行的 EnvEvent。
109
+ *
110
+ * 从中提取 replyChannel(优先 `metadata.replyChannel`,
111
+ * 兼容 `payload.replyChannel`),这就是用户说的「找到对应的 triggerEvent」。
112
+ */
113
+ envEvent?: unknown;
114
+ /** 显式 replyChannel(优先级最高,便于调用方直接指定) */
115
+ replyChannel?: FailureReplyChannelLike;
116
+ /** 原始 query 摘要(会被截断后放进 reply,便于用户对上号) */
117
+ query?: string;
118
+ /** 会话 ID(仅用于日志 / 去重兜底) */
119
+ sessionId?: string;
120
+ /** 去重 key 覆盖(默认从 messageId/chatId 推导) */
121
+ dedupKey?: string;
122
+ /**
123
+ * 兜底 reply 的硬超时(ms)。
124
+ *
125
+ * 生产默认 5s;仅测试注入短值用。超时后 kill 子进程并按失败返回,
126
+ * 保证 `QueryExecutor` 的 catch 不会被 lark-cli 挂住。
127
+ */
128
+ replyTimeoutMs?: number;
129
+ }
130
+ export interface NotifyReactFailureResult {
131
+ /** 是否成功投递到飞书 */
132
+ sent: boolean;
133
+ /** 失败分类(即使没发送也会返回,调用方可记日志) */
134
+ kind: ReactFailureKind;
135
+ /** 结构化失败信息 */
136
+ info: ReactFailureInfo;
137
+ /** 跳过原因(sent=false 时有值) */
138
+ skipped?: "no_channel" | "duplicate" | "not_a_failure";
139
+ /** 投递错误(sent=false 且确实尝试过时有值) */
140
+ error?: string;
141
+ }
142
+ /** 当前生效的规则 id 列表(供可观测性 / 文档 / 测试锚定顺序)。 */
143
+ export declare function getFailureRuleIds(): string[];
144
+ /**
145
+ * 把任意错误分类成结构化、用户可读的失败信息。
146
+ *
147
+ * ⚠️ 关键:必须能处理**类型已丢失**的场景 —— 真实调用链上
148
+ * `environment.ts` 会把 RetryError 字符串化成普通 `Error`,所以只能靠
149
+ * message 文本特征识别,不能依赖 `instanceof RetryError`。
150
+ */
151
+ export declare function classifyReactFailure(error: unknown): ReactFailureInfo;
152
+ /**
153
+ * 生成发给用户的 reply 正文(Markdown)。
154
+ *
155
+ * 契约:
156
+ * - 不含裸 stack trace(` at `)
157
+ * - 含「怎么办」的可操作建议
158
+ * - 总长度远小于飞书 4096 单条上限
159
+ */
160
+ export declare function buildFailureReplyMarkdown(info: ReactFailureInfo, opts?: {
161
+ query?: string;
162
+ sessionId?: string;
163
+ }): string;
164
+ /** 测试用:清空去重状态 */
165
+ export declare function __resetFailureReplyDedupForTest(): void;
166
+ /**
167
+ * React 循环异常中断时,尽最大努力给飞书发一条失败说明。
168
+ *
169
+ * **绝不抛异常** —— 所有错误都被吞掉并记日志,保证不污染原始错误传播。
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * // interactive.ts executeInternal 的 catch 分支
174
+ * } catch (error) {
175
+ * await notifyReactFailure({
176
+ * error,
177
+ * envEvent: this.currentAgentContext?.envEvent,
178
+ * sessionId: agentContext?.eventSessionId,
179
+ * });
180
+ * // …原有错误处理继续
181
+ * }
182
+ * ```
183
+ */
184
+ export declare function notifyReactFailure(options: NotifyReactFailureOptions): Promise<NotifyReactFailureResult>;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * @fileoverview 统一错误类型体系
3
+ *
4
+ * 提供 AgentError, ToolError, LLMError, ComponentError, ContextError 等错误类型
5
+ * 每个错误包含 code(错误码)和 details(额外信息)
6
+ */
7
+ /**
8
+ * 错误码枚举
9
+ */
10
+ export declare const ErrorCodes: {
11
+ readonly AGENT_NOT_FOUND: "AGENT_001";
12
+ readonly AGENT_RUN_FAILED: "AGENT_002";
13
+ readonly AGENT_TIMEOUT: "AGENT_003";
14
+ readonly AGENT_CONFIG_INVALID: "AGENT_004";
15
+ readonly TOOL_NOT_FOUND: "TOOL_001";
16
+ readonly TOOL_DISABLED: "TOOL_002";
17
+ readonly TOOL_EXECUTION_FAILED: "TOOL_003";
18
+ readonly TOOL_VALIDATION_FAILED: "TOOL_004";
19
+ readonly LLM_PROVIDER_NOT_FOUND: "LLM_001";
20
+ readonly LLM_INVOCATION_FAILED: "LLM_002";
21
+ readonly LLM_TIMEOUT: "LLM_003";
22
+ readonly LLM_CONFIG_INVALID: "LLM_004";
23
+ readonly COMPONENT_NOT_FOUND: "COMP_001";
24
+ readonly COMPONENT_INIT_FAILED: "COMP_002";
25
+ readonly COMPONENT_NOT_RUNNING: "COMP_003";
26
+ readonly CONFIG_NOT_FOUND: "CONFIG_001";
27
+ readonly CONFIG_INVALID: "CONFIG_002";
28
+ readonly CONFIG_SOURCE_ERROR: "CONFIG_003";
29
+ readonly CONTEXT_THRESHOLD_EXCEEDED: "CTX_001";
30
+ readonly CONTEXT_COMPACTION_FAILED: "CTX_002";
31
+ readonly MCP_INIT_FAILED: "MCP_001";
32
+ readonly MCP_SERVER_ERROR: "MCP_002";
33
+ readonly MCP_TOOL_ERROR: "MCP_003";
34
+ };
35
+ export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
36
+ /**
37
+ * RoyError 基类
38
+ */
39
+ export declare class RoyError extends Error {
40
+ readonly code: ErrorCode;
41
+ readonly details?: unknown | undefined;
42
+ constructor(message: string, code: ErrorCode, details?: unknown | undefined);
43
+ }
44
+ /**
45
+ * Agent 相关错误
46
+ */
47
+ export declare class AgentError extends RoyError {
48
+ constructor(message: string, code?: ErrorCode, details?: unknown);
49
+ }
50
+ /**
51
+ * Tool 相关错误
52
+ */
53
+ export declare class ToolError extends RoyError {
54
+ readonly toolName?: string | undefined;
55
+ constructor(message: string, code?: ErrorCode, toolName?: string | undefined, details?: unknown);
56
+ }
57
+ /**
58
+ * LLM 相关错误
59
+ */
60
+ export declare class LLMError extends RoyError {
61
+ readonly provider?: string | undefined;
62
+ constructor(message: string, code?: ErrorCode, provider?: string | undefined, details?: unknown);
63
+ }
64
+ /**
65
+ * Component 相关错误
66
+ */
67
+ export declare class ComponentError extends RoyError {
68
+ readonly componentName?: string | undefined;
69
+ constructor(message: string, code?: ErrorCode, componentName?: string | undefined, details?: unknown);
70
+ }
71
+ /**
72
+ * LLM Output 结构(用于 ContextError 携带 assistant message)
73
+ *
74
+ * 这是简化版本,仅包含保存到 session 所需的最少字段。
75
+ * 与 llm/types.ts 中的 LLMOutput 不同,那个版本包含完整的 LLM 调用结果。
76
+ */
77
+ export interface LLMOutput {
78
+ content?: string;
79
+ reasoning?: string;
80
+ toolCalls?: Array<{
81
+ id: string;
82
+ function?: {
83
+ name: string;
84
+ arguments: string;
85
+ };
86
+ name?: string;
87
+ arguments?: unknown;
88
+ }>;
89
+ usage?: {
90
+ promptTokens: number;
91
+ completionTokens: number;
92
+ totalTokens: number;
93
+ };
94
+ }
95
+ /**
96
+ * Context 相关错误
97
+ */
98
+ export declare class ContextError extends RoyError {
99
+ readonly sessionId?: string | undefined;
100
+ readonly usage?: {
101
+ promptTokens: number;
102
+ completionTokens: number;
103
+ totalTokens: number;
104
+ } | undefined;
105
+ readonly contextWindow?: number | undefined;
106
+ readonly llmOutput?: LLMOutput | undefined;
107
+ constructor(message: string, code?: ErrorCode, sessionId?: string | undefined, usage?: {
108
+ promptTokens: number;
109
+ completionTokens: number;
110
+ totalTokens: number;
111
+ } | undefined, contextWindow?: number | undefined, llmOutput?: LLMOutput | undefined, details?: unknown);
112
+ }
113
+ /**
114
+ * 检查是否是 RoyError
115
+ */
116
+ export declare function isRoyError(error: unknown): error is RoyError;
117
+ /**
118
+ * 获取错误码
119
+ */
120
+ export declare function getErrorCode(error: unknown): ErrorCode | undefined;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @fileoverview BountyCli EventSource Handler
3
+ *
4
+ * Built-in handler for `bounty-cli` event source. Spawns the
5
+ * `@ai-setting/bounty-cli` Go binary (a `lark-cli`-style Mattermost
6
+ * event-source CLI) and forwards its NDJSON event stream into the
7
+ * roy-agent event bus.
8
+ *
9
+ * ## Wire format
10
+ *
11
+ * `bounty event consume --channel <name>` emits one JSON object per line
12
+ * (NDJSON). Each object is a bounty Event struct:
13
+ *
14
+ * {
15
+ * "event_id": "...",
16
+ * "event_type": "mm.message.posted",
17
+ * "source_time": "...",
18
+ * "app_id": "...",
19
+ * "tenant_key": "...",
20
+ * "payload": { ... MM post data ... },
21
+ * "timestamp": "2026-..."
22
+ * }
23
+ *
24
+ * Status messages are written to stderr (not stdout).
25
+ *
26
+ * ## Configuration
27
+ *
28
+ * EventSourceConfig requires:
29
+ * - `channel` (top-level): Mattermost channel name (positional arg)
30
+ * - `profile` (optional): bounty profile name (multi-account scenario, #1637)
31
+ *
32
+ * Optional:
33
+ * - `command` (top-level): override the default command line (advanced)
34
+ *
35
+ * ## Reply channel
36
+ *
37
+ * The reply channel uses `type: "bounty-cli"` so that
38
+ * `BountyCliNotificationChannel` (packages/core/src/env/plugin) picks up
39
+ * notification sends and routes them to `bounty event publish`.
40
+ */
41
+ import type { EventSourceHandler } from "./types";
42
+ export declare const bountyCliHandler: EventSourceHandler;