agentworkshop 0.11.3 → 0.13.0

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 (457) hide show
  1. package/.AgentWorkShop/prompts/host-tools.json +4 -4
  2. package/.output/.AgentWorkShop/prompts/host-tools.json +4 -4
  3. package/.output/nitro.json +1 -1
  4. package/.output/public/_nuxt/{DXXBGPAc.js → CsdezMu9.js} +4 -4
  5. package/.output/public/_nuxt/WL1R8lPA.js +1 -0
  6. package/.output/public/_nuxt/_id_.Czwkl50w.css +1 -0
  7. package/.output/public/_nuxt/builds/latest.json +1 -1
  8. package/.output/public/_nuxt/builds/meta/2f96705b-cf57-4bde-87a4-1b818b268f0f.json +1 -0
  9. package/.output/server/chunks/_/access.mjs +1 -1
  10. package/.output/server/chunks/_/candidate-store.mjs +1 -1
  11. package/.output/server/chunks/_/catalog-view.mjs +1 -1
  12. package/.output/server/chunks/_/character-asset.repo.mjs +1 -1
  13. package/.output/server/chunks/_/data-export.mjs +6 -6
  14. package/.output/server/chunks/_/data-query.mjs +3 -3
  15. package/.output/server/chunks/_/eda-run.repo.mjs +2 -2
  16. package/.output/server/chunks/_/entity.mjs +1 -1
  17. package/.output/server/chunks/_/features.mjs +5 -5
  18. package/.output/server/chunks/_/golden.mjs +3 -3
  19. package/.output/server/chunks/_/host-bindings.mjs +1 -1
  20. package/.output/server/chunks/_/index.mjs +1 -1
  21. package/.output/server/chunks/_/line-scope.mjs +1 -1
  22. package/.output/server/chunks/_/mes-console.mjs +1 -1
  23. package/.output/server/chunks/_/mes-secrets.repo.mjs +1 -1
  24. package/.output/server/chunks/_/mes-templates.mjs +1 -1
  25. package/.output/server/chunks/_/nitro.mjs +4084 -2343
  26. package/.output/server/chunks/_/nitro.mjs.map +1 -1
  27. package/.output/server/chunks/_/ocap.mjs +1 -1
  28. package/.output/server/chunks/_/orchestrator.mjs +1 -1
  29. package/.output/server/chunks/_/promote.mjs +1 -1
  30. package/.output/server/chunks/_/rest-auth.mjs +1 -1
  31. package/.output/server/chunks/_/runtime.mjs +8 -8
  32. package/.output/server/chunks/_/scene-layout.repo.mjs +1 -1
  33. package/.output/server/chunks/_/spc.mjs +1 -1
  34. package/.output/server/chunks/_/validator.mjs +1 -1
  35. package/.output/server/chunks/build/TownView-DD1zY8xq.mjs +1 -1
  36. package/.output/server/chunks/build/{_id_-C0vNEbts.mjs → _id_-B9zi8WEg.mjs} +23 -12
  37. package/.output/server/chunks/build/_id_-B9zi8WEg.mjs.map +1 -0
  38. package/.output/server/chunks/build/_wsId_-LDv5SEW_.mjs +1 -1
  39. package/.output/server/chunks/build/daq-B5zlUIlb.mjs +1 -1
  40. package/.output/server/chunks/build/dcw-B-eoU7sq.mjs +1 -1
  41. package/.output/server/chunks/build/types-D6J7slEa.mjs +1 -1
  42. package/.output/server/chunks/build/useDaqAddNode-Dr5CfMpU.mjs +1 -1
  43. package/.output/server/chunks/build/useDaqDetailNode-DDq5osE-.mjs +1 -1
  44. package/.output/server/chunks/build/useDaqDetailParams-DdOcUvHG.mjs +1 -1
  45. package/.output/server/chunks/build/useDaqFilters-Y_NRhP6i.mjs +1 -1
  46. package/.output/server/chunks/build/useDaqStream-phwM5tIN.mjs +1 -1
  47. package/.output/server/chunks/build/useDaqTemplates-lKw2b01d.mjs +1 -1
  48. package/.output/server/chunks/build/useDcwAddNode-CT-oOFom.mjs +1 -1
  49. package/.output/server/chunks/build/useDcwStream-CNtMGcR0.mjs +1 -1
  50. package/.output/server/chunks/routes/api/mcp/workshop.mjs +1 -1
  51. package/.output/server/chunks/routes/api/system/backup/run.post.mjs +2 -2
  52. package/.output/server/chunks/routes/api/system/index.patch.mjs +2 -2
  53. package/.output/server/chunks/routes/api/system/shutdown.post.mjs +2 -2
  54. package/.output/server/chunks/routes/api/workshop/agent-tools/index.post.mjs +1 -1
  55. package/.output/server/chunks/routes/api/workshop/agent-tools/list.get.mjs +7 -2
  56. package/.output/server/chunks/routes/api/workshop/agent-tools/list.get.mjs.map +1 -1
  57. package/.output/server/chunks/routes/api/workshop/agents/_id_.patch.mjs +1 -1
  58. package/.output/server/chunks/routes/api/workshop/aml/datasets/_id/preview.get.mjs +1 -1
  59. package/.output/server/chunks/routes/api/workshop/aml/datasets/_id_.delete.mjs +1 -1
  60. package/.output/server/chunks/routes/api/workshop/aml/datasets/_id_.get.mjs +1 -1
  61. package/.output/server/chunks/routes/api/workshop/aml/datasets/_id_.patch.mjs +1 -1
  62. package/.output/server/chunks/routes/api/workshop/aml/env/recheck.post.mjs +1 -1
  63. package/.output/server/chunks/routes/api/workshop/aml/env/uv.post.mjs +1 -1
  64. package/.output/server/chunks/routes/api/workshop/aml/env/venv.post.mjs +1 -1
  65. package/.output/server/chunks/routes/api/workshop/aml/index.get.mjs +1 -1
  66. package/.output/server/chunks/routes/api/workshop/aml/index.post.mjs +1 -1
  67. package/.output/server/chunks/routes/api/workshop/aml/index2.post.mjs +1 -1
  68. package/.output/server/chunks/routes/api/workshop/aml/index3.get.mjs +1 -1
  69. package/.output/server/chunks/routes/api/workshop/aml/index3.post.mjs +1 -1
  70. package/.output/server/chunks/routes/api/workshop/aml/index4.get.mjs +1 -1
  71. package/.output/server/chunks/routes/api/workshop/aml/index5.get.mjs +1 -1
  72. package/.output/server/chunks/routes/api/workshop/aml/index6.get.mjs +1 -1
  73. package/.output/server/chunks/routes/api/workshop/aml/index7.get.mjs +1 -1
  74. package/.output/server/chunks/routes/api/workshop/aml/jobs/_id/cancel.post.mjs +1 -1
  75. package/.output/server/chunks/routes/api/workshop/aml/jobs/_id/logs.get.mjs +1 -1
  76. package/.output/server/chunks/routes/api/workshop/aml/jobs/_id/retry.post.mjs +1 -1
  77. package/.output/server/chunks/routes/api/workshop/aml/jobs/_id_.delete.mjs +1 -1
  78. package/.output/server/chunks/routes/api/workshop/aml/jobs/_id_.get.mjs +1 -1
  79. package/.output/server/chunks/routes/api/workshop/aml/models/_id/predict.post.mjs +1 -1
  80. package/.output/server/chunks/routes/api/workshop/aml/models/_id/promote.post.mjs +1 -1
  81. package/.output/server/chunks/routes/api/workshop/aml/models/_id_.delete.mjs +1 -1
  82. package/.output/server/chunks/routes/api/workshop/aml/models/_id_.patch.mjs +1 -1
  83. package/.output/server/chunks/routes/api/workshop/aml/models/index.get.mjs +1 -1
  84. package/.output/server/chunks/routes/api/workshop/aml/training-plans/_id/train.post.mjs +1 -1
  85. package/.output/server/chunks/routes/api/workshop/aml/training-plans/_id_.delete.mjs +1 -1
  86. package/.output/server/chunks/routes/api/workshop/aml/training-plans/_id_.patch.mjs +1 -1
  87. package/.output/server/chunks/routes/api/workshop/aml/training-plans/index.get.mjs +1 -1
  88. package/.output/server/chunks/routes/api/workshop/aml/twin/providers.get.mjs +1 -1
  89. package/.output/server/chunks/routes/api/workshop/analysis/_id_.delete.mjs +1 -1
  90. package/.output/server/chunks/routes/api/workshop/analysis/_id_.get.mjs +1 -1
  91. package/.output/server/chunks/routes/api/workshop/analysis/_id_.patch.mjs +1 -1
  92. package/.output/server/chunks/routes/api/workshop/assets/devices/_id_.delete.mjs +1 -1
  93. package/.output/server/chunks/routes/api/workshop/assets/index.post.mjs +1 -1
  94. package/.output/server/chunks/routes/api/workshop/assets/index2.post.mjs +1 -1
  95. package/.output/server/chunks/routes/api/workshop/channel-templates/_id/instantiate.post.mjs +2 -2
  96. package/.output/server/chunks/routes/api/workshop/channel-templates/_id_.patch.mjs +1 -1
  97. package/.output/server/chunks/routes/api/workshop/channels/_id/activate.post.mjs +1 -1
  98. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId_.patch.mjs +1 -1
  99. package/.output/server/chunks/routes/api/workshop/channels/_id/chat/index.post.mjs +1 -1
  100. package/.output/server/chunks/routes/api/workshop/channels/_id/execution-mode.patch.mjs +1 -1
  101. package/.output/server/chunks/routes/api/workshop/channels/_id/harness-profiles/promote.post.mjs +1 -1
  102. package/.output/server/chunks/routes/api/workshop/channels/_id/improvement-proposals/decide.post.mjs +1 -1
  103. package/.output/server/chunks/routes/api/workshop/channels/_id/index.post.mjs +1 -1
  104. package/.output/server/chunks/routes/api/workshop/channels/_id/index.put.mjs +1 -1
  105. package/.output/server/chunks/routes/api/workshop/channels/_id/index11.get.mjs +1 -1
  106. package/.output/server/chunks/routes/api/workshop/channels/_id/index2.get.mjs +1 -1
  107. package/.output/server/chunks/routes/api/workshop/channels/_id/index2.post.mjs +1 -1
  108. package/.output/server/chunks/routes/api/workshop/channels/_id/index2.put.mjs +1 -1
  109. package/.output/server/chunks/routes/api/workshop/channels/_id/index3.get.mjs +1 -1
  110. package/.output/server/chunks/routes/api/workshop/channels/_id/index3.post.mjs +1 -1
  111. package/.output/server/chunks/routes/api/workshop/channels/_id/index5.post.mjs +1 -1
  112. package/.output/server/chunks/routes/api/workshop/channels/_id/index7.get.mjs +1 -1
  113. package/.output/server/chunks/routes/api/workshop/channels/_id/index7.post.mjs +1 -1
  114. package/.output/server/chunks/routes/api/workshop/channels/_id/line.put.mjs +1 -1
  115. package/.output/server/chunks/routes/api/workshop/channels/_id/members/join.post.mjs +1 -1
  116. package/.output/server/chunks/routes/api/workshop/channels/_id/memories/_memoryId/promote.post.mjs +1 -1
  117. package/.output/server/chunks/routes/api/workshop/channels/_id/memories/merge.post.mjs +1 -1
  118. package/.output/server/chunks/routes/api/workshop/channels/_id/products.get.mjs +1 -1
  119. package/.output/server/chunks/routes/api/workshop/channels/_id/products.put.mjs +1 -1
  120. package/.output/server/chunks/routes/api/workshop/channels/_id/terminals.get.mjs +1 -1
  121. package/.output/server/chunks/routes/api/workshop/channels/_id/tool-usage.get.mjs +1 -1
  122. package/.output/server/chunks/routes/api/workshop/channels/_id/tools/reset.post.mjs +1 -1
  123. package/.output/server/chunks/routes/api/workshop/channels/_id/twin-profile.get.mjs +1 -1
  124. package/.output/server/chunks/routes/api/workshop/channels/_id/twin-profile.patch.mjs +1 -1
  125. package/.output/server/chunks/routes/api/workshop/channels/_id_.delete.mjs +1 -1
  126. package/.output/server/chunks/routes/api/workshop/channels/index.get.mjs +1 -1
  127. package/.output/server/chunks/routes/api/workshop/channels/index.patch.mjs +1 -1
  128. package/.output/server/chunks/routes/api/workshop/channels.post.mjs +7 -7
  129. package/.output/server/chunks/routes/api/workshop/daq/_id/bind.post.mjs +1 -1
  130. package/.output/server/chunks/routes/api/workshop/daq/_id/bindings.put.mjs +1 -1
  131. package/.output/server/chunks/routes/api/workshop/daq/_id/frames/content.get.mjs +1 -1
  132. package/.output/server/chunks/routes/api/workshop/daq/_id/frames.get.mjs +1 -1
  133. package/.output/server/chunks/routes/api/workshop/daq/_id/ingest.post.mjs +2 -2
  134. package/.output/server/chunks/routes/api/workshop/daq/_id/samples.get.mjs +1 -1
  135. package/.output/server/chunks/routes/api/workshop/daq/_id/test.post.mjs +1 -1
  136. package/.output/server/chunks/routes/api/workshop/daq/_id_.delete.mjs +1 -1
  137. package/.output/server/chunks/routes/api/workshop/daq/_id_.patch.mjs +1 -1
  138. package/.output/server/chunks/routes/api/workshop/daq/alarms/_id/ack.post.mjs +1 -1
  139. package/.output/server/chunks/routes/api/workshop/daq/controller.post.mjs +1 -1
  140. package/.output/server/chunks/routes/api/workshop/daq/index.get.mjs +1 -1
  141. package/.output/server/chunks/routes/api/workshop/daq/index2.post.mjs +1 -1
  142. package/.output/server/chunks/routes/api/workshop/daq/infra/reconnect.post.mjs +1 -1
  143. package/.output/server/chunks/routes/api/workshop/daq/storage/retention.put.mjs +1 -1
  144. package/.output/server/chunks/routes/api/workshop/daq/storage/rollup.post.mjs +1 -1
  145. package/.output/server/chunks/routes/api/workshop/daq/storage.get.mjs +1 -1
  146. package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.delete.mjs +1 -1
  147. package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.patch.mjs +1 -1
  148. package/.output/server/chunks/routes/api/workshop/daq/test-driver.post.mjs +1 -1
  149. package/.output/server/chunks/routes/api/workshop/dcw/_id/bind.post.mjs +1 -1
  150. package/.output/server/chunks/routes/api/workshop/dcw/_id/bindings.put.mjs +1 -1
  151. package/.output/server/chunks/routes/api/workshop/dcw/_id/param-ledger.get.mjs +1 -1
  152. package/.output/server/chunks/routes/api/workshop/dcw/_id/read.post.mjs +1 -1
  153. package/.output/server/chunks/routes/api/workshop/dcw/_id/test.post.mjs +1 -1
  154. package/.output/server/chunks/routes/api/workshop/dcw/_id/write.post.mjs +1 -1
  155. package/.output/server/chunks/routes/api/workshop/dcw/_id_.delete.mjs +1 -1
  156. package/.output/server/chunks/routes/api/workshop/dcw/_id_.patch.mjs +1 -1
  157. package/.output/server/chunks/routes/api/workshop/dcw/controller.post.mjs +1 -1
  158. package/.output/server/chunks/routes/api/workshop/dcw/index.get.mjs +1 -1
  159. package/.output/server/chunks/routes/api/workshop/dcw/index.post.mjs +1 -1
  160. package/.output/server/chunks/routes/api/workshop/dcw/index2.get.mjs +1 -1
  161. package/.output/server/chunks/routes/api/workshop/dcw/index2.post.mjs +1 -1
  162. package/.output/server/chunks/routes/api/workshop/dcw/index3.get.mjs +1 -1
  163. package/.output/server/chunks/routes/api/workshop/dcw/index3.post.mjs +1 -1
  164. package/.output/server/chunks/routes/api/workshop/dcw/index4.get.mjs +1 -1
  165. package/.output/server/chunks/routes/api/workshop/dcw/index4.post.mjs +1 -1
  166. package/.output/server/chunks/routes/api/workshop/dcw/index5.get.mjs +1 -1
  167. package/.output/server/chunks/routes/api/workshop/dcw/index5.post.mjs +1 -1
  168. package/.output/server/chunks/routes/api/workshop/dcw/index6.get.mjs +1 -1
  169. package/.output/server/chunks/routes/api/workshop/dcw/index7.get.mjs +1 -1
  170. package/.output/server/chunks/routes/api/workshop/dcw/index8.get.mjs +1 -1
  171. package/.output/server/chunks/routes/api/workshop/dcw/journal/node/_nodeId/rollback.post.mjs +1 -1
  172. package/.output/server/chunks/routes/api/workshop/dcw/line/query.get.mjs +1 -1
  173. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/start.post.mjs +1 -1
  174. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/stop.post.mjs +1 -1
  175. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id_.delete.mjs +1 -1
  176. package/.output/server/chunks/routes/api/workshop/dcw/lines/index.get.mjs +1 -1
  177. package/.output/server/chunks/routes/api/workshop/dcw/mes-artifacts/file.get.mjs +1 -1
  178. package/.output/server/chunks/routes/api/workshop/dcw/mes-hook-test.post.mjs +1 -1
  179. package/.output/server/chunks/routes/api/workshop/dcw/mes-test-read.post.mjs +1 -1
  180. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/judge.post.mjs +1 -1
  181. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/rollback.post.mjs +1 -1
  182. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/series.get.mjs +1 -1
  183. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id_.get.mjs +1 -1
  184. package/.output/server/chunks/routes/api/workshop/dcw/params/_id/read.post.mjs +1 -1
  185. package/.output/server/chunks/routes/api/workshop/dcw/params/_id/write.post.mjs +1 -1
  186. package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.delete.mjs +1 -1
  187. package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.patch.mjs +1 -1
  188. package/.output/server/chunks/routes/api/workshop/dcw/products/_id_.delete.mjs +1 -1
  189. package/.output/server/chunks/routes/api/workshop/dcw/products/_id_.patch.mjs +1 -1
  190. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/apply.post.mjs +1 -1
  191. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/mark-good.post.mjs +1 -1
  192. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/revert.post.mjs +1 -1
  193. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/rollback-good.post.mjs +1 -1
  194. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id_.delete.mjs +2 -2
  195. package/.output/server/chunks/routes/api/workshop/dcw/recipes/index.patch.mjs +1 -1
  196. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/close.post.mjs +1 -1
  197. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/data.get.mjs +1 -1
  198. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/rollback.post.mjs +1 -1
  199. package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.delete.mjs +1 -1
  200. package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.patch.mjs +1 -1
  201. package/.output/server/chunks/routes/api/workshop/dcw/test-driver.post.mjs +1 -1
  202. package/.output/server/chunks/routes/api/workshop/device-twins/_id/control.post.mjs +1 -1
  203. package/.output/server/chunks/routes/api/workshop/device-twins/_id/telemetry.post.mjs +1 -1
  204. package/.output/server/chunks/routes/api/workshop/device-twins/_id_.delete.mjs +1 -1
  205. package/.output/server/chunks/routes/api/workshop/device-twins/_id_.patch.mjs +1 -1
  206. package/.output/server/chunks/routes/api/workshop/eda/commonality.get.mjs +1 -1
  207. package/.output/server/chunks/routes/api/workshop/eda/index6.get.mjs +1 -1
  208. package/.output/server/chunks/routes/api/workshop/eda/index6.post.mjs +1 -1
  209. package/.output/server/chunks/routes/api/workshop/eda/vm/predict.post.mjs +1 -1
  210. package/.output/server/chunks/routes/api/workshop/exp/confirmations/_id/decide.post.mjs +1 -1
  211. package/.output/server/chunks/routes/api/workshop/exp/index.get.mjs +1 -1
  212. package/.output/server/chunks/routes/api/workshop/fs/dirs.get.mjs +1 -1
  213. package/.output/server/chunks/routes/api/workshop/harnesses/_id/providers.get.mjs +1 -1
  214. package/.output/server/chunks/routes/api/workshop/harnesses.get.mjs +1 -1
  215. package/.output/server/chunks/routes/api/workshop/hitl/pending.get.mjs +1 -1
  216. package/.output/server/chunks/routes/api/workshop/hitl/respond.post.mjs +1 -1
  217. package/.output/server/chunks/routes/api/workshop/index.mjs +1 -1
  218. package/.output/server/chunks/routes/api/workshop/index.post.mjs +1 -1
  219. package/.output/server/chunks/routes/api/workshop/index.put.mjs +1 -1
  220. package/.output/server/chunks/routes/api/workshop/index12.get.mjs +1 -1
  221. package/.output/server/chunks/routes/api/workshop/index13.get.mjs +1 -1
  222. package/.output/server/chunks/routes/api/workshop/index14.get.mjs +1 -1
  223. package/.output/server/chunks/routes/api/workshop/index2.get.mjs +1 -1
  224. package/.output/server/chunks/routes/api/workshop/index2.post.mjs +1 -1
  225. package/.output/server/chunks/routes/api/workshop/index3.get.mjs +1 -1
  226. package/.output/server/chunks/routes/api/workshop/index3.post.mjs +1 -1
  227. package/.output/server/chunks/routes/api/workshop/index4.post.mjs +1 -1
  228. package/.output/server/chunks/routes/api/workshop/index5.post.mjs +1 -1
  229. package/.output/server/chunks/routes/api/workshop/index6.get.mjs +1 -1
  230. package/.output/server/chunks/routes/api/workshop/index6.post.mjs +1 -1
  231. package/.output/server/chunks/routes/api/workshop/index7.get.mjs +1 -1
  232. package/.output/server/chunks/routes/api/workshop/index7.post.mjs +1 -1
  233. package/.output/server/chunks/routes/api/workshop/index8.get.mjs +1 -1
  234. package/.output/server/chunks/routes/api/workshop/index8.post.mjs +1 -1
  235. package/.output/server/chunks/routes/api/workshop/index9.post.mjs +1 -1
  236. package/.output/server/chunks/routes/api/workshop/mes/bridge.post.mjs +1 -1
  237. package/.output/server/chunks/routes/api/workshop/mes/datasets.get.mjs +1 -1
  238. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId/autofix.mjs +1 -1
  239. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId/compile.mjs +1 -1
  240. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId/evidence.mjs +1 -1
  241. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId/publish.mjs +1 -1
  242. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId/rules/_ruleId/approval-decision.mjs +1 -1
  243. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId/rules/_ruleId/approval.mjs +1 -1
  244. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId/rules/_ruleId/transition.mjs +1 -1
  245. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId/subgraph.mjs +1 -1
  246. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId/validate.mjs +1 -1
  247. package/.output/server/chunks/routes/api/workshop/ontology/drafts/_draftId_.mjs +1 -1
  248. package/.output/server/chunks/routes/api/workshop/ontology/export/_ontologyId_.mjs +1 -1
  249. package/.output/server/chunks/routes/api/workshop/ontology/index.mjs +1 -1
  250. package/.output/server/chunks/routes/api/workshop/ontology/scene.mjs +1 -1
  251. package/.output/server/chunks/routes/api/workshop/ontology/traces/_ontologyId_.mjs +1 -1
  252. package/.output/server/chunks/routes/api/workshop/ontology/versions/_ontologyId/compare.mjs +1 -1
  253. package/.output/server/chunks/routes/api/workshop/ontology/versions/_ontologyId_.mjs +1 -1
  254. package/.output/server/chunks/routes/api/workshop/optimization/capabilities.get.mjs +1 -1
  255. package/.output/server/chunks/routes/api/workshop/optimization/index.get.mjs +1 -1
  256. package/.output/server/chunks/routes/api/workshop/optimization/index.mjs +1 -1
  257. package/.output/server/chunks/routes/api/workshop/optimization/index2.mjs +1 -1
  258. package/.output/server/chunks/routes/api/workshop/optimization/profiles/_id/publish.post.mjs +1 -1
  259. package/.output/server/chunks/routes/api/workshop/optimization/recommendations/_id/crosscheck.post.mjs +1 -1
  260. package/.output/server/chunks/routes/api/workshop/optimization/recommendations/_id/dispatch.post.mjs +1 -1
  261. package/.output/server/chunks/routes/api/workshop/optimization/solve.post.mjs +1 -1
  262. package/.output/server/chunks/routes/api/workshop/plugins/_name/disable.post.mjs +1 -1
  263. package/.output/server/chunks/routes/api/workshop/plugins/_name/enable.post.mjs +1 -1
  264. package/.output/server/chunks/routes/api/workshop/process-model/datasets.post.mjs +1 -1
  265. package/.output/server/chunks/routes/api/workshop/process-model/eligibility.mjs +1 -1
  266. package/.output/server/chunks/routes/api/workshop/process-model/experiments.mjs +1 -1
  267. package/.output/server/chunks/routes/api/workshop/process-model/index.mjs +1 -1
  268. package/.output/server/chunks/routes/api/workshop/process-model/specs/_id/publish.post.mjs +1 -1
  269. package/.output/server/chunks/routes/api/workshop/process-model/train.post.mjs +1 -1
  270. package/.output/server/chunks/routes/api/workshop/projects/_id/activate.post.mjs +1 -1
  271. package/.output/server/chunks/routes/api/workshop/projects/_id/approvals/_aid/decide.post.mjs +1 -1
  272. package/.output/server/chunks/routes/api/workshop/projects/_id/archive.post.mjs +1 -1
  273. package/.output/server/chunks/routes/api/workshop/projects/_id/channels/_channelId_.delete.mjs +1 -1
  274. package/.output/server/chunks/routes/api/workshop/projects/_id/complete.post.mjs +1 -1
  275. package/.output/server/chunks/routes/api/workshop/projects/_id/continue.post.mjs +1 -1
  276. package/.output/server/chunks/routes/api/workshop/projects/_id/deliverables/_did/waive.post.mjs +1 -1
  277. package/.output/server/chunks/routes/api/workshop/projects/_id/deliverables/index.get.mjs +1 -1
  278. package/.output/server/chunks/routes/api/workshop/projects/_id/deliverables/index.patch.mjs +1 -1
  279. package/.output/server/chunks/routes/api/workshop/projects/_id/health.get.mjs +1 -1
  280. package/.output/server/chunks/routes/api/workshop/projects/_id/index.get.mjs +1 -1
  281. package/.output/server/chunks/routes/api/workshop/projects/_id/index.post.mjs +1 -1
  282. package/.output/server/chunks/routes/api/workshop/projects/_id/index2.get.mjs +1 -1
  283. package/.output/server/chunks/routes/api/workshop/projects/_id/index2.post.mjs +1 -1
  284. package/.output/server/chunks/routes/api/workshop/projects/_id/index3.get.mjs +1 -1
  285. package/.output/server/chunks/routes/api/workshop/projects/_id/index3.post.mjs +1 -1
  286. package/.output/server/chunks/routes/api/workshop/projects/_id/index4.get.mjs +1 -1
  287. package/.output/server/chunks/routes/api/workshop/projects/_id/index4.post.mjs +1 -1
  288. package/.output/server/chunks/routes/api/workshop/projects/_id/index5.get.mjs +1 -1
  289. package/.output/server/chunks/routes/api/workshop/projects/_id/index6.get.mjs +1 -1
  290. package/.output/server/chunks/routes/api/workshop/projects/_id/index7.get.mjs +1 -1
  291. package/.output/server/chunks/routes/api/workshop/projects/_id/index8.get.mjs +1 -1
  292. package/.output/server/chunks/routes/api/workshop/projects/_id/kernel/tick.post.mjs +1 -1
  293. package/.output/server/chunks/routes/api/workshop/projects/_id/ledger.get.mjs +1 -1
  294. package/.output/server/chunks/routes/api/workshop/projects/_id/members/_userId_.delete.mjs +1 -1
  295. package/.output/server/chunks/routes/api/workshop/projects/_id/observability/activity.get.mjs +1 -1
  296. package/.output/server/chunks/routes/api/workshop/projects/_id/observability/route.get.mjs +1 -1
  297. package/.output/server/chunks/routes/api/workshop/projects/_id/observability/work-items/_wid_.get.mjs +1 -1
  298. package/.output/server/chunks/routes/api/workshop/projects/_id/observability.get.mjs +1 -1
  299. package/.output/server/chunks/routes/api/workshop/projects/_id/pause.post.mjs +1 -1
  300. package/.output/server/chunks/routes/api/workshop/projects/_id/plan/request-approval.post.mjs +1 -1
  301. package/.output/server/chunks/routes/api/workshop/projects/_id/proposals/_decisionId/apply.post.mjs +1 -1
  302. package/.output/server/chunks/routes/api/workshop/projects/_id/reconcile.post.mjs +1 -1
  303. package/.output/server/chunks/routes/api/workshop/projects/_id/report.get.mjs +1 -1
  304. package/.output/server/chunks/routes/api/workshop/projects/_id/results/_rid/request-acceptance.post.mjs +1 -1
  305. package/.output/server/chunks/routes/api/workshop/projects/_id/results/_rid/review.post.mjs +1 -1
  306. package/.output/server/chunks/routes/api/workshop/projects/_id/results/_rid/submit.post.mjs +1 -1
  307. package/.output/server/chunks/routes/api/workshop/projects/_id/results/_rid/supersede.post.mjs +1 -1
  308. package/.output/server/chunks/routes/api/workshop/projects/_id/resume.post.mjs +1 -1
  309. package/.output/server/chunks/routes/api/workshop/projects/_id/sessions.get.mjs +1 -1
  310. package/.output/server/chunks/routes/api/workshop/projects/_id/snapshot.get.mjs +1 -1
  311. package/.output/server/chunks/routes/api/workshop/projects/_id/terminate.post.mjs +1 -1
  312. package/.output/server/chunks/routes/api/workshop/projects/_id/trace/_traceId_.get.mjs +1 -1
  313. package/.output/server/chunks/routes/api/workshop/projects/_id/work-items/_wid/cancel.post.mjs +1 -1
  314. package/.output/server/chunks/routes/api/workshop/projects/_id/work-items/_wid/dispatch.post.mjs +1 -1
  315. package/.output/server/chunks/routes/api/workshop/projects/_id/work-items/_wid/retry.post.mjs +1 -1
  316. package/.output/server/chunks/routes/api/workshop/projects/_id/work-items/index.get.mjs +1 -1
  317. package/.output/server/chunks/routes/api/workshop/projects/_id/work-items/index.patch.mjs +1 -1
  318. package/.output/server/chunks/routes/api/workshop/projects/_id_.get.mjs +1 -1
  319. package/.output/server/chunks/routes/api/workshop/projects/_id_.patch.mjs +1 -1
  320. package/.output/server/chunks/routes/api/workshop/projects/instantiate.post.mjs +1 -1
  321. package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.delete.mjs +1 -1
  322. package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.put.mjs +1 -1
  323. package/.output/server/chunks/routes/api/workshop/tasks/_id/recovery-disposition.post.mjs +44 -0
  324. package/.output/server/chunks/routes/api/workshop/tasks/_id/recovery-disposition.post.mjs.map +1 -0
  325. package/.output/server/chunks/routes/api/workshop/tasks/recovery-holds.get.mjs +38 -0
  326. package/.output/server/chunks/routes/api/workshop/tasks/recovery-holds.get.mjs.map +1 -0
  327. package/.output/server/chunks/routes/api/workshop/teams/_id/deploy.post.mjs +1 -1
  328. package/.output/server/chunks/routes/api/workshop/teams/_id/index.put.mjs +1 -1
  329. package/.output/server/chunks/routes/api/workshop/teams/_id/index2.get.mjs +1 -1
  330. package/.output/server/chunks/routes/api/workshop/tools/sync.post.mjs +1 -1
  331. package/.output/server/chunks/routes/api/workshop/workspaces/_id/channel-templates/_tplId_.post.mjs +2 -2
  332. package/.output/server/chunks/routes/api/workshop/ws/ticket.post.mjs +1 -1
  333. package/.output/server/chunks/routes/renderer.mjs +2 -2
  334. package/.output/server/chunks/virtual/entry.mjs +6 -2
  335. package/.output/server/chunks/virtual/precomputed.mjs +1 -1
  336. package/.output/server/package.json +1 -1
  337. package/README-zh.md +19 -7
  338. package/README.md +21 -7
  339. package/app/components/dcw/DcwNodesTable.vue +24 -0
  340. package/config.yml +1 -1
  341. package/docs/cli.en.md +1 -1
  342. package/docs/cli.md +1 -1
  343. package/docs/mcp.en.md +30 -27
  344. package/docs/mcp.md +7 -3
  345. package/docs/plugin-idd-rag-contract.md +87 -0
  346. package/docs/plugins.en.md +5 -3
  347. package/docs/plugins.md +5 -3
  348. package/docs/sdk.en.md +1 -1
  349. package/docs/sdk.md +1 -1
  350. package/i18n/dicts/dcwDetail.json +221 -219
  351. package/i18n/locales/en.ts +2 -0
  352. package/i18n/locales/zh-CN.ts +2 -0
  353. package/package.json +3 -1
  354. package/scripts/check-docs-sync.mjs +20 -9
  355. package/scripts/onboarding/forge-channel.mjs +2 -1
  356. package/scripts/onboarding/lib.mjs +159 -3
  357. package/scripts/onboarding/onboard.mjs +2 -0
  358. package/scripts/onboarding/preflight.mjs +233 -231
  359. package/scripts/onboarding/provision-line.mjs +12 -2
  360. package/scripts/onboarding/sim-attest.mjs +103 -0
  361. package/scripts/onboarding/sim-twin.mjs +115 -19
  362. package/scripts/onboarding/test-connection.mjs +2 -1
  363. package/scripts/onboarding/v6-protected-api.mjs +41 -0
  364. package/scripts/onboarding/v6-protected-fixture.mjs +54 -0
  365. package/scripts/onboarding/verify-line.mjs +179 -136
  366. package/scripts/onboarding/verify-mirror.mjs +149 -145
  367. package/server/api/workshop/agent-tools/list.get.ts +10 -1
  368. package/server/api/workshop/tasks/[id]/recovery-disposition.post.ts +32 -0
  369. package/server/api/workshop/tasks/recovery-holds.get.ts +22 -0
  370. package/server/plugins-builtin/diag-bridge/host/deposit.mjs +232 -0
  371. package/server/plugins-builtin/diag-bridge/host/diagnosis.mjs +121 -38
  372. package/server/plugins-builtin/diag-bridge/host/external-v1.mjs +213 -0
  373. package/server/plugins-builtin/diag-bridge/host/helpers.mjs +4 -2
  374. package/server/plugins-builtin/diag-bridge/host/intents.mjs +65 -62
  375. package/server/plugins-builtin/diag-bridge/host/plugin.mjs +351 -82
  376. package/server/plugins-builtin/diag-bridge/host/receipt.mjs +83 -0
  377. package/server/plugins-builtin/diag-bridge/host/sweep.mjs +70 -91
  378. package/server/plugins-builtin/diag-bridge/i18n.json +4 -0
  379. package/server/plugins-builtin/rag-bridge/i18n.json +18 -0
  380. package/server/plugins-builtin/rag-bridge/index.mjs +570 -64
  381. package/server/services/workshop/agents/agent-interface.ts +3 -0
  382. package/server/services/workshop/agents/base-agent.ts +100 -4
  383. package/server/services/workshop/agents/execution-scope.ts +26 -0
  384. package/server/services/workshop/agents/hitl-capabilities.ts +3 -3
  385. package/server/services/workshop/agents/host-tool-bridge/dispatch.ts +42 -2
  386. package/server/services/workshop/agents/host-tool-bridge/tools/progress.ts +4 -0
  387. package/server/services/workshop/agents/host-tool-bridge/tools/tasks.ts +11 -28
  388. package/server/services/workshop/agents/host-tool-bridge/tools/team-delegation.ts +83 -129
  389. package/server/services/workshop/agents/industrial/dcw-tools.ts +27 -5
  390. package/server/services/workshop/agents/industrial/line-tools.ts +15 -4
  391. package/server/services/workshop/agents/industrial/ops-tools.ts +32 -6
  392. package/server/services/workshop/agents/industrial/optimization-tools.ts +28 -4
  393. package/server/services/workshop/agents/industrial/recipe-propose-tools.ts +26 -3
  394. package/server/services/workshop/agents/omp-agent/client.ts +2 -4
  395. package/server/services/workshop/agents/omp-agent/core.ts +3 -0
  396. package/server/services/workshop/agents/omp-agent/lifecycle.ts +70 -4
  397. package/server/services/workshop/agents/omp-agent/supervision-decision.ts +3 -1
  398. package/server/services/workshop/agents/omp-agent/tools-steer.ts +113 -32
  399. package/server/services/workshop/agents/tool-approvals.ts +113 -29
  400. package/server/services/workshop/agents/tool-classes.ts +72 -56
  401. package/server/services/workshop/db/database/open.ts +5 -2
  402. package/server/services/workshop/db/database/schema.ts +1 -0
  403. package/server/services/workshop/db/database/seed.ts +2 -2
  404. package/server/services/workshop/db/message.repo.ts +134 -26
  405. package/server/services/workshop/db/project-kernel.repo.ts +3 -3
  406. package/server/services/workshop/db/schema.sql +3 -1
  407. package/server/services/workshop/db/task.repo.ts +101 -0
  408. package/server/services/workshop/dcw/dcw-controller/actuation.ts +120 -9
  409. package/server/services/workshop/dcw/dcw-controller/contracts.ts +18 -16
  410. package/server/services/workshop/dcw/dcw-controller/crud.ts +23 -0
  411. package/server/services/workshop/dcw/dcw-controller/lines.ts +34 -2
  412. package/server/services/workshop/dcw/dcw-controller/recipes.ts +80 -6
  413. package/server/services/workshop/dcw/dcw-controller/state.ts +89 -88
  414. package/server/services/workshop/dcw/dcw-controller/types.ts +5 -0
  415. package/server/services/workshop/dcw/dcw-controller/write.ts +9 -6
  416. package/server/services/workshop/dcw/dcw-line.repo.ts +2 -0
  417. package/server/services/workshop/dcw/dcw-node.repo.ts +3 -1
  418. package/server/services/workshop/dcw/dcw-node.ts +346 -307
  419. package/server/services/workshop/dcw/dcw-runtime.ts +8 -4
  420. package/server/services/workshop/projects/effects.ts +47 -29
  421. package/server/services/workshop/projects/kernel.ts +8 -1
  422. package/server/services/workshop/projects/legacy-recovery.ts +36 -0
  423. package/server/services/workshop/projects/service.ts +15 -0
  424. package/server/services/workshop/runtime/agent-runtime/contracts.ts +1 -1
  425. package/server/services/workshop/runtime/agent-runtime/lifecycle.ts +7 -2
  426. package/server/services/workshop/runtime/agent-runtime/message-watchdog.ts +40 -0
  427. package/server/services/workshop/runtime/agent-runtime/message.ts +151 -21
  428. package/server/services/workshop/runtime/agent-runtime/state.ts +69 -13
  429. package/server/services/workshop/runtime/agent-runtime/supervise.ts +219 -42
  430. package/server/services/workshop/runtime/agent-runtime/types.ts +6 -0
  431. package/server/services/workshop/runtime/mailbox.ts +112 -21
  432. package/server/services/workshop/runtime/manager/admin-channel.ts +34 -22
  433. package/server/services/workshop/runtime/manager/host-tools.ts +18 -5
  434. package/server/services/workshop/runtime/manager/runtime-wiring.ts +101 -41
  435. package/server/services/workshop/runtime/manager/schedules.ts +3 -1
  436. package/server/services/workshop/runtime/manager/tasks.ts +41 -0
  437. package/server/services/workshop/runtime/memory/recall.ts +11 -4
  438. package/server/services/workshop/runtime/memory/types.ts +2 -0
  439. package/server/services/workshop/runtime/scheduler-loop/contracts.ts +29 -29
  440. package/server/services/workshop/runtime/scheduler-loop/execute.ts +7 -0
  441. package/server/services/workshop/runtime/scheduler-loop/rules.ts +3 -0
  442. package/server/services/workshop/runtime/scheduler-loop/snapshot.ts +10 -2
  443. package/server/services/workshop/runtime/scheduler-loop/state.ts +12 -0
  444. package/server/services/workshop/runtime/scheduler-loop/tick.ts +54 -5
  445. package/server/services/workshop/runtime/task-engine/create.ts +16 -0
  446. package/server/services/workshop/runtime/task-engine/helpers.ts +5 -0
  447. package/server/services/workshop/runtime/task-engine/legacy-recovery.ts +149 -0
  448. package/server/services/workshop/runtime/task-engine/lifecycle.ts +38 -1
  449. package/server/services/workshop/runtime/task-engine/transition.ts +4 -0
  450. package/server/services/workshop/runtime/task-engine/update.ts +6 -0
  451. package/server/services/workshop/runtime/task-engine/views.ts +61 -0
  452. package/server/services/workshop/tools/policy.ts +16 -1
  453. package/shared/dcw-protocol/line.ts +4 -0
  454. package/.output/public/_nuxt/C8QlHux5.js +0 -1
  455. package/.output/public/_nuxt/_id_.0EnzA0aA.css +0 -1
  456. package/.output/public/_nuxt/builds/meta/846b9c03-1442-4fcb-b3fc-1d9484eaa41b.json +0 -1
  457. package/.output/server/chunks/build/_id_-C0vNEbts.mjs.map +0 -1
