@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,138 @@
1
+ /**
2
+ * @fileoverview WorkflowComponent
3
+ *
4
+ * Workflow 组件入口,提供工作流管理和执行能力。
5
+ *
6
+ * 功能:
7
+ * - 工作流 CRUD 操作(通过 WorkflowService)
8
+ * - 工作流执行(通过 WorkflowEngine)
9
+ * - Decorator 节点注册
10
+ *
11
+ * Note: After session-based refactoring, workflow runs are managed via SessionComponent.
12
+ * The Session.metadata stores workflow run state (status, input, agentSessions).
13
+ * Node execution messages are stored in Session.messages with workflow.node.* roles.
14
+ */
15
+ import 'reflect-metadata';
16
+ import { BaseComponent, type ComponentConfig } from '../component';
17
+ import type { WorkflowDefinition, RunOptions, RunResult } from './types';
18
+ import { WorkflowService } from './service';
19
+ import type { ToolComponent } from '../tool/tool-component';
20
+ import type { LogTraceComponent } from '../log-trace/log-trace-component';
21
+ import type { Environment } from '../interface';
22
+ import type { AgentRunner } from './nodes/agent-node';
23
+ export { EventBus, DAGManager, Scheduler, Executor, WorkflowEngine, } from './engine';
24
+ export type { NodeExecutionContext, RunOptions, RunResult, RunStatus, NodeStatus, DAGAnalysis, SchedulerOptions, SchedulerState, ExecutorOptions, WorkflowEngineConfig, NodeContext, NodeFactory, } from './engine';
25
+ export type { NodeDefinition, RetryConfig, TemplateResolver, } from './types';
26
+ export type { WorkflowDefinition, } from './types/workflow';
27
+ export { WorkflowService, WorkflowServiceRegistry, } from './service';
28
+ export type { WorkflowOptions, NodeAsOptions, EdgeOptions, WorkflowMetadata, NodeMetadata, EdgeMetadata, ValidationResult, ConvertedWorkflowDefinition, ConvertedNodeDefinition, } from './types/decorators-types';
29
+ export { Workflow, NodeAs, Edge, WorkflowEdges, getWorkflowMetadata, getNodeMetadatas, getEdgeMetadatas, DecoratorNode, } from './decorators';
30
+ export type { DecoratorNodeConfig, } from './decorators/decorator-node';
31
+ export { WorkflowConverter, } from './extractor/workflow-converter';
32
+ export { createWorkflowFromClass } from './utils/create-workflow';
33
+ export { registerDecoratorNodeType } from './utils/node-registry-helper';
34
+ export interface WorkflowComponentConfig extends ComponentConfig {
35
+ /** 自动注册 decorator 节点类型 */
36
+ autoRegisterDecorators?: boolean;
37
+ }
38
+ export interface WorkflowComponentOptions {
39
+ /** Tool 组件(可选) */
40
+ toolComponent?: ToolComponent;
41
+ /** Log Trace 组件(可选) */
42
+ logTraceComponent?: LogTraceComponent;
43
+ /** Environment(包含 AgentComponent 等) */
44
+ env?: Environment;
45
+ /** Skill registry(可选) */
46
+ skillRegistry?: {
47
+ getSkill(name: string): any;
48
+ hasSkill(name: string): boolean;
49
+ };
50
+ /** Agent runner(可选,用于 agent 节点) */
51
+ agentRunner?: AgentRunner;
52
+ }
53
+ export declare class WorkflowComponent extends BaseComponent {
54
+ readonly name = "workflow";
55
+ readonly version = "1.0.0";
56
+ workflowService: WorkflowService | null;
57
+ sessionComponent: any;
58
+ private nodeRegistry;
59
+ private decoratorsRegistered;
60
+ /**
61
+ * 获取 WorkflowService 实例
62
+ */
63
+ getService(): WorkflowService | null;
64
+ private toolComponent?;
65
+ private logTraceComponent?;
66
+ private _workflowEnv?;
67
+ private skillRegistry?;
68
+ private agentRunner?;
69
+ /**
70
+ * 初始化 WorkflowComponent
71
+ */
72
+ init(options: any): Promise<void>;
73
+ /**
74
+ * 注册 decorator 节点类型
75
+ */
76
+ private registerDecorators;
77
+ /**
78
+ * Note: After session-based refactoring, runRepository is no longer needed.
79
+ * Workflow runs are managed via SessionComponent.
80
+ */
81
+ createService(options: {
82
+ workflowRepository: any;
83
+ toolComponent?: ToolComponent;
84
+ env?: Environment;
85
+ skillRegistry?: {
86
+ getSkill(name: string): any;
87
+ hasSkill(name: string): boolean;
88
+ };
89
+ sessionComponent?: any;
90
+ tagRepository?: any;
91
+ }): WorkflowService;
92
+ /**
93
+ * 运行工作流定义
94
+ */
95
+ runWorkflow(definition: WorkflowDefinition, input?: Record<string, any>, options?: RunOptions): Promise<RunResult>;
96
+ /**
97
+ * 停止组件并清理资源
98
+ *
99
+ * 遵循 Component 接口契约,通过 onStop 钩子实现
100
+ */
101
+ protected onStop(): Promise<void>;
102
+ /**
103
+ * 启动组件 - 初始化持久化的 SQLite WorkflowService
104
+ */
105
+ start(): Promise<void>;
106
+ /**
107
+ * 注册 ask_user 工具到 ToolComponent
108
+ *
109
+ * 这样 Workflow 中的 AgentNode 执行时,Agent 能够找到并调用 ask_user 工具。
110
+ * ask_user 工具会抛出 AskUserError,触发 workflow pause。
111
+ */
112
+ private registerAskUserTool;
113
+ /**
114
+ * 注册 workflow tools 到 ToolComponent
115
+ *
116
+ * 注册 5 个 workflow 工具:workflow_get, workflow_list, workflow_run,
117
+ * workflow_run_status, workflow_run_stop。
118
+ *
119
+ * 注意:这些工具不自动加入 defaultTools,只通过 ToolComponent 的注册表可见。
120
+ * 只有通过 allowedTools 明确引用的 agent(如 workflow-runner)才能使用。
121
+ */
122
+ private registerWorkflowTools;
123
+ /**
124
+ * 初始化 SQLite 持久化的 WorkflowService
125
+ *
126
+ * Note: After session-based refactoring, runRepository is no longer needed.
127
+ * Workflow runs are managed via SessionComponent.
128
+ */
129
+ private initSqliteService;
130
+ /**
131
+ * 创建内存中的 WorkflowService(用于快速运行或降级)
132
+ */
133
+ private createInMemoryService;
134
+ /**
135
+ * 停止组件
136
+ */
137
+ stop(): Promise<void>;
138
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @roy-agent/core - Core SDK
3
+ */
4
+ export { generateId, generateDescendingId } from "./utils/id";
5
+ export { ATTACH_FILE_MAX_BYTES, sniffMimeType, isMediaType, parseImageInput, } from "./utils/media";
6
+ export { type Environment, BaseEnvironment, } from "./env";
7
+ export type { EnvironmentConfig, BaseEnvironmentConfig, EnvEvent, EnvEventMetadata, EnvEventHandler, Action, Context, } from "./env";
8
+ export { type Component, type ComponentConfig, type ComponentSchema, type ComponentPaths, type ComponentStatus, type ComponentConfigChangeEvent, type ComponentWatchCallback, BaseComponent, } from "./env/component";
9
+ export { globalHookManager, type HookPhase, type HookMeta, type BaseHookContext, // 通用 HookContext
10
+ type BaseHook, // 通用 Hook
11
+ type BaseHookFn, // 通用 HookFn
12
+ type HookManagerOptions, type HookAction, type HookResult, type HookActionType, createHook, createPriorityHook, HookManager, } from "./env/hook";
13
+ export { type XDGPaths, type XDGDirType, XDG_PATHS, getXDGPaths, getXDGPath, } from "./env/paths";
14
+ export { type ConfigSource, type ConfigSourceType, type ConfigChangeEvent, type ComponentRegistration, ConfigComponent, } from "./config/config-component";
15
+ export { LLMComponent, type LLMComponentOptions, type ContentPart, type LLMMessage, type LLMOutput, type UsageInfo, type ToolCall, type LLMConfig, type LLMProvider, type ProviderConfig, type ProviderType, type LLMInvokeRequest, type LLMInvokeResult, type StreamEvent, invoke, invokeNonStream, parseModelString, createInvokeConfig, type InvokeConfig, type InvokeOptions, type LLMToolContext, type ConvertedUsageInfo, LLMConfigSchema, ProviderConfigSchema, ProviderCapabilitiesSchema, ModelLimitsSchema, LLMDefaultConfigSchema, isOpencodeProvider, isOpencodeEndpoint, buildOpencodeHeaders, } from "./env/llm";
16
+ export { ToolComponent, type ToolComponentConfig, type Tool, type ToolInfo, type ToolResult, type ToolResultMetadata, type ToolMetadata, type SandboxConfig, type ValidationResult, ToolRegistry, ToolValidator, getAllBuiltInTools, getBuiltInTool, bashTool, globTool, readFileTool, writeFileTool, editFileTool, grepTool, understandImageTool, setUnderstandImageLLMProvider, getUnderstandImageLLMProvider, resetUnderstandImageLLMProvider, type UnderstandImageLLMProvider, } from "./env/tool";
17
+ export type { ToolContext } from "./env/tool/types";
18
+ export type { ToolHookContext } from "./env/tool/tool-component";
19
+ export { AgentComponent, type AgentComponentConfig, type AgentContext, AgentComponentConfigSchema, type Plugin, type HookPoint, type HookContext, } from "./env/agent";
20
+ export { AgentRegistry, type AgentDefinition, type AgentType, type AgentConfig, type ExportOptions, } from "./env/agent/agent-registry";
21
+ export { LogTraceComponent, type LogTraceConfig, type LogTraceComponentOptions, LogTraceConfigSchema, Traced, TracedAs, TracedLightweight, wrapFunction, type TracedOptions, createLogger, getLogDir, setLogDirOverride, setQuietMode, isQuietMode, getLogLevels, getLogLevel, setLoggerConfigComponent, SQLiteSpanStorage, type SpanContext, type SpanAttributes, type Span, type TraceInfo, type SpanStorage, type LogLevel, type LoggerConfig, type ILogger, SpanKind, SpanStatus, OTelTracerProvider, getTracerProvider, resetTracerProvider, type OTelTracer, type OTelSpan, type SpanOptions, propagation, } from "./env/log-trace";
22
+ export { DebugComponent, TraceFormatter, TreeFormatter, ReplFormatter, type TraceDataSource, type TraceParserOptions, } from "./env/debug";
23
+ export type { TraceEntry, TraceTreeNode, ParserOptions, LogDiscoveryOptions, TraceIdInfo, TraceSummary, TraceAction, LogLevel as DebugLogLevel, FormatOptions, } from "./env/debug";
24
+ export { PromptComponent, type PromptComponentOptions, } from "./env/prompt/prompt-component";
25
+ export { PromptStore } from "./env/prompt/prompt-store";
26
+ export { closeDatabase } from "./env/workflow/storage/sqlite";
27
+ export type { PromptConfig, PromptPath, PromptEntry, PromptSource, PromptHook, RenderHookContext, PromptHookMap, } from "./env/prompt/types";
28
+ export { SessionComponent, MemorySessionStore, } from "./env/session";
29
+ export type { Session, SessionMessage, SessionConfig, CreateSessionOptions, UpdateSessionOptions, ListSessionsOptions, AddMessageOptions, SessionCheckpoint, CompactOptions, CompactResult, CompactPreview, GetContextOptions, GetContextResult, CheckpointType, SearchMessagesOptions, MessageMatch, SearchResult, } from "./env/session/types";
30
+ export { cascadeStopSessionTree, type CascadeStopOptions, type CascadeStopResult, } from "./env/session-tree-stopper";
31
+ export { createMemoryAgentTools, } from "./env/memory/tools/memory-agent-tools";
32
+ export type { SearchSessionsParams, GetSessionParams, WriteMemoryParams, } from "./env/memory/tools/memory-agent-tools";
33
+ export { getBuiltInPrompt, getBuiltInPromptNames, } from "./env/prompt/prompts-index";
34
+ export { TaskComponent, SQLiteTaskStore, getDefaultTaskDbPath, } from "./env/task";
35
+ export type { Task, TaskOperation, TaskStatus, TaskPriority, ActionType, CreateTaskOptions, UpdateTaskOptions, ListTasksOptions, CreateOperationOptions, ListOperationsOptions, TaskConfig, } from "./env/task/types";
36
+ export { TaskTagPlugin, createAutoTaskPlugin, type AutoTaskPluginConfig, } from "./env/task/plugins";
37
+ export { TaskHookPoints, type TaskHookPoint, } from "./env/task/hooks";
38
+ export { SkillComponent, } from "./env/skill";
39
+ export type { SkillEntry, SkillListItem, SkillConfig, SkillPath, SkillSource, SkillToolParams, } from "./env/skill/types";
40
+ export { McpComponent, } from "./env/mcp";
41
+ export type { McpComponentConfig, McpComponentOptions, McpPath, McpServerConfig, McpServerLocalConfig, McpServerRemoteConfig, McpServerStatus, DiscoveredMcpServer, } from "./env/mcp";
42
+ export { MemoryComponent, } from "./env/memory";
43
+ export type { MemoryConfig, MemoryPath, MemorySource, RecordMemoryParams, RecallMemoryParams, RecordMemoryMode, RecordMemoryResult, } from "./env/memory/types";
44
+ export type { MemoryComponentOptions } from "./env/memory";
45
+ export { MemoryPlugin, createMemoryPlugin, } from "./env/memory/plugin";
46
+ export type { MemoryPluginConfig, } from "./env/memory/plugin/types";
47
+ export { CommandsComponent, } from "./env/commands";
48
+ export type { CommandsComponentConfig, CommandIndex, ScanResult, ExecutionResult, DiscoverOptions, AddCommandOptions, RemoveCommandOptions, CommandSource, CommandsComponentOptions, } from "./env/commands";
49
+ export * from "./env/event-source";
50
+ export { ErrorCodes, RoyError, AgentError, ToolError, LLMError, ComponentError, ContextError, isRoyError, getErrorCode, } from "./env/errors";
51
+ export type { ErrorCode } from "./env/errors";
52
+ export { WorkflowComponent, type WorkflowComponentConfig, } from "./env/workflow/workflow-component";
53
+ export { AskUserError, type NodeInterruptEvent, type WorkflowAskUserEvent, } from "./env/workflow/types/workflow-hil";
54
+ export { Workflow, WorkflowEdges, NodeAs, Edge, } from "./env/workflow/decorators";
55
+ export type { WorkflowOptions, NodeAsOptions, EdgeMetadata, } from "./env/workflow/types/decorators-types";
56
+ export { createWorkflowFromClass, } from "./env/workflow/utils/create-workflow";
57
+ export { registerDecoratorNodeType, } from "./env/workflow/utils/node-registry-helper";
58
+ export { PluginComponent, type PluginComponentOptions, } from "./env/plugin/plugin-component";
59
+ export { BasePlugin, type PluginEnv, type HookDefinition, type HookHandler, type AgentInstanceConfig, type ToolDefinition, type HookResult as PluginHookResult, type HookContext as PluginHookContext, } from "./env/plugin/types";
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ import {
47
47
  } from "./shared/@ai-setting/roy-agent-core-j5c3chtn.js";
48
48
  import {
49
49
  DebugComponent
50
- } from "./shared/@ai-setting/roy-agent-core-0cfaqnz9.js";
50
+ } from "./shared/@ai-setting/roy-agent-core-k25gv86p.js";
51
51
  import {
52
52
  ReplFormatter,
53
53
  TraceFormatter,
@@ -66,7 +66,7 @@ import {
66
66
  BaseEnvironment,
67
67
  generateDescendingId,
68
68
  generateId
69
- } from "./shared/@ai-setting/roy-agent-core-rcfewbzr.js";
69
+ } from "./shared/@ai-setting/roy-agent-core-4sx6sdb2.js";
70
70
  import {
71
71
  TaskComponent
72
72
  } from "./shared/@ai-setting/roy-agent-core-39xejr39.js";
