@ai-setting/roy-agent-core 1.7.51 → 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 (337) 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 +4 -4
  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 +6 -6
  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 +2 -2
  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/index.js +2 -2
  263. package/dist/env/workflow/plugins/lark-cli-workflow-notify-plugin.d.ts +107 -0
  264. package/dist/env/workflow/plugins/workflow-json-output-plugin.d.ts +166 -0
  265. package/dist/env/workflow/runtime/runtime-cancellation-scope.d.ts +121 -0
  266. package/dist/env/workflow/service/index.d.ts +9 -0
  267. package/dist/env/workflow/service/registry.d.ts +37 -0
  268. package/dist/env/workflow/service/workflow-service.d.ts +422 -0
  269. package/dist/env/workflow/storage/index.d.ts +11 -0
  270. package/dist/env/workflow/storage/mock-repositories.d.ts +106 -0
  271. package/dist/env/workflow/storage/safe-json.d.ts +62 -0
  272. package/dist/env/workflow/storage/sqlite.d.ts +57 -0
  273. package/dist/env/workflow/storage/tag-repo.d.ts +65 -0
  274. package/dist/env/workflow/storage/workflow-repo.d.ts +161 -0
  275. package/dist/env/workflow/tools/ask-user-tool.d.ts +35 -0
  276. package/dist/env/workflow/tools/index.d.ts +16 -0
  277. package/dist/env/workflow/tools/run-workflow.d.ts +130 -0
  278. package/dist/env/workflow/tools/submit-json-output-tool.d.ts +38 -0
  279. package/dist/env/workflow/tools/workflow-add-tool.d.ts +47 -0
  280. package/dist/env/workflow/tools/workflow-get-tool.d.ts +29 -0
  281. package/dist/env/workflow/tools/workflow-list-tool.d.ts +55 -0
  282. package/dist/env/workflow/tools/workflow-run-status-tool.d.ts +26 -0
  283. package/dist/env/workflow/tools/workflow-run-stop-tool.d.ts +29 -0
  284. package/dist/env/workflow/tools/workflow-search-tool.d.ts +33 -0
  285. package/dist/env/workflow/tools/workflow-tag-list-tool.d.ts +59 -0
  286. package/dist/env/workflow/tools/workflow-validate-tool.d.ts +60 -0
  287. package/dist/env/workflow/types/context.d.ts +17 -0
  288. package/dist/env/workflow/types/decorators-types.d.ts +182 -0
  289. package/dist/env/workflow/types/edge.d.ts +33 -0
  290. package/dist/env/workflow/types/event.d.ts +869 -0
  291. package/dist/env/workflow/types/index.d.ts +16 -0
  292. package/dist/env/workflow/types/run.d.ts +235 -0
  293. package/dist/env/workflow/types/workflow-error.d.ts +79 -0
  294. package/dist/env/workflow/types/workflow-hil.d.ts +57 -0
  295. package/dist/env/workflow/types/workflow-message.d.ts +193 -0
  296. package/dist/env/workflow/types/workflow-session.d.ts +17 -0
  297. package/dist/env/workflow/types/workflow.d.ts +654 -0
  298. package/dist/env/workflow/types_compat.d.ts +10 -0
  299. package/dist/env/workflow/utils/agent-session-metadata.d.ts +35 -0
  300. package/dist/env/workflow/utils/build-agent-node-output.d.ts +11 -0
  301. package/dist/env/workflow/utils/create-workflow.d.ts +35 -0
  302. package/dist/env/workflow/utils/dependency-prescan.d.ts +67 -0
  303. package/dist/env/workflow/utils/execution-state.d.ts +46 -0
  304. package/dist/env/workflow/utils/extract-agent-json-output.d.ts +6 -0
  305. package/dist/env/workflow/utils/index.d.ts +14 -0
  306. package/dist/env/workflow/utils/json-schema-to-zod.d.ts +23 -0
  307. package/dist/env/workflow/utils/node-id-utils.d.ts +20 -0
  308. package/dist/env/workflow/utils/node-output-contracts.d.ts +137 -0
  309. package/dist/env/workflow/utils/node-registry-helper.d.ts +36 -0
  310. package/dist/env/workflow/utils/output-schema-hint.d.ts +7 -0
  311. package/dist/env/workflow/utils/parse-agent-output-config.d.ts +9 -0
  312. package/dist/env/workflow/utils/recovery-validator.d.ts +30 -0
  313. package/dist/env/workflow/utils/sensitive-redact.d.ts +37 -0
  314. package/dist/env/workflow/utils/session-parser.d.ts +23 -0
  315. package/dist/env/workflow/utils/session-recovery.d.ts +122 -0
  316. package/dist/env/workflow/utils/template-contract-validator.d.ts +87 -0
  317. package/dist/env/workflow/utils/template-resolver.d.ts +285 -0
  318. package/dist/env/workflow/utils/validate-workflow-definition.d.ts +57 -0
  319. package/dist/env/workflow/utils/validation-rules.d.ts +103 -0
  320. package/dist/env/workflow/utils/workflow-message-metadata.d.ts +20 -0
  321. package/dist/env/workflow/utils/workflow-sanitize.d.ts +51 -0
  322. package/dist/env/workflow/workflow-component.d.ts +138 -0
  323. package/dist/index.d.ts +59 -0
  324. package/dist/index.js +7 -7
  325. package/dist/shared/@ai-setting/{roy-agent-core-9faekt5n.js → roy-agent-core-4sx6sdb2.js} +1 -1
  326. package/dist/shared/@ai-setting/{roy-agent-core-wxsgay02.js → roy-agent-core-brwzs8wf.js} +1 -1
  327. package/dist/shared/@ai-setting/{roy-agent-core-kyasfzeh.js → roy-agent-core-hch2geta.js} +45 -14
  328. package/dist/shared/@ai-setting/{roy-agent-core-zd077w51.js → roy-agent-core-j8e92gj8.js} +43 -1
  329. package/dist/shared/@ai-setting/{roy-agent-core-wwytg8rv.js → roy-agent-core-ph5qbqcx.js} +566 -78
  330. package/dist/util/process/process-tree-killer.d.ts +67 -0
  331. package/dist/utils/id.d.ts +11 -0
  332. package/dist/utils/loose-json.d.ts +30 -0
  333. package/dist/utils/media.d.ts +70 -0
  334. package/dist/utils/temp-file-manager/index.d.ts +99 -0
  335. package/package.json +4 -2
  336. /package/dist/shared/@ai-setting/{roy-agent-core-s214vmmd.js → roy-agent-core-4vpk40ss.js} +0 -0
  337. /package/dist/shared/@ai-setting/{roy-agent-core-0cfaqnz9.js → roy-agent-core-k25gv86p.js} +0 -0
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @fileoverview Static **template-reference contract** validation for workflow
3
+ * definitions (Task #4298).
4
+ *
5
+ * ## The problem
6
+ *
7
+ * `workflow_validate` (and `workflow_add`) historically only ran DAG-structure
8
+ * checks (duplicate IDs / missing deps / cycles / empty IDs). It could not
9
+ * notice that a node's prompt referenced a field its upstream node can never
10
+ * produce — which is exactly how `wheels-validate-v1` v1.3.0 shipped a
11
+ * workflow whose `report-results` agent received an *empty string* for
12
+ * `{{nodes.run-validation-tests.result}}` (a **tool** node has no `result`)
13
+ * and then reported `completed` anyway.
14
+ *
15
+ * ## What this module does
16
+ *
17
+ * Walks every node's `config`, extracts *pure* `{{ ... }}` template paths, and
18
+ * checks each one against:
19
+ *
20
+ * 1. **R1** — the referenced source node actually exists → error
21
+ * 2. **R2** — `.result` is an **agent-only** idiom; using it on a data
22
+ * node (tool / python_call / skill / condition / merge / askUser)
23
+ * is the canonical bug above → error
24
+ * 3. **R3** — a first-level field that is not in the source node's
25
+ * *closed* contract field set (may still resolve if the node's
26
+ * `output` happens to be an object carrying that key) → warning
27
+ * 4. **R4** — a deep path (`.output.<x>`) into a `tool` node whose
28
+ * output is usually a plain string → info
29
+ * 5. **R5** — a field that contradicts an agent's **declared JSON
30
+ * schema** (`config.output.schema.properties`) → warning
31
+ * 6. **R6** — the source node is not upstream of the consumer
32
+ * (loops / forward refs legitimately consume prior-round output) → info
33
+ *
34
+ * Severity policy: only R1/R2 are `error` (blocking). R3/R5 are `warning`
35
+ * (advisory). R4/R6 are `info` (hint). This keeps the existing corpus clean —
36
+ * a scan of all 75 registered workflows yields **2 errors, both in
37
+ * `wheels-validate-v1`**, i.e. precisely the bug we set out to catch.
38
+ *
39
+ * ## Parsing rules (deliberately conservative)
40
+ *
41
+ * A `{{ ... }}` body is only considered a node reference when it is a *pure dot
42
+ * path* (`^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_-]+|\\[-?\\d+\\])*$`). This
43
+ * excludes, in one stroke:
44
+ * - scoped refs: `{{input.x}}` / `{{inputs.x}}` / `{{config.x}}` / `{{env.X}}`
45
+ * - docker Go-templates: `{{index .RepoDigests 0}}`
46
+ * - handlebars-ish conditionals: `{{#if input.x}}` / `{{/if}}`
47
+ * - documentation placeholders: `{{nodes.<source-id>.<field>}}`
48
+ * - shell parameter expansions and any prose containing a space
49
+ *
50
+ * It also explicitly ignores the `{{X | default ''}}` filter suffix used by a
51
+ * few workflows (the path is taken up to the first space or `|`).
52
+ */
53
+ export type TemplateContractSeverity = "error" | "warning" | "info";
54
+ export type TemplateContractRule = "R1-node-not-found" | "R2-result-on-non-agent" | "R3-unknown-field-on-closed" | "R4-deep-path-into-tool" | "R5-agent-schema-field" | "R6-not-upstream";
55
+ export interface TemplateContractFinding {
56
+ /** `error` blocks `workflow_add`; `warning` / `info` are advisory. */
57
+ severity: TemplateContractSeverity;
58
+ rule: TemplateContractRule;
59
+ /** The node whose config contains the reference. */
60
+ nodeId: string;
61
+ /** The verbatim template, e.g. `{{nodes.run-validation-tests.result}}`. */
62
+ template: string;
63
+ /** The referenced source node id. */
64
+ sourceNodeId?: string;
65
+ /** The referenced source node type (when it exists). */
66
+ sourceNodeType?: string;
67
+ /** Human-readable, actionable explanation. */
68
+ message: string;
69
+ /** Suggested replacement template (when we can compute one). */
70
+ suggestion?: string;
71
+ }
72
+ /**
73
+ * Validate every template reference in a workflow definition against the
74
+ * source node's output contract.
75
+ *
76
+ * Never throws — malformed input yields `[]`.
77
+ *
78
+ * @param definition - Workflow definition (needs a `nodes` array)
79
+ * @returns Findings, in node-declaration order
80
+ */
81
+ export declare function validateTemplateContracts(definition: unknown): TemplateContractFinding[];
82
+ /** Convenience: only the blocking findings. */
83
+ export declare function getTemplateContractErrors(definition: unknown): TemplateContractFinding[];
84
+ /** Convenience: only the advisory findings. */
85
+ export declare function getTemplateContractWarnings(definition: unknown): TemplateContractFinding[];
86
+ /** Render findings as `string[]` for the `{ valid, errors }` callers. */
87
+ export declare function formatTemplateContractFindings(findings: TemplateContractFinding[]): string[];
@@ -0,0 +1,285 @@
1
+ /**
2
+ * @fileoverview Template Resolver - Unified template resolution for workflow nodes
3
+ *
4
+ * This module provides a unified template resolution system for workflow nodes.
5
+ * Templates are in the format {{path}} where path can reference:
6
+ *
7
+ * - Input variables: {{input.key}} or {{input.key.nested}}
8
+ * - Node outputs: {{nodeId}} or {{nodeId.output}} or {{nodeId.output.path}}
9
+ * - With prefix: {{nodes.nodeId}} or {{nodes.nodeId.output.path}}
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const resolver = new TemplateResolver({
14
+ * input: { query: 'weather' },
15
+ * previousOutputs: new Map([
16
+ * ['fetch', { data: { temp: 25, condition: 'sunny' } }]
17
+ * ])
18
+ * });
19
+ *
20
+ * resolver.resolve('Weather in {{input.query}}: {{nodes.fetch.data.condition}}');
21
+ * // => 'Weather in weather: sunny'
22
+ * ```
23
+ */
24
+ import type { NodeExecutionContext } from '../types';
25
+ /**
26
+ * Template resolution options
27
+ */
28
+ export interface TemplateResolverOptions {
29
+ /** Input passed to the workflow/node */
30
+ input?: Record<string, unknown>;
31
+ /** Map of previous node outputs */
32
+ previousOutputs?: Map<string, unknown>;
33
+ }
34
+ /**
35
+ * Result of template resolution
36
+ */
37
+ export interface ResolvedValue {
38
+ /** Whether the value was resolved */
39
+ resolved: boolean;
40
+ /** The resolved value */
41
+ value: unknown;
42
+ }
43
+ /**
44
+ * Result of resolveAndValidate operation
45
+ */
46
+ export interface ResolveResult {
47
+ /** The resolved value (with templates replaced) */
48
+ resolved: unknown;
49
+ /** List of template strings that could not be resolved */
50
+ unresolved: string[];
51
+ }
52
+ /**
53
+ * TemplateResolver
54
+ *
55
+ * Resolves template strings that reference workflow inputs and node outputs.
56
+ */
57
+ export declare class TemplateResolver {
58
+ private input;
59
+ private previousOutputs;
60
+ constructor(options?: TemplateResolverOptions);
61
+ /**
62
+ * Create a TemplateResolver from NodeExecutionContext
63
+ *
64
+ * @param context - Node execution context
65
+ * @returns TemplateResolver instance
66
+ */
67
+ static fromContext(context: NodeExecutionContext): TemplateResolver;
68
+ /**
69
+ * Resolve template references in an input value.
70
+ *
71
+ * Handles:
72
+ * - Primitive values (returned as-is)
73
+ * - Objects (recursively resolved)
74
+ * - Arrays (recursively resolved)
75
+ * - Strings (template resolution)
76
+ *
77
+ * Key behavior for template strings:
78
+ * - If the string is a pure template reference (e.g., "{{nodes.fetch}}"),
79
+ * the resolved value is returned as-is (preserving objects/arrays)
80
+ * - If the string contains text + templates (e.g., "Hello {{name}}"),
81
+ * returns a string with interpolated values
82
+ *
83
+ * @param input - Input value that may contain template strings
84
+ * @returns Input with template references resolved
85
+ */
86
+ resolveValue(input: unknown): unknown;
87
+ /**
88
+ * Check if a string is a pure template reference (starts with {{ and ends with }})
89
+ * @param str - String to check
90
+ * @returns The template content if pure, null otherwise
91
+ */
92
+ private extractPureTemplate;
93
+ /**
94
+ * Resolve a pure template reference and return the value as-is.
95
+ * @param templateContent - Content between {{ and }}
96
+ * @returns The resolved value (may be object, array, or primitive)
97
+ */
98
+ private resolvePureTemplate;
99
+ /**
100
+ * Resolve a path-style template reference and return the value.
101
+ *
102
+ * Task #2283 — added so the engine can read any previous-progress
103
+ * signal (e.g. `{{nodes.tdd-implement.commits[-1]}}`) inside
104
+ * loop_guard checks without having to re-parse the template.
105
+ *
106
+ * Supports:
107
+ * - `{{input.foo}}` / `{{input.foo.bar}}`
108
+ * - `{{nodes.X}}` / `{{nodes.X.Y}}` / `{{nodes.X.Y.Z}}`
109
+ * - Array indexing: `{{nodes.X.list[0]}}`, `{{nodes.X.list[-1]}}`
110
+ * (-1 means "last element"; -2 means "second to last", etc.)
111
+ * - `.length` accessor on arrays
112
+ *
113
+ * The `{{` and `}}` wrappers are optional — a bare path string
114
+ * (`nodes.X.Y`) is also accepted.
115
+ *
116
+ * Returns `undefined` if any segment is missing, an array index is
117
+ * out of range, or the input is empty.
118
+ */
119
+ resolvePath(path: string): unknown;
120
+ /**
121
+ * Tokenize a path string into segments, respecting bracket notation
122
+ * `foo[0]`, `foo[-1]`, and the `.length` accessor.
123
+ *
124
+ * Examples:
125
+ * "nodes.x.y" -> ["nodes", "x", "y"]
126
+ * "nodes.x.list[0]" -> ["nodes", "x", "list", 0]
127
+ * "nodes.x.list[-1]" -> ["nodes", "x", "list", -1]
128
+ * "nodes.x.l.length" -> ["nodes", "x", "l", "length"]
129
+ */
130
+ private tokenizePath;
131
+ /**
132
+ * Navigate `tokens` (mix of string keys and integer indices) into
133
+ * `root`, returning the value at the end of the path or undefined.
134
+ *
135
+ * For negative indices, the engine resolves them as offset from the
136
+ * end of the array (-1 = last, -2 = second to last, ...).
137
+ */
138
+ private navigateTokens;
139
+ /**
140
+ * Resolve template content (the part inside {{ }}) and return the value.
141
+ * @param templateContent - The path to resolve (e.g., "input.key", "nodes.fetch.data")
142
+ * @returns The resolved value
143
+ */
144
+ private resolveTemplateContent;
145
+ /**
146
+ * Auto-unwrap AgentNode output format `{ result, metadata, ... }` when
147
+ * the caller asked for the bare node (no further path). Preserves the
148
+ * pre-tokenizer behavior where `{{nodeId}}` returns the result field
149
+ * rather than the whole wrapper object.
150
+ *
151
+ * Only unwraps when the value LOOKS like an AgentNode result wrapper
152
+ * (has `result` and not `nodes`); this guards against false positives
153
+ * on plain objects that happen to have a `result` key.
154
+ */
155
+ private unwrapAgentNodeResult;
156
+ /**
157
+ * Resolve a single template string.
158
+ *
159
+ * Supports patterns:
160
+ * - {{input.key}} - Input variable
161
+ * - {{nodeId}} - Node's entire output
162
+ * - {{nodeId.output}} - Node's output property
163
+ * - {{nodeId.output.path}} - Node's nested output property
164
+ * - {{nodes.nodeId}} - Node's entire output (with prefix)
165
+ * - {{nodes.nodeId.output.path}} - Node's nested property (with prefix)
166
+ *
167
+ * @param template - Template string to resolve
168
+ * @returns Resolved string
169
+ */
170
+ resolveString(template: string): string;
171
+ /**
172
+ * Resolve a node output path.
173
+ *
174
+ * @param path - Path like "nodeId" or "nodeId.output" or "nodeId.output.path"
175
+ * @returns The resolved value or undefined
176
+ */
177
+ private resolveNodePath;
178
+ /**
179
+ * Get a nested value from an object using dot notation.
180
+ *
181
+ * @param obj - Object to traverse
182
+ * @param path - Dot-separated path
183
+ * @returns The nested value or undefined
184
+ */
185
+ private getNestedValue;
186
+ /**
187
+ * Convert a value to string for template substitution.
188
+ *
189
+ * Task #2912: when value is undefined, return empty string instead of
190
+ * the original template. Returning the original template caused downstream
191
+ * bash guards (e.g. `[ -n "$SID_COOKIE_RAW" ]`) to evaluate as truthy
192
+ * on the template literal like `{{input.sidCookie}}`, which misrouted
193
+ * workflows into fallback paths when an input field was simply absent.
194
+ * null still returns the sentinel string "null" for backward compatibility.
195
+ */
196
+ private stringify;
197
+ /**
198
+ * Check if a string contains template references.
199
+ *
200
+ * @param str - String to check
201
+ * @returns True if the string contains template references
202
+ */
203
+ containsTemplates(str: string): boolean;
204
+ /**
205
+ * Extract all template references from a string.
206
+ *
207
+ * @param str - String to extract from
208
+ * @returns Array of template references
209
+ */
210
+ extractTemplates(str: string): string[];
211
+ /**
212
+ * Resolve and validate input, tracking unresolved templates.
213
+ *
214
+ * This method resolves all template references in the input and returns
215
+ * both the resolved value and a list of templates that could not be resolved.
216
+ *
217
+ * @param input - Input value that may contain template strings
218
+ * @returns Object containing resolved value and list of unresolved templates
219
+ */
220
+ resolveAndValidate(input: unknown): ResolveResult;
221
+ /**
222
+ * Internal method to resolve values while tracking unresolved templates.
223
+ */
224
+ private resolveValueWithTracking;
225
+ /**
226
+ * Resolve string templates while tracking unresolved ones.
227
+ */
228
+ private resolveStringWithTracking;
229
+ /**
230
+ * Resolve templates strictly, throwing on unresolved templates.
231
+ *
232
+ * This is useful when you want to ensure all templates are resolved
233
+ * before proceeding, and treat any unresolved templates as an error.
234
+ *
235
+ * Uses factory methods to create meaningful error messages with nodeId and reason.
236
+ *
237
+ * @param input - Input value that may contain template strings
238
+ * @param nodeId - Optional node ID for better error context
239
+ * @returns The resolved value
240
+ * @throws TemplateUnresolvedError if any templates could not be resolved
241
+ */
242
+ resolveStrict(input: unknown, nodeId?: string): unknown;
243
+ /**
244
+ * Evaluate a condition expression and return boolean result
245
+ * Supports operators: ==, !=, >, <, >=, <=, &&, ||, !
246
+ *
247
+ * @param condition - Condition expression with template references
248
+ * @returns Boolean result of the condition
249
+ * @throws Error if condition cannot be evaluated
250
+ */
251
+ evaluateCondition(condition: string): boolean;
252
+ /**
253
+ * Parse and evaluate a condition string
254
+ * Handles operator precedence: ! > && > ||
255
+ */
256
+ private parseCondition;
257
+ /**
258
+ * Split a string by an operator, respecting quoted strings
259
+ */
260
+ private splitByOperator;
261
+ /**
262
+ * Evaluate a value (handles strings, numbers, booleans)
263
+ */
264
+ private evaluateValue;
265
+ /**
266
+ * Compare two values with the given operator
267
+ */
268
+ private compare;
269
+ }
270
+ /**
271
+ * Resolve template references in input using context.
272
+ *
273
+ * @param input - Input value with potential templates
274
+ * @param context - Node execution context
275
+ * @returns Resolved input
276
+ */
277
+ export declare function resolveTemplates(input: unknown, context: NodeExecutionContext): unknown;
278
+ /**
279
+ * Resolve a template string using context.
280
+ *
281
+ * @param template - Template string
282
+ * @param context - Node execution context
283
+ * @returns Resolved string
284
+ */
285
+ export declare function resolveTemplateString(template: string, context: NodeExecutionContext): string;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @fileoverview Shared validateWorkflowDefinition helper.
3
+ *
4
+ * Single entry point for validating a workflow definition:
5
+ *
6
+ * Layer 1 — DAG structure (delegated to DAGManager.validate()):
7
+ * duplicate node IDs, missing dependencies, cycles, empty node IDs.
8
+ *
9
+ * Layer 2 — Template-reference **contracts** (Task #4298, see
10
+ * `template-contract-validator.ts`): does a `{{nodes.X.<field>}}`
11
+ * reference actually match the output shape of node `X`? This is what
12
+ * catches the `wheels-validate-v1` class of bug where an agent prompt
13
+ * read `.result` off a **tool** node (which has no such field) and the
14
+ * engine silently substituted an empty string.
15
+ *
16
+ * Wraps everything in a defensive try/catch so callers (workflow_add tool,
17
+ * `workflow add` CLI, workflow_validate tool, TaskTagPlugin.extractWorkflow)
18
+ * always get a consistent `{ valid, errors, warnings, infos }` shape — even
19
+ * when the input is garbage.
20
+ *
21
+ * Backward compatibility: the original `{ valid, errors }` shape is preserved;
22
+ * `warnings` / `infos` are additive. Only `error`-severity findings affect
23
+ * `valid`.
24
+ */
25
+ import { type TemplateContractFinding } from "./template-contract-validator";
26
+ export interface ValidateWorkflowResult {
27
+ valid: boolean;
28
+ /** Blocking problems. Non-empty ⟺ `valid === false`. */
29
+ errors: string[];
30
+ /**
31
+ * Advisory problems (Task #4298). These do NOT make the definition invalid,
32
+ * but the workflow-creator loop is expected to address them.
33
+ */
34
+ warnings?: string[];
35
+ /** Informational hints (e.g. references to non-upstream nodes). */
36
+ infos?: string[];
37
+ /** Structured findings, for callers that want machine-readable detail. */
38
+ findings?: TemplateContractFinding[];
39
+ }
40
+ export interface ValidateWorkflowOptions {
41
+ /**
42
+ * Skip the Layer-2 template-contract checks. Defaults to `false`.
43
+ *
44
+ * Provided for callers that only care about structural validity (e.g. a
45
+ * pre-flight DAG sanity check while a definition is still being authored
46
+ * incrementally).
47
+ */
48
+ skipTemplateContracts?: boolean;
49
+ }
50
+ /**
51
+ * Validate a workflow definition (structure + template contracts).
52
+ *
53
+ * @param definition - The workflow definition object (must have a `nodes` array).
54
+ * @param options - Optional behaviour switches.
55
+ * @returns `{ valid, errors, warnings, infos, findings }` — never throws.
56
+ */
57
+ export declare function validateWorkflowDefinition(definition: unknown, options?: ValidateWorkflowOptions): ValidateWorkflowResult;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Validation Rules for Workflow Recovery
3
+ *
4
+ * Defines types for validation errors, results, and recovery plans.
5
+ */
6
+ /**
7
+ * Validation error types for workflow recovery
8
+ */
9
+ export declare enum ValidationErrorType {
10
+ /** Variable referenced by node input is missing */
11
+ MISSING_VARIABLE = "MISSING_VARIABLE",
12
+ /** Parallel branch is incomplete */
13
+ INCOMPLETE_PARALLEL = "INCOMPLETE_PARALLEL",
14
+ /** Condition branch cannot be determined */
15
+ AMBIGUOUS_BRANCH = "AMBIGUOUS_BRANCH",
16
+ /** Loop state is lost */
17
+ LOOP_STATE_LOST = "LOOP_STATE_LOST",
18
+ /** Nested workflow state is invalid */
19
+ NESTED_WORKFLOW_INVALID = "NESTED_WORKFLOW_INVALID",
20
+ /** Node execution state is inconsistent */
21
+ NODE_STATE_INCONSISTENT = "NODE_STATE_INCONSISTENT",
22
+ /** Critical dependency is missing */
23
+ MISSING_DEPENDENCY = "MISSING_DEPENDENCY"
24
+ }
25
+ /**
26
+ * Suggested actions for recovery
27
+ */
28
+ export declare enum SuggestedAction {
29
+ /** Re-run the workflow from the beginning */
30
+ RE_RUN = "RE_RUN",
31
+ /** Confirm with user before proceeding */
32
+ CONFIRM = "CONFIRM",
33
+ /** Skip the problematic node */
34
+ SKIP = "SKIP",
35
+ /** Provide the missing value */
36
+ PROVIDE_VALUE = "PROVIDE_VALUE",
37
+ /** Ignore the warning and proceed */
38
+ IGNORE = "IGNORE"
39
+ }
40
+ /**
41
+ * Validation error detail
42
+ */
43
+ export interface ValidationError {
44
+ /** Error type */
45
+ type: ValidationErrorType;
46
+ /** Node ID where error occurred */
47
+ nodeId: string;
48
+ /** Human-readable error description */
49
+ description: string;
50
+ /** Suggested action to resolve */
51
+ suggestedAction: SuggestedAction;
52
+ /** Additional context information */
53
+ context?: Record<string, unknown>;
54
+ }
55
+ /**
56
+ * Result of validation
57
+ */
58
+ export interface ValidationResult {
59
+ /** Whether the workflow can be safely resumed */
60
+ isValid: boolean;
61
+ /** List of validation errors */
62
+ errors: ValidationError[];
63
+ /** List of warnings (non-critical issues) */
64
+ warnings: string[];
65
+ }
66
+ /**
67
+ * Recovery plan for resuming a workflow
68
+ */
69
+ export interface RecoveryPlan {
70
+ /** Whether the workflow can be resumed */
71
+ canResume: boolean;
72
+ /** Node ID where execution should resume */
73
+ resumePoint: string;
74
+ /** List of completed node IDs */
75
+ completedNodes: string[];
76
+ /** List of pending node IDs */
77
+ pendingNodes: string[];
78
+ /** List of node IDs that will be skipped */
79
+ skippedNodes: string[];
80
+ /** Validation errors encountered */
81
+ validationErrors: ValidationError[];
82
+ /** Human-readable summary */
83
+ summary: string;
84
+ }
85
+ /**
86
+ * Execution state of a workflow
87
+ */
88
+ export interface ExecutionState {
89
+ /** Set of completed node IDs */
90
+ completedNodes: Set<string>;
91
+ /** Set of in-progress node IDs */
92
+ inProgressNodes: Set<string>;
93
+ /** Set of pending node IDs */
94
+ pendingNodes: Set<string>;
95
+ /** Map of node ID to output */
96
+ nodeOutputs: Map<string, unknown>;
97
+ /** Map of node ID to input */
98
+ nodeInputs: Map<string, unknown>;
99
+ /** Map of variable name to value */
100
+ variables: Map<string, unknown>;
101
+ /** Loop iteration counts */
102
+ loopCounts: Map<string, number>;
103
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Shared helpers for workflow session message metadata.
3
+ * Ensures nodeId / workflowNodeId and _workflowNodeMetadata are consistent.
4
+ */
5
+ export type WorkflowNodeMessageType = 'workflow.node.start' | 'workflow.node.end' | 'workflow.node.interrupt' | 'workflow.node.resume' | 'workflow.node.call' | 'workflow.node.result';
6
+ /**
7
+ * Resolve node id from message metadata (supports nodeId and workflowNodeId).
8
+ */
9
+ export declare function getWorkflowNodeIdFromMetadata(metadata: Record<string, unknown> | undefined | null): string | undefined;
10
+ /**
11
+ * Build base workflow node message metadata with nodeId aliases.
12
+ */
13
+ export declare function buildWorkflowNodeMetadata(type: WorkflowNodeMessageType, nodeId: string, nodeType: string, extra?: Record<string, unknown>): Record<string, unknown>;
14
+ /**
15
+ * Patch agentSessionId onto an existing metadata object and optional parts.
16
+ */
17
+ export declare function patchAgentSessionIdOnMessage(metadata: Record<string, unknown> | undefined, parts: unknown[] | undefined, agentSessionId: string): {
18
+ metadata: Record<string, unknown>;
19
+ parts?: unknown[];
20
+ };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @fileoverview Workflow Definition Sanitization
3
+ *
4
+ * Task #2926: Persist fixes for shell-script bugs that previously lived only as
5
+ * runtime SQLite patches (e.g. `query-wiki-iteration-tasks v2.4.0` had three
6
+ * known issues that the previous subagent patched directly in the database).
7
+ *
8
+ * Without this sanitizer, those patches vanish on any reinstall / reimport /
9
+ * fresh db migration. The sanitize step runs inside the service layer
10
+ * (`WorkflowService.createWorkflow` / `updateWorkflow`) before the definition
11
+ * is JSON-stringified and written to SQLite, so every persistence path is
12
+ * covered.
13
+ *
14
+ * Currently fixed defects (all match bugs observed in Task #2924):
15
+ *
16
+ * 1. `python3 -c "; <module> ..."` — leading `; ` inside the `-c` argument
17
+ * causes `SyntaxError: invalid syntax` (Python rejects a statement
18
+ * starting with `;`). Fix: drop the leading `; `.
19
+ *
20
+ * 2. Bare `$RANDOM` reference inside a script run by `dash` (the default
21
+ * `/bin/sh` on Debian/Ubuntu) with `set -u` enabled throws
22
+ * `RANDOM: parameter not set`. Fix: expand to `${RANDOM:-0}`.
23
+ *
24
+ * The sanitizer is intentionally conservative:
25
+ * - It mutates only string values reachable through known command fields
26
+ * (`config.command`, `config.inputs.command`, `config.input.command`,
27
+ * `config.message`, `config.inputs.message`).
28
+ * - It walks `depends_on` and arbitrary nested config (e.g. retry block
29
+ * does not contain shell but other extensions might).
30
+ * - It returns a deep clone to keep callers from sharing references with
31
+ * SQLite-bound objects.
32
+ *
33
+ * Anything that doesn't match a known bad pattern is left untouched.
34
+ */
35
+ import type { WorkflowDefinition } from '../types/workflow';
36
+ /**
37
+ * Public entry point. Returns a sanitized deep-clone of the workflow
38
+ * definition (the original object is not mutated).
39
+ */
40
+ export declare function sanitizeWorkflowDefinition(definition: WorkflowDefinition): WorkflowDefinition;
41
+ /**
42
+ * Apply the known shell-script bug fixes to a single string.
43
+ *
44
+ * Bug 1: `python3 -c "; <stmt>"` (or `python3 -c ";<stmt>"`) — drop leading
45
+ * `; ` so Python sees a valid statement.
46
+ *
47
+ * Bug 2: bare `$RANDOM` reference — wrap with `${RANDOM:-0}` so `dash` under
48
+ * `set -u` doesn't blow up. Already-safe forms (`${RANDOM:-x}`,
49
+ * `${RANDOM}`, `$RANDOM9`, `${RANDOM:-}`) are left alone.
50
+ */
51
+ export declare function sanitizeShellScript(script: string): string;