@@ -14,19 +14,27 @@ export abstract class SchedulerLoopSnapshot extends SchedulerLoopTick {
14
14
  * supervise 未实现/抛错/空决策时不能自动把任务派给 worker,也不能把父任务标记完成。
15
15
  * 指纹无变化时跳过 LLM,但恢复性规则仍可运行。
16
16
  */
17
- protected async decide(snapshot: SupervisionSnapshot): Promise<SchedulerDecision[]> {
17
+ protected async decide(snapshot: SupervisionSnapshot, stillCurrent: () => boolean): Promise<SchedulerDecision[]> {
18
+ let previousAttemptId: string | null | undefined
19
+ const aborted = (): boolean => {
20
+ const attempt = this.lead.getSupervisionStatus?.()
21
+ return Boolean(attempt?.attemptId && attempt.attemptId !== previousAttemptId && attempt.lastDecisionKind === 'aborted')
22
+ }
18
23
  try {
24
+ if (!stillCurrent()) return []
19
25
  if (!this.shouldSupervise(snapshot)) return this.ruleEngine(snapshot)
20
26
  this.lastSuperviseAt = Date.now()
21
27
  this.lastFingerprint = this.superviseFingerprint(snapshot)
28
+ previousAttemptId = this.lead.getSupervisionStatus?.().attemptId
22
29
  const decisions = await this.lead.supervise(snapshot)
23
- if (decisions === null) return this.ruleEngine(snapshot)
30
+ if (!stillCurrent() || aborted() || decisions === null) return []
24
31
  if (decisions.length > 0) return decisions
25
32
  // 空决策表示 Lead 本轮决定不采取行动;只允许非破坏性/故障恢复规则补充,
26
33
  // 常规派单和父任务验收永不由兜底猜测。
27
34
  return this.ruleEngine(snapshot)
28
35
  }
29
36
  catch (err) {
37
+ if (!stillCurrent() || aborted()) return []
30
38
  log.error(`[SchedulerLoop:${this.lead.agentId}] lead supervise 抛错,仅运行故障恢复规则(不盲派/验收):`, err)
31
39
  return this.ruleEngine(snapshot)
32
40
  }
@@ -22,6 +22,8 @@ export abstract class SchedulerLoopState extends SchedulerLoopContracts {
22
22
  protected lastFingerprint = ''
23
23
  protected timer: NodeJS.Timeout | null = null
24
24
  protected started = false
25
+ /** Invalidates work from a previous scheduler lifecycle, including after restart. */
26
+ protected lifecycleGeneration = 0
25
27
  protected running = false
26
28
  protected activeRound: Promise<void> | null = null
27
29
  protected pendingWake = false
@@ -60,6 +62,11 @@ export abstract class SchedulerLoopState extends SchedulerLoopContracts {
60
62
  this.onLeadDecision = options.onLeadDecision
61
63
  }
62
64
 
65
+ /** Use the task engine's shared FIFO hold policy, including terminal held roots. */
66
+ protected legacyBlocked(taskId: string): boolean {
67
+ return this.lead.taskEngine.isLegacyRecoveryBlocked?.(taskId) ?? false
68
+ }
69
+
63
70
  /** Lead 决策留痕(异常绝不阻断调度) */
64
71
  protected noteLeadDecision(e: { decision: string, taskId?: string, toAgentId?: string, reason?: string, rootId?: string }): void {
65
72
  try {
@@ -121,6 +128,11 @@ export abstract class SchedulerLoopState extends SchedulerLoopContracts {
121
128
 
122
129
  stop(): void {
123
130
  this.started = false
131
+ this.lifecycleGeneration++
132
+ this.lastSuperviseAt = 0
133
+ this.lastFingerprint = ''
134
+ this.lastRoundFingerprint = ''
135
+ this.idleStreak = 0
124
136
  this.clearTimer()
125
137
  this.pendingWake = false
126
138
  if (this.loopController) {
@@ -5,6 +5,7 @@
5
5
  import { SchedulerLoopState } from './state'
6
6
  import type { SupervisionSnapshot } from '../../agents/agent-interface'
7
7
  import { IDLE_TICK_CAP_MS, LEAD_DECISION_RETRY_MS, log } from './helpers'
8
+ import { isLegacyRecoveryHeld } from '../task-engine/legacy-recovery'
8
9
  import { TERMINAL_TASK_STATES } from '../../types/task'
9
10
  import { findModeTask } from '../execution-mode'
10
11
  import { isOrdinaryRoot } from '../task-engine/policy'
@@ -16,6 +17,7 @@ export abstract class SchedulerLoopTick extends SchedulerLoopState {
16
17
  /** 每个根被 HITL 顺延的次数(上限后恢复 ROOT_TIMEOUT,避免 hold 模式永久挂起) */
17
18
  protected hitlDeferrals = new Map<string, number>()
18
19
  protected async runRound(): Promise<void> {
20
+ const generation = this.lifecycleGeneration
19
21
  this.running = true
20
22
  try {
21
23
  // P1(2026-11-10 实测复现):过期收口此前在 tickRound 内(持 lead execLock)——
@@ -25,7 +27,8 @@ export abstract class SchedulerLoopTick extends SchedulerLoopState {
25
27
  // 本轮有收口动作则跳过监督回合(收口本身会触发任务事件唤醒下一轮)。
26
28
  const snapshot = this.collectSnapshot()
27
29
  if (await this.enforceRootDeadlines(snapshot)) return
28
- await this.lead.withExecLock(() => this.tickRound())
30
+ if (generation !== this.lifecycleGeneration) return
31
+ await this.lead.withExecLock(() => generation === this.lifecycleGeneration ? this.tickRound() : Promise.resolve())
29
32
  }
30
33
  catch (err) {
31
34
  log.error(`[SchedulerLoop:${this.lead.agentId}] 一轮调度失败:`, err)
@@ -60,8 +63,10 @@ export abstract class SchedulerLoopTick extends SchedulerLoopState {
60
63
  * 返回 true = 本轮有收口/顺延动作(调用方据此跳过监督回合)。
61
64
  */
62
65
  protected async enforceRootDeadlines(snapshot: SupervisionSnapshot): Promise<boolean> {
63
- const expiredRoots = snapshot.tasks.filter(task =>
64
- isOrdinaryRoot(task)
66
+ const generation = this.lifecycleGeneration
67
+ let expiredRoots = snapshot.tasks.filter(task =>
68
+ !isLegacyRecoveryHeld(task) && !this.legacyBlocked(task.id)
69
+ && isOrdinaryRoot(task)
65
70
  && !TERMINAL_TASK_STATES[task.state]
66
71
  && task.deadlineAt
67
72
  && Date.parse(task.deadlineAt) <= Date.now()
@@ -88,6 +93,19 @@ export abstract class SchedulerLoopTick extends SchedulerLoopState {
88
93
  }
89
94
  catch { return false }
90
95
  })()
96
+ if (generation !== this.lifecycleGeneration) return false
97
+ const engine = this.lead.taskEngine
98
+ if (typeof engine.listLite === 'function') {
99
+ const latest = engine.listLite(this.channelRuntime.channelId)
100
+ const byId = new Map(latest.map(task => [task.id, task]))
101
+ expiredRoots = expiredRoots.filter((root) => {
102
+ const current = byId.get(root.id)
103
+ return current && !this.legacyBlocked(root.id) && !isLegacyRecoveryHeld(current)
104
+ && current.state === root.state && current.deadlineAt === root.deadlineAt
105
+ && current.assignmentGeneration === root.assignmentGeneration && current.executionLeaseId === root.executionLeaseId
106
+ })
107
+ }
108
+ if (expiredRoots.length === 0) return false
91
109
  const MAX_HITL_DEFERRALS = 3
92
110
  const deferrable = hitlPending
93
111
  ? expiredRoots.filter(r => (this.hitlDeferrals.get(r.id) ?? 0) < MAX_HITL_DEFERRALS)
@@ -138,9 +156,39 @@ export abstract class SchedulerLoopTick extends SchedulerLoopState {
138
156
  return true
139
157
  }
140
158
 
159
+ /** Capture the root lease once so in-place snapshot changes cannot authorize an old turn. */
160
+ protected roundIsCurrent(snapshot: SupervisionSnapshot): () => boolean {
161
+ const generation = this.lifecycleGeneration
162
+ const rootId = snapshot.activeRootId
163
+ const root = rootId ? snapshot.tasks.find(task => task.id === rootId) : undefined
164
+ const rootChannelId = root?.channelId
165
+ const rootAssigneeId = root?.assigneeId
166
+ const leaseAgentId = root?.executionLeaseAgentId
167
+ const assignmentGeneration = root?.assignmentGeneration
168
+ const executionLeaseId = root?.executionLeaseId
169
+ const validSnapshot = !rootId || Boolean(root && !isLegacyRecoveryHeld(root) && rootChannelId === this.channelRuntime.channelId
170
+ && rootAssigneeId === this.lead.agentId && !TERMINAL_TASK_STATES[root.state]
171
+ && leaseAgentId === this.lead.agentId && !root.executionLeaseRevokedAt
172
+ && Number.isSafeInteger(assignmentGeneration) && (assignmentGeneration ?? -1) >= 0 && executionLeaseId)
173
+ return () => {
174
+ if (generation !== this.lifecycleGeneration || this.lead.getState?.() === 'stopped' || !validSnapshot) return false
175
+ if (!rootId) return !this.lead.taskEngine.hasLegacyRecoveryHold?.(this.channelRuntime.channelId)
176
+ const engine = this.lead.taskEngine
177
+ if (this.legacyBlocked(rootId)) return false
178
+ const current = engine.get(rootId)
179
+ return Boolean(current && !isLegacyRecoveryHeld(current) && current.channelId === rootChannelId && current.assigneeId === rootAssigneeId
180
+ && !TERMINAL_TASK_STATES[current.state] && !current.executionLeaseRevokedAt
181
+ && current.executionLeaseAgentId === leaseAgentId
182
+ && current.assignmentGeneration === assignmentGeneration && current.executionLeaseId === executionLeaseId)
183
+ }
184
+ }
185
+
141
186
  protected async tickRound(): Promise<void> {
142
187
  this.tick += 1
143
188
  const snapshot = this.collectSnapshot()
189
+ if (snapshot.activeRootId && this.legacyBlocked(snapshot.activeRootId)) return
190
+ const stillCurrent = this.roundIsCurrent(snapshot)
191
+ if (!stillCurrent()) return
144
192
  // 状态 Map 生命周期修剪:终态/已删任务的条目随轮清理(长会话内存有界)。
145
193
  // progressSeen 全程只增不减;notified/lastProgress/loopCompletedTaskIds 统一按任务集收敛。
146
194
  const liveIds = new Set(snapshot.tasks.map(t => t.id))
@@ -173,8 +221,9 @@ export abstract class SchedulerLoopTick extends SchedulerLoopState {
173
221
  // loop 模式:检测主任务完成 → 触发循环控制器
174
222
  this.checkLoopCompletion(snapshot)
175
223
 
176
- const decisions = await this.decide(snapshot)
224
+ const decisions = await this.decide(snapshot, stillCurrent)
177
225
  for (const decision of decisions) {
226
+ if (!stillCurrent()) break
178
227
  try {
179
228
  this.execute(decision)
180
229
  }
@@ -190,7 +239,7 @@ export abstract class SchedulerLoopTick extends SchedulerLoopState {
190
239
  */
191
240
  protected superviseFingerprint(snapshot: SupervisionSnapshot): string {
192
241
  const tasks = snapshot.tasks
193
- .map(t => `${t.id}:${t.state}`)
242
+ .map(t => `${t.id}:${t.state}:${t.assigneeId}:${t.assignmentGeneration ?? ''}:${t.executionLeaseId ?? ''}:${t.executionLeaseAgentId ?? ''}:${t.executionLeaseRevokedAt ?? ''}:${isLegacyRecoveryHeld(t)}`)
194
243
  .sort()
195
244
  .join('|')
196
245
  const members = snapshot.members
@@ -10,6 +10,7 @@ import { rowToTask } from './helpers'
10
10
  import { assertDispatchAllowed, rootLineage } from './policy'
11
11
  import { issueLeaseFields } from './lease'
12
12
  import { rootQueueEnabled } from '../../settings'
13
+ import { assertNotLegacyRecoveryHeld } from './legacy-recovery'
13
14
 
14
15
  export abstract class TaskEngineCreate extends TaskEngineUpdate {
15
16
  /** 创建任务(落库);若 parentId 存在且父任务 WORKING 则父转 WAITING */
@@ -34,6 +35,13 @@ export abstract class TaskEngineCreate extends TaskEngineUpdate {
34
35
  sessionId?: string | null
35
36
  traceId?: string
36
37
  }): WorkspaceTask {
38
+ if (input.parentId) {
39
+ assertNotLegacyRecoveryHeld(this.requireTask(input.parentId))
40
+ this.assertLegacyRecoveryAdmission(input.parentId)
41
+ }
42
+ else if (this.hasLegacyRecoveryHold(input.channelId)) {
43
+ throw new AppError(409, 'LEGACY_EXECUTION_RECOVERY_REQUIRED', `Channel ${input.channelId} requires operator investigation before creating a root task`)
44
+ }
37
45
  const row = this.repos.tasks.create({
38
46
  channelId: input.channelId,
39
47
  parentId: input.parentId ?? null,
@@ -88,6 +96,9 @@ export abstract class TaskEngineCreate extends TaskEngineUpdate {
88
96
  sessionId?: string | null
89
97
  traceId?: string
90
98
  }): { task: WorkspaceTask, created: boolean } {
99
+ if (this.hasLegacyRecoveryHold(input.channelId)) {
100
+ throw new AppError(409, 'LEGACY_EXECUTION_RECOVERY_REQUIRED', `Channel ${input.channelId} requires operator investigation before creating a root task`)
101
+ }
91
102
  const result = this.repos.tasks.createOrGetRoot({
92
103
  channelId: input.channelId,
93
104
  creatorId: input.creatorId,
@@ -118,6 +129,11 @@ export abstract class TaskEngineCreate extends TaskEngineUpdate {
118
129
  parent: WorkspaceTask,
119
130
  input: { assigneeId: string, title: string, description?: string, parts?: Part[], routeReason?: string },
120
131
  ): WorkspaceTask {
132
+ // TaskEngine is the common dispatch boundary for recovery holds.
133
+ assertNotLegacyRecoveryHeld(this.requireTask(parent.id))
134
+ if (this.isLegacyRecoveryBlocked(parent.id)) {
135
+ throw new AppError(409, 'LEGACY_EXECUTION_RECOVERY_REQUIRED', `Task ${parent.id} is blocked by an earlier recovery hold`)
136
+ }
121
137
  // TaskEngine 是所有派发入口的最终预算闸门;Manager/host tool 的提示不能替代它。
122
138
  assertDispatchAllowed(this.repos.tasks, parent)
123
139
  // 2026-10-30 修复(引擎直调路径的状态前置):manager.dispatchTask 有「终态先拒 +
@@ -94,6 +94,11 @@ export function rowToTaskLite(row: TaskMetaRow): WorkspaceTask {
94
94
  sessionId: row.sessionId ?? undefined,
95
95
  traceId: row.traceId || undefined,
96
96
  supersededByTaskId: row.supersededByTaskId || undefined,
97
+ assignmentGeneration: row.assignmentGeneration ?? 0,
98
+ executionLeaseId: row.executionLeaseId || undefined,
99
+ executionLeaseAgentId: row.executionLeaseAgentId || undefined,
100
+ executionLeaseStartedAt: row.executionLeaseStartedAt || undefined,
101
+ executionLeaseRevokedAt: row.executionLeaseRevokedAt || undefined,
97
102
  createdAt: row.createdAt,
98
103
  updatedAt: row.updatedAt,
99
104
  }
@@ -0,0 +1,149 @@
1
+ import type { DatabaseSync } from 'node:sqlite'
2
+ import { AppError } from '../../../../utils/errors'
3
+ import { fenceFromMetadata } from './lease'
4
+
5
+ export const LEGACY_RECOVERY_MARKER = '[LEGACY_EXECUTION_RECOVERY_REQUIRED]'
6
+
7
+ export function isLegacyRecoveryHeld(task: { closeReason?: string | null }): boolean {
8
+ return (task.closeReason ?? '').includes(LEGACY_RECOVERY_MARKER)
9
+ }
10
+
11
+ export function assertNotLegacyRecoveryHeld(task: { id: string, closeReason?: string | null }): void {
12
+ if (isLegacyRecoveryHeld(task)) {
13
+ throw new AppError(409, 'LEGACY_EXECUTION_RECOVERY_REQUIRED', `Task ${task.id} requires operator investigation; execution was not replayed`)
14
+ }
15
+ }
16
+
17
+ interface RecoveryTask {
18
+ id: string
19
+ parentId: string | null
20
+ rootQueueSeq: number | null
21
+ closeReason: string | null
22
+ }
23
+
24
+ /** Channel-local FIFO check; malformed ancestry or ordering fails closed when a hold exists. */
25
+ export function isChannelRecoveryBlocked(taskId: string, rows: RecoveryTask[]): boolean {
26
+ const held = rows.filter(isLegacyRecoveryHeld)
27
+ if (held.length === 0) return false
28
+ const byId = new Map(rows.map(row => [row.id, row]))
29
+ const rootOf = (id: string): RecoveryTask | undefined => {
30
+ const seen = new Set<string>()
31
+ let current = byId.get(id)
32
+ while (current?.parentId) {
33
+ if (seen.has(current.id)) return undefined
34
+ seen.add(current.id)
35
+ current = byId.get(current.parentId)
36
+ }
37
+ return current
38
+ }
39
+ const root = rootOf(taskId)
40
+ if (!root) return true
41
+ for (const row of held) {
42
+ const heldRoot = rootOf(row.id)
43
+ if (!heldRoot || heldRoot.id === root.id) return true
44
+ if (root.rootQueueSeq == null || heldRoot.rootQueueSeq == null || root.rootQueueSeq >= heldRoot.rootQueueSeq) return true
45
+ }
46
+ return false
47
+ }
48
+
49
+ interface ActiveTask {
50
+ id: string
51
+ channelId: string
52
+ assigneeId: string
53
+ generation: number | null
54
+ leaseId: string | null
55
+ leaseAgentId: string | null
56
+ revokedAt: string | null
57
+ }
58
+
59
+ interface PendingMessage {
60
+ taskId: string | null
61
+ channelId: string
62
+ toAgentId: string | null
63
+ metadataJson: string
64
+ }
65
+
66
+ /** Called before project or channel runtimes start. Never issue a lease or replay work. */
67
+ export function holdLegacyActiveTasks(db: DatabaseSync): void {
68
+ db.exec('SAVEPOINT legacy_execution_recovery')
69
+ try {
70
+ const active = db.prepare(`SELECT id, channel_id AS channelId, assignee_id AS assigneeId,
71
+ assignment_generation AS generation, execution_lease_id AS leaseId,
72
+ execution_lease_agent_id AS leaseAgentId, execution_lease_revoked_at AS revokedAt
73
+ FROM tasks WHERE state IN ('SUBMITTED', 'ASSIGNED', 'WORKING', 'WAITING')`).all() as unknown as ActiveTask[]
74
+ const byId = new Map(active.map(task => [task.id, task]))
75
+ const suspect = new Set(active.filter(task => !task.leaseId?.trim()
76
+ || task.leaseAgentId !== task.assigneeId || !!task.revokedAt
77
+ || !Number.isSafeInteger(task.generation) || (task.generation ?? -1) < 0).map(task => task.id))
78
+
79
+ const messages = db.prepare(`SELECT task_id AS taskId, channel_id AS channelId,
80
+ to_agent_id AS toAgentId, metadata_json AS metadataJson FROM messages
81
+ WHERE state IN ('pending', 'consuming') AND CASE WHEN json_valid(metadata_json)
82
+ THEN json_type(metadata_json) <> 'object' AND task_id IS NOT NULL
83
+ OR json_extract(metadata_json, '$."x-aw-task-kind"') = 'assign'
84
+ ELSE task_id IS NOT NULL END`)
85
+ for (const message of messages.iterate() as unknown as Iterable<PendingMessage>) {
86
+ let metadata: Record<string, unknown>
87
+ try {
88
+ const value: unknown = JSON.parse(message.metadataJson)
89
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
90
+ if (message.taskId && byId.has(message.taskId)) suspect.add(message.taskId)
91
+ continue
92
+ }
93
+ metadata = value as Record<string, unknown>
94
+ }
95
+ catch {
96
+ if (message.taskId && byId.has(message.taskId)) suspect.add(message.taskId)
97
+ continue
98
+ }
99
+ if (metadata['x-aw-task-kind'] !== 'assign') continue
100
+ const metadataId = typeof metadata['x-aw-task-id'] === 'string' ? metadata['x-aw-task-id'] : null
101
+ const fence = fenceFromMetadata(metadata)
102
+ for (const id of new Set([message.taskId, metadataId])) {
103
+ const task = id ? byId.get(id) : undefined
104
+ if (!task) continue
105
+ if ((message.taskId && message.taskId !== task.id) || (metadataId && metadataId !== task.id)
106
+ || message.channelId !== task.channelId || message.toAgentId !== task.assigneeId
107
+ || !Number.isSafeInteger(fence?.generation) || (fence?.generation ?? -1) < 0
108
+ || fence?.generation !== task.generation || !fence?.leaseId || fence.leaseId !== task.leaseId) {
109
+ suspect.add(task.id)
110
+ }
111
+ }
112
+ }
113
+
114
+ const mark = db.prepare(`UPDATE tasks SET close_reason = CASE
115
+ WHEN COALESCE(close_reason, '') = '' THEN ?
116
+ ELSE close_reason || ' ' || ? END
117
+ WHERE id = ? AND instr(COALESCE(close_reason, ''), ?) = 0`)
118
+ for (const id of suspect) mark.run(LEGACY_RECOVERY_MARKER, LEGACY_RECOVERY_MARKER, id, LEGACY_RECOVERY_MARKER)
119
+
120
+ // UNION terminates even on malformed cycles and retains holds from prior startups.
121
+ db.prepare(`WITH RECURSIVE held(id) AS (
122
+ SELECT id FROM tasks WHERE instr(COALESCE(close_reason, ''), ?) > 0
123
+ UNION SELECT t.parent_id FROM tasks t JOIN held h ON t.id = h.id WHERE t.parent_id IS NOT NULL
124
+ UNION SELECT t.id FROM tasks t JOIN held h ON t.parent_id = h.id
125
+ ) UPDATE tasks SET close_reason = CASE
126
+ WHEN COALESCE(close_reason, '') = '' THEN ? ELSE close_reason || ' ' || ? END
127
+ WHERE id IN (SELECT id FROM held) AND instr(COALESCE(close_reason, ''), ?) = 0`)
128
+ .run(LEGACY_RECOVERY_MARKER, LEGACY_RECOVERY_MARKER, LEGACY_RECOVERY_MARKER, LEGACY_RECOVERY_MARKER)
129
+
130
+ // Preserve normal task-linked chat; malformed or non-object metadata cannot be
131
+ // classified, so retain the raw row as dead-letter evidence instead of replaying it.
132
+ db.prepare(`UPDATE messages SET state = 'dead', claim_token = NULL
133
+ WHERE state IN ('pending', 'consuming') AND CASE WHEN json_valid(messages.metadata_json)
134
+ THEN json_type(messages.metadata_json) <> 'object'
135
+ OR json_type(messages.metadata_json, '$."x-aw-task-kind"') IS NOT NULL ELSE 1 END
136
+ AND EXISTS (
137
+ SELECT 1 FROM tasks t
138
+ WHERE instr(COALESCE(t.close_reason, ''), ?) > 0
139
+ AND (messages.task_id = t.id OR CASE WHEN json_valid(messages.metadata_json)
140
+ THEN json_extract(messages.metadata_json, '$."x-aw-task-id"') = t.id
141
+ OR json_extract(messages.metadata_json, '$."x-aw-child-task-id"') = t.id ELSE 0 END)
142
+ )`).run(LEGACY_RECOVERY_MARKER)
143
+ db.exec('RELEASE legacy_execution_recovery')
144
+ }
145
+ catch (error) {
146
+ db.exec('ROLLBACK TO legacy_execution_recovery; RELEASE legacy_execution_recovery')
147
+ throw error
148
+ }
149
+ }
@@ -13,6 +13,7 @@ import type { ExecutionFence } from './lease'
13
13
  import { fenceMatches, issueLeaseFields } from './lease'
14
14
  import type { TaskPatch } from '../../db/task.repo'
15
15
  import type { TaskRow } from '../../db/database'
16
+ import { assertNotLegacyRecoveryHeld, isLegacyRecoveryHeld } from './legacy-recovery'
16
17
 
17
18
  export abstract class TaskEngineLifecycle extends TaskEngineTransition {
18
19
  /** 完成任务:WORKING → COMPLETED(终态)+ 进度置 100(广播由上层 ChannelBus 监听 onTaskEvent 承担);
@@ -25,6 +26,8 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
25
26
  * 经 supersede 显式处置后方可收口。 */
26
27
  complete(taskId: string, artifacts?: A2AArtifact[]): WorkspaceTask {
27
28
  const task = this.requireTask(taskId)
29
+ assertNotLegacyRecoveryHeld(task)
30
+ this.assertLegacyRecoveryAdmission(taskId)
28
31
  if (task.state === 'COMPLETED') return task
29
32
  if (task.state === 'CANCELED' || task.state === 'FAILED') {
30
33
  throw new AppError(409, 'TASK_TERMINAL', `任务 ${taskId.slice(0, 8)} 已处于终态 ${task.state},不能再完成`)
@@ -109,6 +112,8 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
109
112
  */
110
113
  reassign(taskId: string, toAgentId: string, reason?: string): WorkspaceTask {
111
114
  const task = this.requireTask(taskId)
115
+ assertNotLegacyRecoveryHeld(task)
116
+ this.assertLegacyRecoveryAdmission(taskId)
112
117
  if (task.state === 'COMPLETED' || task.state === 'CANCELED') {
113
118
  throw new AppError(400, 'INVALID_STATE', `终态任务不可重新指派(${task.state})`)
114
119
  }
@@ -173,6 +178,8 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
173
178
  */
174
179
  reassignRunning(taskId: string, toAgentId: string, by: string, reason?: string): { task: WorkspaceTask, previousAssigneeId: string } {
175
180
  const task = this.requireTask(taskId)
181
+ assertNotLegacyRecoveryHeld(task)
182
+ this.assertLegacyRecoveryAdmission(taskId)
176
183
  if (task.state !== 'WORKING' && task.state !== 'WAITING') {
177
184
  throw new AppError(400, 'INVALID_STATE', `仅运行中任务可执行运行中重分配(当前 ${task.state})`)
178
185
  }
@@ -215,7 +222,7 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
215
222
  */
216
223
  assertAssignmentFence(taskId: string, fence?: ExecutionFence): boolean {
217
224
  const row = this.repos.tasks.findById(taskId)
218
- if (!row) return false
225
+ if (!row || isLegacyRecoveryHeld(row) || this.isLegacyRecoveryBlocked(taskId)) return false
219
226
  return fenceMatches(rowToTask(row), fence)
220
227
  }
221
228
 
@@ -232,6 +239,7 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
232
239
  /** 取消任务:CANCELED(终态)+ 作废队列中的过期投递(assignee 不再消费)+ 投递 cancel 通知 */
233
240
  cancel(taskId: string, by: string, reason = 'LEAD_CANCEL'): WorkspaceTask {
234
241
  const task = this.requireTask(taskId)
242
+ assertNotLegacyRecoveryHeld(task)
235
243
  if (task.state === 'CANCELED') return task
236
244
  if (task.state === 'COMPLETED' || task.state === 'FAILED') {
237
245
  throw new AppError(409, 'TASK_TERMINAL', `任务 ${taskId.slice(0, 8)} 已处于终态 ${task.state},不能取消`)
@@ -259,6 +267,7 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
259
267
  */
260
268
  supersede(taskId: string, replacementTaskId: string, by: string, reason?: string): WorkspaceTask {
261
269
  const task = this.requireTask(taskId)
270
+ assertNotLegacyRecoveryHeld(task)
262
271
  if (!task.parentId) {
263
272
  throw new AppError(400, 'INVALID_STATE', '仅子任务分支可被替代(根任务请走取消/失败语义)')
264
273
  }
@@ -269,6 +278,7 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
269
278
  throw new AppError(400, 'INVALID_STATE', '任务不能被自身替代')
270
279
  }
271
280
  const replacement = this.requireTask(replacementTaskId)
281
+ assertNotLegacyRecoveryHeld(replacement)
272
282
  if ((replacement.parentId ?? null) !== (task.parentId ?? null)) {
273
283
  throw new AppError(400, 'INVALID_STATE', '替代任务必须与被替代任务同属一个父任务')
274
284
  }
@@ -290,6 +300,19 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
290
300
  /** 普通根任务超时:活动后代取消,根任务以 FAILED 保留明确超时语义。 */
291
301
  timeoutTree(taskId: string, by: string): WorkspaceTask[] {
292
302
  const root = this.requireTask(taskId)
303
+ if (this.isLegacyRecoveryBlocked(taskId)) return []
304
+ const descendants = this.repos.tasks.listByChannel(root.channelId)
305
+ const held = new Set(descendants.filter(isLegacyRecoveryHeld).map(row => row.id))
306
+ const parents = new Map(descendants.map(row => [row.id, row.parentId]))
307
+ for (const id of held) {
308
+ let current: string | null | undefined = id
309
+ const visited = new Set<string>()
310
+ while (current && !visited.has(current)) {
311
+ if (current === root.id) return []
312
+ visited.add(current)
313
+ current = parents.get(current)
314
+ }
315
+ }
293
316
  const children = this.cancelTreeChildren(root.id, root.channelId, by, 'ROOT_TIMEOUT')
294
317
  const latest = this.get(root.id)
295
318
  if (latest && latest.state !== 'COMPLETED' && latest.state !== 'FAILED' && latest.state !== 'CANCELED') {
@@ -324,6 +347,18 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
324
347
  /** 取消整棵任务树:后代优先,已终态结果保留。 */
325
348
  cancelTree(taskId: string, by: string, reason = 'LEAD_CANCEL'): WorkspaceTask[] {
326
349
  const root = this.requireTask(taskId)
350
+ assertNotLegacyRecoveryHeld(root)
351
+ const rows = this.repos.tasks.listByChannel(root.channelId)
352
+ const parents = new Map(rows.map(row => [row.id, row.parentId]))
353
+ for (const row of rows.filter(isLegacyRecoveryHeld)) {
354
+ let current: string | null | undefined = row.id
355
+ const visited = new Set<string>()
356
+ while (current && !visited.has(current)) {
357
+ if (current === root.id) assertNotLegacyRecoveryHeld(row)
358
+ visited.add(current)
359
+ current = parents.get(current)
360
+ }
361
+ }
327
362
  const canceled = this.cancelTreeChildren(root.id, root.channelId, by, reason)
328
363
  const current = this.get(root.id)
329
364
  if (current && current.state !== 'COMPLETED' && current.state !== 'FAILED' && current.state !== 'CANCELED') {
@@ -341,6 +376,7 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
341
376
  if (!parentId) return
342
377
  const parent = this.get(parentId)
343
378
  if (!parent || parent.state === 'COMPLETED' || parent.state === 'FAILED' || parent.state === 'CANCELED') return
379
+ if (isLegacyRecoveryHeld(parent)) return
344
380
  this.deliverTaskMessage({
345
381
  channelId: child.channelId,
346
382
  taskId: parent.id,
@@ -365,6 +401,7 @@ export abstract class TaskEngineLifecycle extends TaskEngineTransition {
365
401
  protected onChildResolved(parentId: string, channelId: string, by: string): void {
366
402
  const parent = this.get(parentId)
367
403
  if (!parent || parent.state !== 'WAITING') return
404
+ if (isLegacyRecoveryHeld(parent)) return
368
405
  const siblings = this.repos.tasks.listChildrenMeta(channelId, parentId)
369
406
  const incomplete = siblings.filter(t => t.state !== 'COMPLETED' && t.state !== 'FAILED' && t.state !== 'CANCELED' && !t.supersededByTaskId)
370
407
  if (incomplete.length === 0) this.transition(parentId, 'WORKING', by)
@@ -12,12 +12,15 @@ import { TERMINAL_TASK_STATES } from '../../types/task'
12
12
  import { deriveProgressMap } from './derived-progress'
13
13
  import type { ExecutionFence } from './lease'
14
14
  import { fenceMatches } from './lease'
15
+ import { assertNotLegacyRecoveryHeld, isLegacyRecoveryHeld } from './legacy-recovery'
15
16
 
16
17
  export abstract class TaskEngineTransition extends TaskEngineCreate {
17
18
  /** 状态机校验迁移;非法迁移抛 AppError('INVALID_TRANSITION', 400);成功后广播任务事件 */
18
19
  transition(taskId: string, state: TaskState, by: string): WorkspaceTask {
19
20
  const row = this.repos.tasks.findById(taskId)
20
21
  if (!row) throw new AppError(404, 'NOT_FOUND', `任务不存在: ${taskId}`)
22
+ assertNotLegacyRecoveryHeld(row)
23
+ if (state === 'WORKING' || state === 'ASSIGNED') this.assertLegacyRecoveryAdmission(taskId)
21
24
  const current = row.state as TaskState
22
25
  // D3 幂等迁移:重复派发/重复汇总会再次请求 WORKING → WORKING(TRANSITIONS 不含自迁移)。
23
26
  // 作为 no-op 返回当前任务:不广播、不刷新租约;终态自迁移(如重复 COMPLETED)
@@ -62,6 +65,7 @@ export abstract class TaskEngineTransition extends TaskEngineCreate {
62
65
  /** 应用 Agent 事件:artifact(分块 append/进度折算)、status(追加 history)、error(FAILED)、done(无) */
63
66
  applyEvent(taskId: string, event: AgentEvent, fence?: ExecutionFence): void {
64
67
  const task = this.requireTask(taskId)
68
+ if (isLegacyRecoveryHeld(task) || this.isLegacyRecoveryBlocked(taskId)) return
65
69
  // §5.1 执行代次栅栏:携带 generation/lease 的事件必须与任务当前 assignment 一致,
66
70
  // 否则是「旧 worker 的迟到事件」——在运行中 reassign 之后绝不允许它写入新执行的结果。
67
71
  if (!fenceMatches(task, fence)) {
@@ -10,6 +10,7 @@ import { TERMINAL_TASK_STATES } from '../../types/task'
10
10
  import { randomUUID } from 'node:crypto'
11
11
  import { rowToTask } from './helpers'
12
12
  import { fenceToMetadata } from './lease'
13
+ import { assertNotLegacyRecoveryHeld } from './legacy-recovery'
13
14
 
14
15
  export abstract class TaskEngineUpdate extends TaskEngineViews {
15
16
  /**
@@ -23,6 +24,8 @@ export abstract class TaskEngineUpdate extends TaskEngineViews {
23
24
  by: string,
24
25
  ): WorkspaceTask {
25
26
  const task = this.requireTask(taskId)
27
+ assertNotLegacyRecoveryHeld(task)
28
+ this.assertLegacyRecoveryAdmission(taskId)
26
29
  if (task.state !== 'SUBMITTED' && task.state !== 'ASSIGNED') {
27
30
  throw new AppError(400, 'INVALID_STATE', `仅待执行任务可修改(${task.state} 不可改)`)
28
31
  }
@@ -55,6 +58,7 @@ export abstract class TaskEngineUpdate extends TaskEngineViews {
55
58
  */
56
59
  refreshDeadline(taskId: string, deadlineAt: string): WorkspaceTask {
57
60
  const task = this.requireTask(taskId)
61
+ assertNotLegacyRecoveryHeld(task)
58
62
  const updated = this.repos.tasks.update(taskId, { deadlineAt })
59
63
  return updated ? rowToTask(updated) : task
60
64
  }
@@ -65,6 +69,8 @@ export abstract class TaskEngineUpdate extends TaskEngineViews {
65
69
  */
66
70
  redeliverAssign(taskId: string): WorkspaceTask {
67
71
  const task = this.requireTask(taskId)
72
+ assertNotLegacyRecoveryHeld(task)
73
+ this.assertLegacyRecoveryAdmission(taskId)
68
74
  if (TERMINAL_TASK_STATES[task.state]) {
69
75
  throw new AppError(400, 'INVALID_STATE', `终态任务不可重投(${task.state})`)
70
76
  }
@@ -8,6 +8,9 @@ import type { AgentTaskQueueView, RootQueueView, TaskState, WorkspaceTask } from
8
8
  import type { MessageRepo } from '../../db/message.repo'
9
9
  import type { TaskRepo } from '../../db/task.repo'
10
10
  import { rowToTask, rowToTaskLite } from './helpers'
11
+ import { isChannelRecoveryBlocked, isLegacyRecoveryHeld, LEGACY_RECOVERY_MARKER } from './legacy-recovery'
12
+ import { AppError } from '../../../../utils/errors'
13
+ import { audit } from '../../ops/ops'
11
14
 
12
15
  export abstract class TaskEngineViews extends TaskEngineContracts {
13
16
  /**
@@ -54,6 +57,64 @@ export abstract class TaskEngineViews extends TaskEngineContracts {
54
57
  }
55
58
  }
56
59
 
60
+ /** A hold is durable until an explicit operator disposition; terminal nodes count too. */
61
+ hasLegacyRecoveryHold(channelId: string): boolean {
62
+ return this.repos.tasks.listByChannelMeta(channelId).some(isLegacyRecoveryHeld)
63
+ }
64
+
65
+ /** Held trees and roots behind a held root cannot enter execution. */
66
+ isLegacyRecoveryBlocked(taskId: string): boolean {
67
+ const task = this.repos.tasks.findById(taskId)
68
+ if (!task) return true
69
+ const rows = this.repos.tasks.listByChannelMeta(task.channelId)
70
+ if (isChannelRecoveryBlocked(taskId, rows)) return true
71
+ return this.repos.tasks.projectRecoveryBlocked?.(taskId) ?? false
72
+ }
73
+
74
+ /** 运维面:当前全部恢复保留任务(含树内消息计数,供处置前调查)。 */
75
+ listLegacyRecoveryHolds(): Array<{ taskId: string, channelId: string, assigneeId: string, title: string, state: string, closeReason: string, createdAt: string, messages: { pending: number, consuming: number, dead: number } }> {
76
+ return this.repos.tasks.listRecoveryHolds(LEGACY_RECOVERY_MARKER).map((row) => {
77
+ const counts = this.repos.tasks.recoveryHoldMessageCounts(row.id)
78
+ return {
79
+ taskId: row.id, channelId: row.channelId, assigneeId: row.assigneeId,
80
+ title: row.title, state: row.state, closeReason: row.closeReason ?? '',
81
+ createdAt: row.createdAt, messages: counts,
82
+ }
83
+ })
84
+ }
85
+
86
+ /**
87
+ * 运维面:显式处置(释放)恢复保留。只清 marker + 复位在飞消息投递预算,
88
+ * 不自动重放任何执行 —— 重新执行必须由操作员走显式 retry/reopen。
89
+ * 全程写审计;失败静默的 audit() 不影响处置主路径。
90
+ */
91
+ disposeLegacyRecoveryHold(taskId: string, actor: { id: string, name?: string }, note?: string): { released: string[], requeued: number, unblockedPending: number } {
92
+ const result = this.repos.tasks.disposeLegacyRecoveryHold(taskId, LEGACY_RECOVERY_MARKER)
93
+ if (!result) {
94
+ const task = this.repos.tasks.findById(taskId)
95
+ if (!task) throw new AppError(404, 'NOT_FOUND', `任务不存在: ${taskId}`)
96
+ throw new AppError(409, 'NOT_HELD', `任务 ${taskId} 不在 legacy 恢复保留中`)
97
+ }
98
+ audit({
99
+ actor: actor.id,
100
+ actorName: actor.name ?? '',
101
+ actorKind: 'user',
102
+ action: 'task.recovery_disposition',
103
+ targetKind: 'task',
104
+ targetId: taskId,
105
+ detail: { released: result.released, requeued: result.requeued, unblockedPending: result.unblockedPending, note: note ?? '' },
106
+ summary: `释放 legacy 恢复保留:${result.released.length} 个任务,复位 ${result.requeued} 条在飞消息(待投 ${result.unblockedPending})`,
107
+ level: 'warn',
108
+ })
109
+ return result
110
+ }
111
+
112
+ protected assertLegacyRecoveryAdmission(taskId: string): void {
113
+ if (this.isLegacyRecoveryBlocked(taskId)) {
114
+ throw new AppError(409, 'LEGACY_EXECUTION_RECOVERY_REQUIRED', `Task ${taskId} requires operator investigation; execution was not replayed`)
115
+ }
116
+ }
117
+
57
118
  /** FIFO root queue: only the oldest non-terminal root is active. */
58
119
  rootQueue(channelId: string): { activeRoot: WorkspaceTask | null, queuedRoots: WorkspaceTask[], completedRoots: WorkspaceTask[] } {
59
120
  const roots = this.repos.tasks.listRoots(channelId).map(rowToTask)