@@ -92,7 +92,7 @@ import {
92
92
  larkCliHandler,
93
93
  resolveBountyIMSystemPrompt,
94
94
  timerHandler
95
- } from "./shared/@ai-setting/roy-agent-core-ezgsem94.js";
95
+ } from "./shared/@ai-setting/roy-agent-core-ph5qbqcx.js";
96
96
  import {
97
97
  BUILT_IN_EVENT_SOURCE_TYPES,
98
98
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -109,7 +109,7 @@ import {
109
109
  import {
110
110
  TaskTagPlugin,
111
111
  createAutoTaskPlugin
112
- } from "./shared/@ai-setting/roy-agent-core-pkpkctvf.js";
112
+ } from "./shared/@ai-setting/roy-agent-core-hch2geta.js";
113
113
  import {
114
114
  EventStoreImpl,
115
115
  getSharedEventStore,
@@ -127,7 +127,7 @@ import"./shared/@ai-setting/roy-agent-core-brwzs8wf.js";
127
127
  import"./shared/@ai-setting/roy-agent-core-j8e92gj8.js";
128
128
  import {
129
129
  WorkflowComponent
130
- } from "./shared/@ai-setting/roy-agent-core-s214vmmd.js";
130
+ } from "./shared/@ai-setting/roy-agent-core-4vpk40ss.js";
131
131
  import {
132
132
  init_node_registry_helper,
133
133
  registerDecoratorNodeType
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAutoTaskPlugin
3
- } from "./roy-agent-core-pkpkctvf.js";
3
+ } from "./roy-agent-core-hch2geta.js";
4
4
  import {
5
5
  ContextError,
6
6
  ErrorCodes
@@ -8,7 +8,7 @@ import {
8
8
  extractPerTaskChatId,
9
9
  extractPerTaskChatName,
10
10
  mergeChatOwnership
11
- } from "./roy-agent-core-pkpkctvf.js";
11
+ } from "./roy-agent-core-hch2geta.js";
12
12
  import {
13
13
  getSharedEventStore
14
14
  } from "./roy-agent-core-yhsssn86.js";
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @fileoverview 跨平台进程树杀进程工具
3
+ *
4
+ * 用于 delegate_task 超时/stop 时彻底清理子 agent 派生的进程树(包括孙进程),
5
+ * 防止端口、文件句柄、孤儿进程泄漏。
6
+ *
7
+ * 平台策略:
8
+ * - POSIX (Linux / macOS):要求子进程以 `detached: true` + 子进程是进程组 leader,
9
+ * 通过 `process.kill(-pid, signal)` 杀进程组。如果子进程没有 detached(PID 不是负数),退化为直接杀 PID。
10
+ * - Windows:永远用 `taskkill /pid <pid> /f /t` 杀进程树(不依赖 detached)。
11
+ *
12
+ * 验证 + 重试机制:
13
+ * - 每次 kill 后等待 retryDelayMs,用 `process.kill(pid, 0)`(POSIX)或 `tasklist`(Windows)验证进程是否存活
14
+ * - 如果仍存活,重试(最多 retry 次,默认 3 次)
15
+ * - 全部重试完仍存活:记录 error 日志(由外层 process-registry 负责)
16
+ *
17
+ * 多平台代码路径在测试中可通过 `_setPlatformForTests()` 切换。
18
+ */
19
+ import type { ChildProcess, SpawnOptions, SpawnSyncOptions, SpawnSyncReturns } from "child_process";
20
+ type SpawnFn = (cmd: string, args: string[], opts: SpawnOptions) => ChildProcess;
21
+ export declare function _setSpawnForTests(s: SpawnFn | undefined): void;
22
+ type SpawnSyncFn = (cmd: string, args: string[], opts: SpawnSyncOptions) => SpawnSyncReturns<Buffer | string>;
23
+ export declare function _setSpawnSyncForTests(s: SpawnSyncFn | undefined): void;
24
+ export interface KillProcessTreeOptions {
25
+ /** 信号类型(仅 POSIX)。默认 SIGKILL */
26
+ signal?: NodeJS.Signals;
27
+ /** 已废弃字段,保留以兼容早期 API。SIGKILL 默认立即生效 */
28
+ gracefulTimeoutMs?: number;
29
+ /** 最大重试次数(默认 3) */
30
+ retry?: number;
31
+ /** 重试间隔(ms,默认 500) */
32
+ retryDelayMs?: number;
33
+ }
34
+ /** 杀进程结果 */
35
+ export interface KillProcessTreeResult {
36
+ /** 杀掉的进程 ID */
37
+ pid: number;
38
+ /** 使用的平台策略 */
39
+ platform: NodeJS.Platform;
40
+ /** 实际发出的信号(POSIX)或命令(Windows) */
41
+ signal: string;
42
+ /** 是否成功(不一定准确,例如 POSIX 中 ESRCH 被忽略视为软成功) */
43
+ success: boolean;
44
+ /** 实际尝试次数 */
45
+ attempts: number;
46
+ /** 最后一次尝试后进程是否仍存活(true=没杀干净) */
47
+ stillAlive: boolean;
48
+ }
49
+ export declare function _setPlatformForTests(p: NodeJS.Platform): void;
50
+ export declare function _resetPlatformForTests(): void;
51
+ /**
52
+ * 杀进程树(跨平台)。不会 throw;ESRCH / EPERM 等"进程已不存在"类错误静默忽略。
53
+ *
54
+ * 验证 + 重试:
55
+ * - 每次 kill 后等待 retryDelayMs(默认 500ms)
56
+ * - 用 `process.kill(pid, 0)`(POSIX)或 `tasklist`(Windows)验证进程是否存活
57
+ * - 如果仍存活,重试(最多 retry 次,默认 3 次)
58
+ * - 全部重试完仍存活:通过 stillAlive: true 返回,由外层记录 error 日志
59
+ *
60
+ * POSIX 默认使用 SIGKILL 杀进程组,要求子进程 spawn 时带 `detached: true`。
61
+ * Windows 调用 `taskkill /f /t` 杀进程树(不依赖 detached)。
62
+ *
63
+ * @param pid 进程 PID(必须为正整数)
64
+ * @param options 可选项
65
+ */
66
+ export declare function killProcessTree(pid: number, options?: KillProcessTreeOptions): Promise<KillProcessTreeResult>;
67
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @fileoverview ID Generation Utilities
3
+ */
4
+ /**
5
+ * Generate a unique ID with optional prefix
6
+ */
7
+ export declare function generateId(prefix?: string): string;
8
+ /**
9
+ * Generate a descending ID (useful for creating IDs that sort newest first)
10
+ */
11
+ export declare function generateDescendingId(prefix?: string): string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview Loose JSON extraction helpers
3
+ *
4
+ * LLM 经常把「本该结构化」的结果当纯文本吐出来,格式五花八门:
5
+ * 1. 纯 JSON
6
+ * 2. Markdown ```json ... ``` 代码块
7
+ * 3. 夹在解释文字中的第一个 `{...}`
8
+ *
9
+ * 这些 helper 从任意文本里尽力抠出 JSON 对象,返回 null 表示没找到。
10
+ *
11
+ * 原实现内联在 `env/workflow/plugins/workflow-json-output-plugin.ts`,
12
+ * 2026-10-16 抽到 utils 以便 session 压缩的 checkpoint 降级路径复用
13
+ * (避免 session → workflow/plugins 的反向耦合)。
14
+ */
15
+ /**
16
+ * Helper: try to parse a string as a JSON object.
17
+ * Returns the parsed object (excluding arrays/primitives), or null.
18
+ */
19
+ export declare function tryParseJsonString(s: string): Record<string, unknown> | null;
20
+ /**
21
+ * Extract a JSON object from arbitrary LLM text.
22
+ *
23
+ * Tries (in order):
24
+ * 1. Whole text is JSON
25
+ * 2. Markdown ```json ... ``` code block
26
+ * 3. First {...} substring
27
+ *
28
+ * Returns null if no valid JSON object is found.
29
+ */
30
+ export declare function tryParseJsonFromText(text: string): Record<string, unknown> | null;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @fileoverview Media utils — magic-byte mime sniffing, media-type gate, image-input parsing
3
+ *
4
+ * 借鉴 opencode 设计:
5
+ * - ATTACH_FILE_MAX_BYTES = 10 MiB(防止 base64 内存爆炸)
6
+ * - sniffAttachmentMime 优先 magic bytes,其次扩展名(mime-types),最后 application/octet-stream
7
+ * - parseImageInput 支持本地路径 / http(s) URL / data:base64 URL
8
+ *
9
+ * 设计取舍:
10
+ * - 不引入 mime-types npm 依赖,自己用常见扩展名映射兜底(轻量级)
11
+ * - isMediaType 用 startsWith gate:image/audio/video/application/pdf
12
+ * - image/svg+xml 不算 media(LLM 多用位图,SVG 太特殊)
13
+ */
14
+ import type { ContentPart } from "../env/llm/types";
15
+ /**
16
+ * 附件最大字节数(10 MiB)。
17
+ * 借鉴 opencode 的 ATTACH_FILE_MAX_BYTES = 10 * 1024 * 1024(run.ts:59)。
18
+ * 超过即拒收,避免 base64 编码后内存爆炸。
19
+ */
20
+ export declare const ATTACH_FILE_MAX_BYTES: number;
21
+ /**
22
+ * 通过 magic bytes 检测 mime type。
23
+ * 顺序:PNG → JPEG → GIF → WebP → PDF → BMP
24
+ * 都不匹配则 fallback 到扩展名推断,都没则 application/octet-stream
25
+ *
26
+ * @param buffer 文件内容(Buffer 或 Uint8Array)
27
+ * @param fallbackName 可选的文件名,用于扩展名 fallback(如 "image.png")
28
+ * @returns mime type 字符串
29
+ */
30
+ export declare function sniffMimeType(buffer: Uint8Array, fallbackName?: string): string;
31
+ /**
32
+ * 判断 mime 是否为 LLM 支持的多模态媒体(image / audio / video / pdf)。
33
+ *
34
+ * image/svg+xml 故意排除:SVG 是矢量图,LLM 多用 vision 处理位图;
35
+ * 如未来需要可加入白名单。
36
+ */
37
+ export declare function isMediaType(mime: string): boolean;
38
+ /**
39
+ * 解析图像输入并归一化为 ContentPart。
40
+ *
41
+ * 三种输入形式:
42
+ * 1. 本地路径:读取文件、sniff mime、超 10 MiB 抛错、返回 { type: 'image', image: Buffer }
43
+ * 2. http(s) URL:原样返回 { type: 'image', image: url },由下游 AI SDK 处理
44
+ * 3. data:base64 URL:原样返回 { type: 'image', image: dataUrl }
45
+ *
46
+ * @param input 图像输入字符串
47
+ * @returns ContentPart(必为 image 类型)
48
+ */
49
+ export declare function parseImageInput(input: string): Promise<ContentPart>;
50
+ /**
51
+ * Multi-source image MIME detection used by adapter-pi-ai.ts toPiMessages().
52
+ *
53
+ * Hardcoding `mimeType: "image/*"` upstream made every vision provider
54
+ * return HTTP 400 ("media type \"image/*\" not supported"). This helper
55
+ * sniffs from 4 sources, in priority order:
56
+ *
57
+ * 1. Explicit `mediaType` if it's already specific (not "image/*")
58
+ * 2. `data:` URL prefix (e.g. `data:image/jpeg;base64,...`)
59
+ * 3. HTTP(S) URL suffix (.jpg/.jpeg/.png/.gif/.webp/.bmp)
60
+ * 4. Buffer magic bytes (JPEG / PNG / GIF / WebP / BMP)
61
+ *
62
+ * If NONE of these succeed, throws an explicit error instead of silently
63
+ * emitting the `"image/*"` wildcard.
64
+ *
65
+ * @param image Uint8Array buffer / data: URL / http(s) URL
66
+ * @param explicitMediaType optional caller-provided MIME (e.g. from LLMMessage)
67
+ * @returns detected MIME string (e.g. "image/jpeg")
68
+ * @throws Error with clear message when MIME cannot be determined
69
+ */
70
+ export declare function sniffImageMime(image: Uint8Array | string, explicitMediaType?: string): string;
@@ -0,0 +1,99 @@
1
+ /**
2
+ * TempFileManager — singleton manager for tool output truncation temp files.
3
+ *
4
+ * When tool output is truncated, the full content is saved to a temp file so the
5
+ * LLM can use `read_file` to retrieve specific portions.
6
+ *
7
+ * Features:
8
+ * - Cross-platform: uses `os.tmpdir()` + `path.join()` (Linux/macOS/Windows)
9
+ * - Process lifecycle: cleans up on exit/SIGINT/SIGTERM
10
+ * - Stale file sweep: cleans up files older than 24h at startup
11
+ * - Concurrent safe: uses `crypto.randomUUID()` for unique filenames
12
+ * - Large file safety: warns for content > 10MB (does not block)
13
+ * - Singleton: shared instance via `getInstance()`
14
+ *
15
+ * File naming: `roy-agent-truncation-{pid}-{uuid}-{prefix}.txt`
16
+ * Examples:
17
+ * Linux: /tmp/roy-agent-truncation-12345-abc123-def456-bash.txt
18
+ * macOS: /var/folders/xx/yy/T/roy-agent-truncation-12345-abc123-def456-bash.txt
19
+ * Windows: C:\Users\xxx\AppData\Local\Temp\roy-agent-truncation-12345-abc123-def456-bash.txt
20
+ */
21
+ export declare class TempFileManager {
22
+ private static _instance;
23
+ private readonly _files;
24
+ private _hooksRegistered;
25
+ private static readonly FILE_PREFIX;
26
+ private static readonly FILE_EXT;
27
+ private static readonly LARGE_FILE_THRESHOLD;
28
+ private static readonly STALE_FILE_AGE_MS;
29
+ /**
30
+ * Private constructor — use `getInstance()` instead.
31
+ */
32
+ private constructor();
33
+ /**
34
+ * Get the singleton instance.
35
+ *
36
+ * Note: This intentionally holds a strong reference for the process lifetime
37
+ * because process exit hooks reference the instance.
38
+ */
39
+ static getInstance(): TempFileManager;
40
+ /**
41
+ * Reset the singleton instance (for testing only).
42
+ *
43
+ * @internal
44
+ */
45
+ static _resetForTesting(): void;
46
+ /**
47
+ * Write content to a temporary file and track it for later cleanup.
48
+ *
49
+ * @param content - The text content to write to the file
50
+ * @param prefix - A short string to identify the source (e.g., tool name)
51
+ * @returns Absolute path to the created temp file
52
+ *
53
+ * @example
54
+ * const path = await TempFileManager.getInstance().writeTempFile(
55
+ * "large output...",
56
+ * "bash"
57
+ * );
58
+ * // → "/tmp/roy-agent-truncation-12345-abc123-bash.txt"
59
+ */
60
+ writeTempFile(content: string, prefix?: string): Promise<string>;
61
+ /**
62
+ * Remove all temp files created by this instance.
63
+ *
64
+ * Missing files are silently skipped (no error thrown).
65
+ */
66
+ cleanupAll(): Promise<void>;
67
+ /**
68
+ * Get the count of currently tracked temp files.
69
+ *
70
+ * Useful for tests and diagnostics.
71
+ */
72
+ getActiveFileCount(): number;
73
+ /**
74
+ * Sweep stale temp files from previous sessions (older than 24h).
75
+ *
76
+ * Called automatically on first instantiation. Can also be called manually
77
+ * for housekeeping (e.g., on a timer).
78
+ *
79
+ * @param maxAgeMs - Maximum age in milliseconds (default: 24 hours)
80
+ * @returns Number of files deleted
81
+ */
82
+ sweepStaleFiles(maxAgeMs?: number): Promise<number>;
83
+ /**
84
+ * Ensure process exit hooks are registered (idempotent).
85
+ *
86
+ * Hooks clean up all tracked temp files when the process exits.
87
+ */
88
+ ensureHooksRegistered(): void;
89
+ /**
90
+ * Sanitize the prefix string to be safe for filenames.
91
+ *
92
+ * Removes characters that are problematic on any platform:
93
+ * - Path separators (/, \)
94
+ * - Reserved characters (<, >, :, ", |, ?, *)
95
+ * - Control characters
96
+ * - Spaces (replaced with -)
97
+ */
98
+ private sanitizePrefix;
99
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.7.52",
3
+ "version": "1.7.53",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,9 @@
28
28
  "README.md"
29
29
  ],
30
30
  "scripts": {
31
- "build": "bunup",
31
+ "build": "bunup && bun run build:dts",
32
+ "build:dts": "tsc -p tsconfig.dts.json --noCheck",
33
+ "typecheck:dts": "tsc -p tsconfig.dts.json --noEmit",
32
34
  "build:main": "bunup -- --entry src/index.ts",
33
35
  "clean": "rm -rf dist",
34
36
  "typecheck": "npx tsc --noEmit --skipLibCheck --project tsconfig.json",