agentworkshop 0.11.3 → 0.12.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 (440) 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/577f464e-672a-4c4e-a3c8-dc8c1b38930d.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 +4070 -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 +7 -7
  338. package/README.md +7 -7
  339. package/app/components/dcw/DcwNodesTable.vue +24 -0
  340. package/docs/mcp.en.md +30 -27
  341. package/docs/mcp.md +7 -3
  342. package/docs/plugins.en.md +4 -2
  343. package/docs/plugins.md +4 -2
  344. package/i18n/dicts/dcwDetail.json +221 -219
  345. package/i18n/locales/en.ts +2 -0
  346. package/i18n/locales/zh-CN.ts +2 -0
  347. package/package.json +2 -1
  348. package/scripts/check-docs-sync.mjs +20 -9
  349. package/scripts/onboarding/forge-channel.mjs +2 -1
  350. package/scripts/onboarding/lib.mjs +159 -3
  351. package/scripts/onboarding/onboard.mjs +2 -0
  352. package/scripts/onboarding/preflight.mjs +233 -231
  353. package/scripts/onboarding/provision-line.mjs +12 -2
  354. package/scripts/onboarding/sim-attest.mjs +103 -0
  355. package/scripts/onboarding/sim-twin.mjs +88 -4
  356. package/scripts/onboarding/test-connection.mjs +2 -1
  357. package/scripts/onboarding/v6-protected-api.mjs +41 -0
  358. package/scripts/onboarding/v6-protected-fixture.mjs +54 -0
  359. package/scripts/onboarding/verify-line.mjs +179 -136
  360. package/scripts/onboarding/verify-mirror.mjs +149 -145
  361. package/server/api/workshop/agent-tools/list.get.ts +10 -1
  362. package/server/api/workshop/tasks/[id]/recovery-disposition.post.ts +32 -0
  363. package/server/api/workshop/tasks/recovery-holds.get.ts +22 -0
  364. package/server/plugins-builtin/rag-bridge/index.mjs +20 -2
  365. package/server/services/workshop/agents/agent-interface.ts +3 -0
  366. package/server/services/workshop/agents/base-agent.ts +100 -4
  367. package/server/services/workshop/agents/execution-scope.ts +26 -0
  368. package/server/services/workshop/agents/hitl-capabilities.ts +3 -3
  369. package/server/services/workshop/agents/host-tool-bridge/dispatch.ts +42 -2
  370. package/server/services/workshop/agents/host-tool-bridge/tools/progress.ts +4 -0
  371. package/server/services/workshop/agents/host-tool-bridge/tools/tasks.ts +11 -28
  372. package/server/services/workshop/agents/host-tool-bridge/tools/team-delegation.ts +83 -129
  373. package/server/services/workshop/agents/industrial/dcw-tools.ts +27 -5
  374. package/server/services/workshop/agents/industrial/line-tools.ts +15 -4
  375. package/server/services/workshop/agents/industrial/ops-tools.ts +32 -6
  376. package/server/services/workshop/agents/industrial/optimization-tools.ts +16 -3
  377. package/server/services/workshop/agents/industrial/recipe-propose-tools.ts +26 -3
  378. package/server/services/workshop/agents/omp-agent/client.ts +2 -4
  379. package/server/services/workshop/agents/omp-agent/core.ts +3 -0
  380. package/server/services/workshop/agents/omp-agent/lifecycle.ts +70 -4
  381. package/server/services/workshop/agents/omp-agent/supervision-decision.ts +3 -1
  382. package/server/services/workshop/agents/omp-agent/tools-steer.ts +113 -32
  383. package/server/services/workshop/agents/tool-approvals.ts +113 -29
  384. package/server/services/workshop/agents/tool-classes.ts +72 -56
  385. package/server/services/workshop/db/database/open.ts +5 -2
  386. package/server/services/workshop/db/database/schema.ts +1 -0
  387. package/server/services/workshop/db/database/seed.ts +2 -2
  388. package/server/services/workshop/db/message.repo.ts +134 -26
  389. package/server/services/workshop/db/project-kernel.repo.ts +3 -3
  390. package/server/services/workshop/db/schema.sql +3 -1
  391. package/server/services/workshop/db/task.repo.ts +101 -0
  392. package/server/services/workshop/dcw/dcw-controller/actuation.ts +120 -9
  393. package/server/services/workshop/dcw/dcw-controller/contracts.ts +18 -16
  394. package/server/services/workshop/dcw/dcw-controller/crud.ts +23 -0
  395. package/server/services/workshop/dcw/dcw-controller/lines.ts +34 -2
  396. package/server/services/workshop/dcw/dcw-controller/recipes.ts +80 -6
  397. package/server/services/workshop/dcw/dcw-controller/state.ts +89 -88
  398. package/server/services/workshop/dcw/dcw-controller/types.ts +5 -0
  399. package/server/services/workshop/dcw/dcw-controller/write.ts +9 -6
  400. package/server/services/workshop/dcw/dcw-line.repo.ts +2 -0
  401. package/server/services/workshop/dcw/dcw-node.repo.ts +3 -1
  402. package/server/services/workshop/dcw/dcw-node.ts +346 -307
  403. package/server/services/workshop/dcw/dcw-runtime.ts +8 -4
  404. package/server/services/workshop/projects/effects.ts +47 -29
  405. package/server/services/workshop/projects/kernel.ts +8 -1
  406. package/server/services/workshop/projects/legacy-recovery.ts +36 -0
  407. package/server/services/workshop/projects/service.ts +15 -0
  408. package/server/services/workshop/runtime/agent-runtime/contracts.ts +1 -1
  409. package/server/services/workshop/runtime/agent-runtime/lifecycle.ts +7 -2
  410. package/server/services/workshop/runtime/agent-runtime/message-watchdog.ts +40 -0
  411. package/server/services/workshop/runtime/agent-runtime/message.ts +151 -21
  412. package/server/services/workshop/runtime/agent-runtime/state.ts +69 -13
  413. package/server/services/workshop/runtime/agent-runtime/supervise.ts +219 -42
  414. package/server/services/workshop/runtime/agent-runtime/types.ts +6 -0
  415. package/server/services/workshop/runtime/mailbox.ts +112 -21
  416. package/server/services/workshop/runtime/manager/admin-channel.ts +34 -22
  417. package/server/services/workshop/runtime/manager/host-tools.ts +18 -5
  418. package/server/services/workshop/runtime/manager/runtime-wiring.ts +101 -41
  419. package/server/services/workshop/runtime/manager/schedules.ts +3 -1
  420. package/server/services/workshop/runtime/manager/tasks.ts +41 -0
  421. package/server/services/workshop/runtime/memory/recall.ts +11 -4
  422. package/server/services/workshop/runtime/memory/types.ts +2 -0
  423. package/server/services/workshop/runtime/scheduler-loop/contracts.ts +29 -29
  424. package/server/services/workshop/runtime/scheduler-loop/execute.ts +7 -0
  425. package/server/services/workshop/runtime/scheduler-loop/rules.ts +3 -0
  426. package/server/services/workshop/runtime/scheduler-loop/snapshot.ts +10 -2
  427. package/server/services/workshop/runtime/scheduler-loop/state.ts +12 -0
  428. package/server/services/workshop/runtime/scheduler-loop/tick.ts +54 -5
  429. package/server/services/workshop/runtime/task-engine/create.ts +16 -0
  430. package/server/services/workshop/runtime/task-engine/helpers.ts +5 -0
  431. package/server/services/workshop/runtime/task-engine/legacy-recovery.ts +149 -0
  432. package/server/services/workshop/runtime/task-engine/lifecycle.ts +38 -1
  433. package/server/services/workshop/runtime/task-engine/transition.ts +4 -0
  434. package/server/services/workshop/runtime/task-engine/update.ts +6 -0
  435. package/server/services/workshop/runtime/task-engine/views.ts +61 -0
  436. package/shared/dcw-protocol/line.ts +4 -0
  437. package/.output/public/_nuxt/C8QlHux5.js +0 -1
  438. package/.output/public/_nuxt/_id_.0EnzA0aA.css +0 -1
  439. package/.output/public/_nuxt/builds/meta/846b9c03-1442-4fcb-b3fc-1d9484eaa41b.json +0 -1
  440. package/.output/server/chunks/build/_id_-C0vNEbts.mjs.map +0 -1
@@ -7,11 +7,80 @@ import type { AgentRunContext, SupervisionDecision, SupervisionSnapshot } from '
7
7
  import { randomUUID } from 'node:crypto'
8
8
  import type { WorkspaceTask } from '../../types/task'
9
9
  import { log } from './helpers'
10
+ import { MESSAGE_WATCHDOG_TICK_MS, shouldFireMessageWatchdog } from './message-watchdog'
10
11
  import { superviseWatchdogOnly, workshopSettings } from '../../settings'
12
+ import { TERMINAL_TASK_STATES } from '../../types/task'
13
+ import type { ExecutionScope } from '../../agents/execution-scope'
11
14
 
12
15
  export abstract class AgentRuntimeSupervise extends AgentRuntimeLifecycle {
16
+ /** 当前消息看门狗的活动上报句柄(processMessage 事件循环逐事件调用;回合外为 null) */
17
+ protected messageWatchdogBump: (() => void) | null = null
18
+
19
+ /** 事件驱动的活动上报:任何 harness 事件(delta/工具调用/状态)都视为"回合活着" */
20
+ protected bumpMessageActivity(): void {
21
+ this.messageWatchdogBump?.()
22
+ }
23
+
24
+ /** 看门狗单次巡检(async:审批面动态导入;判定语义在 ./message-watchdog.ts 纯函数) */
25
+ private async messageWatchdogTick(
26
+ msg: { messageId: string },
27
+ w: { stallMs: number, getLast: () => number, bump: () => void, isFired: () => boolean, markFired: () => void, stop: () => void },
28
+ ): Promise<void> {
29
+ if (w.isFired()) return
30
+ let hasPendingApprovals = false
31
+ try {
32
+ // 动态导入取审批面(避免 tool-approvals → platform-notice → manager 静态环);
33
+ // 审批面未装配(单测/降级)按"无合法等待"处理。
34
+ const { getToolApprovals } = await import('../../agents/tool-approvals')
35
+ hasPendingApprovals = getToolApprovals().listPending(this.agentId).length > 0
36
+ }
37
+ catch { /* 按无等待处理 */ }
38
+ if (w.isFired()) return
39
+ const now = Date.now()
40
+ if (hasPendingApprovals) {
41
+ // 有人在裁:暂停无活动窗口。审批解除后由下一次巡检从当前时刻重新起算,
42
+ // 避免长时间等人后刚拿到结果就被旧时间戳立即误杀。
43
+ w.bump()
44
+ return
45
+ }
46
+ if (!shouldFireMessageWatchdog({ state: this.state, lastActivityAt: w.getLast(), now, stallMs: w.stallMs, hasPendingApprovals })) return
47
+ w.markFired()
48
+ w.stop()
49
+ log.warn(`[AgentRuntime:${this.agentId}] 消息 ${msg.messageId.slice(0, 8)} 超过无活动阈值(${w.stallMs}ms)未结束且无挂起审批 → abort 当前回合并重投(state=${this.state})`)
50
+ // 带结构化 reason:omp 侧 normalizeSupervisionAbortReason 把 watchdog 视为非硬中止,
51
+ // 不合成 cancel 决策 —— 不会连坐取消频道内其它 active 任务(2026-11-16 复现回归)。
52
+ // 重投由旧回合 finally 完成,确保它停止处理后新回合才可认领该消息。
53
+ this.abortCurrent('message watchdog')
54
+ }
55
+
13
56
  async supervise(snapshot: SupervisionSnapshot): Promise<SupervisionDecision[] | null> {
14
- if (!this.impl.supervise) return null
57
+ if (!this.impl.supervise || this.getState() === 'stopped') return null
58
+ const rootId = snapshot.activeRootId ?? null
59
+ const root = rootId ? snapshot.tasks.find(task => task.id === rootId) : undefined
60
+ const rootGeneration = root?.assignmentGeneration
61
+ const rootLeaseId = root?.executionLeaseId
62
+ const rootSnapshotValid = Boolean(root && root.channelId === this.channelId && root.assigneeId === this.agentId
63
+ && !TERMINAL_TASK_STATES[root.state] && !root.executionLeaseRevokedAt
64
+ && root.executionLeaseAgentId === this.agentId
65
+ && Number.isSafeInteger(rootGeneration) && (rootGeneration ?? -1) >= 0 && rootLeaseId)
66
+ const controller = new AbortController()
67
+ this.superviseController = controller
68
+ const attemptId = randomUUID()
69
+ const startedAt = new Date().toISOString()
70
+ this.supervisionAttempt = {
71
+ attemptId,
72
+ channelId: this.channelId,
73
+ leadAgentId: this.agentId,
74
+ state: 'RUNNING',
75
+ startedAt,
76
+ watchdogAt: null,
77
+ completedAt: null,
78
+ snapshotRevision: snapshot.tick,
79
+ activeRootId: snapshot.activeRootId ?? null,
80
+ watchdogCount: 0,
81
+ lastSignalAt: null,
82
+ lastDecisionKind: null,
83
+ }
15
84
  // 监督回合本身是「在途工作」:过去只在 processMessage 里置 busy,lead 长监督
16
85
  // 期间对外恒 idle,Channel 配置重装会据此把它当空闲卸载并 abort 根任务。
17
86
  // 进入监督即置 busy,落定后恢复 idle;若期间已被 stop 则保持 stopped。
@@ -30,33 +99,36 @@ export abstract class AgentRuntimeSupervise extends AgentRuntimeLifecycle {
30
99
  ...snapshot.tasks.filter(t => t.state === 'SUBMITTED' || t.state === 'FAILED' || t.state === 'WAITING').map(t => t.title),
31
100
  ...snapshot.members.map(m => m.name),
32
101
  ].join(' ')
33
- memoryBlock = (await this.deps.memory?.recall(query, { touch: false })) ?? undefined
102
+ const recall = this.deps.memory?.recall(query, { touch: false, signal: controller.signal })
103
+ if (recall) {
104
+ let onAbort!: () => void
105
+ const aborted = new Promise<undefined>((resolve) => {
106
+ onAbort = () => resolve(undefined)
107
+ if (controller.signal.aborted) onAbort()
108
+ else controller.signal.addEventListener('abort', onAbort, { once: true })
109
+ })
110
+ try {
111
+ memoryBlock = (await Promise.race([recall, aborted])) ?? undefined
112
+ }
113
+ finally {
114
+ controller.signal.removeEventListener('abort', onAbort)
115
+ }
116
+ }
34
117
  }
35
118
  catch (err) {
36
119
  log.error(`[AgentRuntime:${this.agentId}] supervise 记忆召回失败:`, err)
37
120
  }
38
- const controller = new AbortController()
39
- this.superviseController = controller
121
+ if (controller.signal.aborted || this.getState() === 'stopped') {
122
+ if (this.superviseController === controller) this.superviseController = null
123
+ this.supervisionAttempt = { ...this.supervisionAttempt, state: 'IDLE', completedAt: new Date().toISOString(), lastDecisionKind: 'aborted' }
124
+ if (restoreIdleOnSettle && this.state === 'busy' && this.currentTaskId == null) this.state = 'idle'
125
+ this.refreshStatus()
126
+ return null
127
+ }
40
128
  const policy = this.impl.getSupervisionPolicy?.() ?? {
41
129
  watchdogMs: Number(workshopSettings().supervise_watchdog_ms) || 90_000,
42
130
  hardTimeoutMs: Number(workshopSettings().supervise_hard_timeout_ms) || 900_000,
43
131
  }
44
- const attemptId = randomUUID()
45
- const startedAt = new Date().toISOString()
46
- this.supervisionAttempt = {
47
- attemptId,
48
- channelId: this.channelId,
49
- leadAgentId: this.agentId,
50
- state: 'RUNNING',
51
- startedAt,
52
- watchdogAt: null,
53
- completedAt: null,
54
- snapshotRevision: snapshot.tick,
55
- activeRootId: snapshot.activeRootId ?? null,
56
- watchdogCount: 0,
57
- lastSignalAt: null,
58
- lastDecisionKind: null,
59
- }
60
132
  // §11 supervise_watchdog_only=false 时回退旧行为:watchdog 即中止回合。
61
133
  // 默认(true)下 watchdog 只记录信号 + 提示同一会话,绝不 abort/kill/重建 Harness。
62
134
  const watchdogOnly = superviseWatchdogOnly()
@@ -111,6 +183,30 @@ export abstract class AgentRuntimeSupervise extends AgentRuntimeLifecycle {
111
183
  void this.impl.steer?.('[系统监督 watchdog] 当前调度回合已超过观察阈值。请基于真实 worker 进度判断 wait、guide、reassign、cancel 或 complete;不要创建重复任务。')
112
184
  .catch(() => {})
113
185
  }
186
+ const validRoot = (): boolean => {
187
+ if (!rootId || !rootSnapshotValid) return false
188
+ if (this.deps.taskEngine.isLegacyRecoveryBlocked?.(rootId)) return false
189
+ const current = this.deps.taskEngine.get(rootId)
190
+ return Boolean(current && current.channelId === this.channelId && current.assigneeId === this.agentId
191
+ && !TERMINAL_TASK_STATES[current.state] && !current.executionLeaseRevokedAt
192
+ && current.executionLeaseAgentId === this.agentId
193
+ && current.assignmentGeneration === rootGeneration
194
+ && current.executionLeaseId === rootLeaseId)
195
+ }
196
+ const executionScope: ExecutionScope | undefined = rootId && rootGeneration != null && rootLeaseId && validRoot()
197
+ ? {
198
+ taskId: rootId,
199
+ agentId: this.agentId,
200
+ channelId: this.channelId,
201
+ assignmentGeneration: rootGeneration,
202
+ executionLeaseId: rootLeaseId,
203
+ signal: controller.signal,
204
+ assertActive: () => {
205
+ if (controller.signal.aborted || !validRoot()) throw new Error('supervision task execution lease is stale')
206
+ },
207
+ }
208
+ : undefined
209
+ if (rootId && !executionScope) controller.abort(new Error('task abort'))
114
210
  const ctx: AgentRunContext = {
115
211
  agentId: this.agentId,
116
212
  channelId: this.channelId,
@@ -118,10 +214,14 @@ export abstract class AgentRuntimeSupervise extends AgentRuntimeLifecycle {
118
214
  workspace: this.deps.workspace,
119
215
  signal: controller.signal,
120
216
  memory: memoryBlock,
217
+ ...(executionScope ? { executionScope } : {}),
121
218
  }
122
219
  let decisions: SupervisionDecision[] | null = null
123
220
  try {
221
+ if (controller.signal.aborted) return null
124
222
  decisions = await this.impl.supervise(snapshot, ctx, { signal: controller.signal, onWatchdog: at => markWatchdog(at) })
223
+ if (!controller.signal.aborted && executionScope && !validRoot()) controller.abort(new Error('task abort'))
224
+ if (controller.signal.aborted) return null
125
225
  return decisions
126
226
  }
127
227
  catch (err) {
@@ -133,11 +233,15 @@ export abstract class AgentRuntimeSupervise extends AgentRuntimeLifecycle {
133
233
  if (watchdogTimer) clearTimeout(watchdogTimer)
134
234
  if (hardTimer) clearTimeout(hardTimer)
135
235
  if (this.superviseController === controller) this.superviseController = null
136
- const settled = controller.signal.aborted ? 'ABORTED' : 'DECISION_APPLIED'
236
+ const aborted = controller.signal.aborted
237
+ const settled = aborted ? 'ABORTED' : 'DECISION_APPLIED'
238
+ if (!aborted) controller.abort(new Error('supervision settled'))
137
239
  // §2.3:落定审计 —— 完成时刻 + 最后决策类型(§8「Lead 最后决策」的数据源)
138
- const lastDecisionKind = decisions && decisions.length > 0
139
- ? decisions.map(d => d.kind).join(',')
140
- : (watchdogFired ? 'none_after_watchdog' : 'none')
240
+ const lastDecisionKind = aborted
241
+ ? 'aborted'
242
+ : decisions && decisions.length > 0
243
+ ? decisions.map(d => d.kind).join(',')
244
+ : (watchdogFired ? 'none_after_watchdog' : 'none')
141
245
  this.supervisionAttempt = {
142
246
  ...this.supervisionAttempt,
143
247
  state: settled,
@@ -191,37 +295,110 @@ export abstract class AgentRuntimeSupervise extends AgentRuntimeLifecycle {
191
295
  protected async consumeLoop(): Promise<void> {
192
296
  while (this.state !== 'stopped') {
193
297
  const msg = await this.deps.mailbox.dequeue()
194
- if (this.getState() === 'stopped' || msg === null) break
195
- // 单条 run 抛错不阻塞下一条
298
+ if (msg === null) break
299
+ const claimToken = this.deps.mailbox.claimToken(msg)
300
+ if (!claimToken) {
301
+ log.error(`[AgentRuntime:${this.agentId}] 消息认领缺少 token,拒绝执行: ${msg.messageId}`)
302
+ continue
303
+ }
304
+ if (this.getState() === 'stopped') {
305
+ this.deps.mailbox.releaseClaim(msg.messageId, claimToken)
306
+ break
307
+ }
308
+ // 单条 run 抛错不阻塞下一条。
309
+ // 看门狗必须在拿到 execLock **之后**才起表(2026-11-16 复现):否则前一条消息的
310
+ // 长回合会吃掉本消息的整个排队窗口,fire 时杀的是别人的回合、重投的是还没开跑的消息。
311
+ let turnGeneration = this.turnGeneration
196
312
  try {
197
- await this.withMessageWatchdog(msg, () => this.withExecLock(() => this.processMessage(msg)))
313
+ await this.withExecLock(() => {
314
+ turnGeneration = this.turnGeneration
315
+ if (this.getState() === 'stopped') {
316
+ this.deps.mailbox.releaseClaim(msg.messageId, claimToken)
317
+ return Promise.resolve()
318
+ }
319
+ return this.withMessageWatchdog(msg, claimToken, () => {
320
+ if (!this.deps.mailbox.beginProcessing(msg.messageId, claimToken)) return Promise.resolve()
321
+ return this.processMessage(msg, claimToken)
322
+ })
323
+ })
198
324
  }
199
325
  catch (err) {
200
326
  log.error(`[AgentRuntime:${this.agentId}] run 失败:`, err)
327
+ if (this.turnGeneration === turnGeneration) {
328
+ // Stop before releasing to prevent an immediate, unbounded preflight retry loop.
329
+ void this.stop()
330
+ this.deps.mailbox.releaseClaim(msg.messageId, claimToken)
331
+ break
332
+ }
333
+ else if (this.deps.mailbox.ownsClaim(msg.messageId, claimToken)) {
334
+ // Execution may have produced side effects: retain the claim and halt replay.
335
+ log.error(`[AgentRuntime:${this.agentId}] 回合收尾失败,保留认领并停止消费以避免重复执行`)
336
+ void this.stop()
337
+ break
338
+ }
201
339
  }
202
340
  }
203
341
  }
204
342
 
205
343
  /**
206
- * 消息级活性看门狗(P1 修复,2026-11-10 实测复现):被 claim 的消息若超过停滞阈值
207
- * 仍未结束回合 → abort 当前 run/监督回合 + 消息重投(attempts+1,≥3→dead,与 P3-4 同语义)。
344
+ * 消息级活性看门狗(P1 修复,2026-11-10;2026-11-16 重设计为「活动窗口」):
345
+ * 被 claim 的消息若超过**无活动阈值**仍未结束回合 → abort 当前 run/监督回合 +
346
+ * 消息重投(attempts+1,≥3→dead,与 P3-4 同语义)。
208
347
  *
209
- * 为什么需要:workerTurn 有停滞看门狗,但 peer/监督回合没有;ensureClient 的 await
210
- * 也不在超时保护内 —— 任一处挂死都会**永久持有 execLock**:状态恒 idle、消息恒
211
- * consuming、无任何日志(实测:群聊消息对空闲 lead 卡死 3+ 分钟且不可自愈)。
348
+ * 旧实现是固定 600s 从 claim 起算:实测把 16 分钟的健康治理回合(含 4 分钟 HITL
349
+ * 人工等待)连续 abort+重投 3 次直到 dead,同一 message_id 被整段重放三轮,还把
350
+ * 频道内其它 active 任务连坐取消。新语义(判定在 ./message-watchdog.ts,纯函数):
351
+ * - 回合内任何 harness 事件都重置活动时间(message.ts 事件循环逐事件上报);
352
+ * - 本 agent 有挂起 HITL 审批 → 不算停滞("有人在裁"是合法等待);
353
+ * - fire 时 abort 必须带 'message watchdog' reason —— omp 侧据此不合成 cancel
354
+ * 决策(硬中止只有 external cancel),不会连坐取消别的任务。
212
355
  * race 败者不清理状态:原回合若最终完成,按其自身路径 markConsumed
213
- * (repo requeue 的 WHERE state='consuming' 守卫使双重消费收敛为 no-op)。
356
+ * (repo requeue/markConsumed 的 WHERE state='consuming' 守卫使双重消费收敛为 no-op)。
214
357
  */
215
- protected withMessageWatchdog(msg: { messageId: string }, fn: () => Promise<void>): Promise<void> {
358
+ protected async withMessageWatchdog(msg: { messageId: string }, claimToken: string, fn: () => Promise<void>): Promise<void> {
216
359
  const stallMs = Math.max(60_000, Number(workshopSettings().harness_stall_timeout_ms) || 600_000)
217
- const timer = setTimeout(() => {
218
- log.warn(`[AgentRuntime:${this.agentId}] 消息 ${msg.messageId.slice(0, 8)} 超过停滞阈值(${stallMs}ms)未结束 → abort 当前回合并重投(state=${this.state})`)
219
- this.abortCurrent()
220
- // 重投(条件更新:仅 consuming 可重投);原回合若最终完成,其 markConsumed
221
- // 与本 requeue 以 WHERE state='consuming' 互斥,不产生双重消费。
222
- if (this.deps.mailbox.requeue(msg.messageId)) this.deps.mailbox.wake()
223
- }, stallMs)
360
+ let lastActivityAt = Date.now()
361
+ let fired = false
362
+ let unsubscribe = () => {}
363
+ this.messageWatchdogBump = () => {
364
+ lastActivityAt = Date.now()
365
+ }
366
+ try {
367
+ const { getToolApprovals } = await import('../../agents/tool-approvals')
368
+ unsubscribe = getToolApprovals().subscribeApprovalChanges(this.agentId, () => {
369
+ lastActivityAt = Date.now()
370
+ })
371
+ }
372
+ catch { /* 审批面未装配时继续使用活动事件 */ }
373
+ if (this.getState() === 'stopped') {
374
+ unsubscribe()
375
+ this.messageWatchdogBump = null
376
+ this.deps.mailbox.releaseClaim(msg.messageId, claimToken)
377
+ return
378
+ }
379
+ const timer = setInterval(() => {
380
+ void this.messageWatchdogTick(msg, {
381
+ stallMs,
382
+ getLast: () => lastActivityAt,
383
+ bump: () => {
384
+ lastActivityAt = Date.now()
385
+ },
386
+ isFired: () => fired,
387
+ markFired: () => {
388
+ fired = true
389
+ },
390
+ stop: () => clearInterval(timer),
391
+ })
392
+ }, MESSAGE_WATCHDOG_TICK_MS)
224
393
  timer.unref?.()
225
- return fn().finally(() => clearTimeout(timer))
394
+ try {
395
+ await fn()
396
+ }
397
+ finally {
398
+ fired = true
399
+ clearInterval(timer)
400
+ unsubscribe()
401
+ this.messageWatchdogBump = null
402
+ }
226
403
  }
227
404
  }
@@ -150,6 +150,12 @@ export interface TaskEngine {
150
150
  applyEvent(taskId: string, event: AgentEvent, fence?: { generation?: number | null, leaseId?: string | null }): void
151
151
  /** §5.1 执行代次栅栏:事件是否属于任务当前 assignment(无栅栏/无 lease → 放行) */
152
152
  assertAssignmentFence(taskId: string, fence?: { generation?: number | null, leaseId?: string | null }): boolean
153
+ /** Block held legacy task trees and roots behind them. */
154
+ isLegacyRecoveryBlocked(taskId: string): boolean
155
+ hasLegacyRecoveryHold(channelId: string): boolean
156
+ /** 运维处置面:恢复保留清单(含树内消息计数)与显式释放(审计留痕,不自动重放) */
157
+ listLegacyRecoveryHolds(): Array<{ taskId: string, channelId: string, assigneeId: string, title: string, state: string, closeReason: string, createdAt: string, messages: { pending: number, consuming: number, dead: number } }>
158
+ disposeLegacyRecoveryHold(taskId: string, actor: { id: string, name?: string }, note?: string): { released: string[], requeued: number, unblockedPending: number }
153
159
  list(channelId: string): WorkspaceTask[]
154
160
  get(taskId: string): WorkspaceTask | undefined
155
161
  complete(taskId: string, artifacts?: A2AArtifact[]): WorkspaceTask
@@ -7,7 +7,7 @@
7
7
  import type { A2AMessage, Part } from '../types/a2a'
8
8
  import { parseJson } from '../db/database'
9
9
  import type { MessageRow } from '../db/database'
10
- import type { MessageRepo } from '../db/message.repo'
10
+ import type { MessageBlocked, MessageRepo } from '../db/message.repo'
11
11
  import { AppError } from '../../../utils/errors'
12
12
 
13
13
  /** promise 门闩:resolve 后重建,供 dequeue 反复挂起 */
@@ -26,7 +26,10 @@ function newGate(): Gate {
26
26
 
27
27
  /** MessageRow → A2AMessage(parts/metadata 反序列化) */
28
28
  export function rowToMessage(row: MessageRow): A2AMessage {
29
- const metadata = parseJson<Record<string, unknown>>(row.metadataJson, {})
29
+ const parsedMetadata = parseJson<unknown>(row.metadataJson, {})
30
+ const metadata: Record<string, unknown> = parsedMetadata !== null && typeof parsedMetadata === 'object' && !Array.isArray(parsedMetadata)
31
+ ? parsedMetadata as Record<string, unknown>
32
+ : {}
30
33
  // Session Context:session_id 是平台列,metadata 是消息契约;读取时补齐后者,
31
34
  // 保证从历史 mailbox 重放的旧行也能恢复到同一 session。
32
35
  if (row.sessionId && typeof metadata['x-aw-session-id'] !== 'string') {
@@ -47,6 +50,10 @@ export class Mailbox {
47
50
  readonly channelId: string
48
51
  private gate: Gate = newGate()
49
52
  private closed = false
53
+ /** Tokens, not message IDs, distinguish concurrent generations of a claim. */
54
+ private readonly claimedMessages = new Map<string, string>()
55
+ private readonly processingMessages = new Map<string, string>()
56
+ private readonly deliveryTokens = new WeakMap<A2AMessage, string>()
50
57
  /** 外部通知回调(如唤醒调度循环);由 AgentRuntime/Manager 注入 */
51
58
  private onWake: () => void
52
59
  /** 到信回调注册(poll_messages 长轮询即时唤醒;注册方自带注销句柄) */
@@ -57,6 +64,7 @@ export class Mailbox {
57
64
  channelId: string,
58
65
  agentId: string,
59
66
  wake: () => void,
67
+ private readonly isBlocked?: MessageBlocked,
60
68
  ) {
61
69
  this.channelId = channelId
62
70
  this.agentId = agentId
@@ -102,12 +110,6 @@ export class Mailbox {
102
110
  message.messageId = result.row.id
103
111
  }
104
112
  this.wake()
105
- for (const cb of this.arrivalCbs) {
106
- try {
107
- cb()
108
- }
109
- catch { /* 回调异常不阻断投递 */ }
110
- }
111
113
  this.onWake()
112
114
  return true
113
115
  }
@@ -127,12 +129,15 @@ export class Mailbox {
127
129
  // 先取门闩引用再查询:查询空档内 enqueue 的 releaseGate 才不会丢唤醒
128
130
  // (若查询后才取引用,新门闩替换旧门闩 → 挂在未触发的门闩上永久沉睡)
129
131
  const gate = this.gate
130
- const row = this.messageRepo.firstPendingByChannelAgent(this.channelId, this.agentId)
132
+ const row = this.messageRepo.firstPendingByChannelAgent(this.channelId, this.agentId, this.isBlocked)
131
133
  if (row) {
132
134
  // 原子认领:认领失败 = 消息已被 steer 注入或 poll_messages 读即取
133
135
  // (唯一所有权),让路重查下一条——消费循环绝不重复处理他人消息
134
- if (!this.messageRepo.claim(row.id)) continue
135
- return rowToMessage(row)
136
+ const token = this.claim(row.id)
137
+ if (!token) continue
138
+ const message = rowToMessage(row)
139
+ this.deliveryTokens.set(message, token)
140
+ return message
136
141
  }
137
142
  // 门闩挂起 + 15s 兜底重查:任何唤醒丢失路径自愈(消息最多滞后 15s)
138
143
  await Promise.race([
@@ -142,29 +147,115 @@ export class Mailbox {
142
147
  }
143
148
  }
144
149
 
145
- /** 原子认领(pending → consuming):多方竞争下唯一所有权;认领失败返回 false */
146
- claim(messageId: string): boolean {
147
- return this.messageRepo.claim(messageId)
150
+ /** Get the private token associated with this exact dequeued delivery. */
151
+ claimToken(message: A2AMessage): string | undefined {
152
+ return this.deliveryTokens.get(message)
153
+ }
154
+
155
+ /** Atomically claim a message; callers must retain the returned token. */
156
+ claim(messageId: string): string | null {
157
+ const token = this.messageRepo.claim(messageId, this.isBlocked)
158
+ if (token) this.claimedMessages.set(token, messageId)
159
+ return token
160
+ }
161
+
162
+ /** Release either an unstarted or a completed processing claim. */
163
+ releaseClaim(messageId: string, token: string): boolean {
164
+ if (!this.hasLocalClaim(messageId, token)) return false
165
+ const released = this.messageRepo.releaseClaim(messageId, token)
166
+ this.forgetClaim(messageId, token)
167
+ if (released) this.wake()
168
+ return released
169
+ }
170
+
171
+ /** Return all claims that have not entered processing, preserving retry budget. */
172
+ releaseOwnedClaims(): number {
173
+ let released = 0
174
+ for (const [token, messageId] of this.claimedMessages) {
175
+ if (this.messageRepo.releaseClaim(messageId, token)) released += 1
176
+ }
177
+ this.claimedMessages.clear()
178
+ if (released > 0) this.wake()
179
+ return released
180
+ }
181
+
182
+ /** Mark an exact current claim as processing. */
183
+ beginProcessing(messageId: string, token: string): boolean {
184
+ if (this.claimedMessages.get(token) !== messageId) return false
185
+ if (!this.messageRepo.ownsClaim(messageId, token)) {
186
+ this.claimedMessages.delete(token)
187
+ return false
188
+ }
189
+ if (this.isBlocked && this.messageRepo.isClaimBlocked(messageId, token, this.isBlocked)) {
190
+ this.releaseClaim(messageId, token)
191
+ return false
192
+ }
193
+ this.claimedMessages.delete(token)
194
+ this.processingMessages.set(token, messageId)
195
+ return true
196
+ }
197
+
198
+ private hasLocalClaim(messageId: string, token: string): boolean {
199
+ return typeof token === 'string' && token.length > 0
200
+ && (this.claimedMessages.get(token) === messageId || this.processingMessages.get(token) === messageId)
201
+ }
202
+
203
+ private forgetClaim(messageId: string, token: string): void {
204
+ if (this.claimedMessages.get(token) === messageId) this.claimedMessages.delete(token)
205
+ if (this.processingMessages.get(token) === messageId) this.processingMessages.delete(token)
148
206
  }
149
207
 
150
208
  /** 只读查看未消费消息(不改变状态) */
151
209
  async peek(limit: number): Promise<A2AMessage[]> {
152
- return this.messageRepo.listPendingByChannelAgent(this.channelId, this.agentId, limit).map(rowToMessage)
210
+ return this.messageRepo.listPendingByChannelAgent(this.channelId, this.agentId, limit, this.isBlocked).map(rowToMessage)
211
+ }
212
+
213
+ /** Settle only the exact claim held by this mailbox. */
214
+ markConsumed(messageId: string, token: string): boolean {
215
+ if (!this.hasLocalClaim(messageId, token)) return false
216
+ const consumed = this.messageRepo.markConsumed(messageId, token)
217
+ this.forgetClaim(messageId, token)
218
+ return consumed
219
+ }
220
+
221
+ /** Quarantine a locally held recovery claim without disturbing a newer claim. */
222
+ deadLetterLegacyRecoveryClaim(messageId: string, token: string): boolean {
223
+ if (!this.hasLocalClaim(messageId, token)) return false
224
+ const dead = this.messageRepo.deadLetterLegacyRecoveryClaim(messageId, token)
225
+ if (dead || !this.messageRepo.ownsClaim(messageId, token)) this.forgetClaim(messageId, token)
226
+ return dead
227
+ }
228
+
229
+ /** Recheck the persisted row under this exact claim, failing closed on lost ownership. */
230
+ isClaimBlocked(messageId: string, token: string): boolean {
231
+ if (!this.hasLocalClaim(messageId, token)) return true
232
+ return this.isBlocked
233
+ ? this.messageRepo.isClaimBlocked(messageId, token, this.isBlocked)
234
+ : !this.messageRepo.ownsClaim(messageId, token)
153
235
  }
154
236
 
155
- /** 标记已消费 */
156
- markConsumed(messageId: string): void {
157
- this.messageRepo.markConsumed(messageId)
237
+ /** Whether this exact claim is still owned by this mailbox. */
238
+ ownsClaim(messageId: string, token: string): boolean {
239
+ return this.hasLocalClaim(messageId, token) && this.messageRepo.ownsClaim(messageId, token)
158
240
  }
159
241
 
160
242
  /** 回合失败重投(consuming → pending);返回是否实际重投 */
161
- requeue(messageId: string): boolean {
162
- return this.messageRepo.requeue(messageId)
243
+ requeue(messageId: string, token: string): boolean {
244
+ if (!this.hasLocalClaim(messageId, token)) return false
245
+ const requeued = this.messageRepo.requeue(messageId, token)
246
+ this.forgetClaim(messageId, token)
247
+ return requeued
163
248
  }
164
249
 
165
- /** 外部唤醒:解除 dequeue 挂起(供 manager 在 taskEngine 直接落库后唤醒) */
250
+ /** Recheck queue and long-poll waiters after delivery or eligibility changes. */
166
251
  wake(): void {
167
252
  this.releaseGate()
253
+ for (const cb of this.arrivalCbs) {
254
+ try {
255
+ cb()
256
+ }
257
+ catch { /* A waiter must not block other notifications. */ }
258
+ }
168
259
  }
169
260
 
170
261
  /** 关闭邮箱:解除 dequeue 挂起,后续 dequeue 返回 null(供 AgentRuntime.stop) */
@@ -17,7 +17,6 @@ import { assertChannelWorkspaceAllowed, assertSpawnConfigAllowed, type SpawnActo
17
17
  import { mkdirSync } from 'node:fs'
18
18
  import { parseJson } from '../../db/database'
19
19
  import { resolve } from 'node:path'
20
- import { runtimeKey } from './helpers'
21
20
  import { activeSessionOfMember, SESSION_MARKER } from '../../agents/session-clone'
22
21
  import { createChannelSessionRepo } from '../../db/channel-session.repo'
23
22
 
@@ -328,32 +327,45 @@ export abstract class ManagerAdminChannel extends ManagerNotifications {
328
327
  return this.deps.repos.channels.list()
329
328
  }
330
329
 
331
- async removeChannel(channelId: string): Promise<void> {
332
- const cr = this.channels.get(channelId)
333
- if (cr) {
334
- await cr.stopSchedulersAndWait()
335
- for (const agent of [...cr.getAgents()]) {
336
- await agent.stop()
337
- this.agentIndex.delete(runtimeKey(channelId, agent.agentId))
330
+ removeChannel(channelId: string): Promise<void> {
331
+ const pending = this.channelRemovals.get(channelId)
332
+ if (pending) return pending
333
+
334
+ // Hold a separate deletion fence across a shared unload and the synchronous cascades.
335
+ const stops = [...(this.channelAgentStops.get(channelId) ?? [])]
336
+ let unloading: Promise<boolean>
337
+ const removal = Promise.resolve().then(async () => {
338
+ const results = await Promise.allSettled([unloading, ...stops])
339
+ const failed = results.find(result => result.status === 'rejected')
340
+ if (failed?.status === 'rejected') throw failed.reason
341
+ // 记忆级联清理:成员私有行 + team 公共行(防残留行污染他 channel 的 FTS/team 检索域)
342
+ this.deps.repos.memories.deleteByChannel(channelId)
343
+ // 工具治理级联:插件开关 + Channel 工具策略/选择行(无外键,必须显式删除)
344
+ try {
345
+ getChannelPluginsRepo().removeForChannel(channelId)
346
+ getToolRegistryRepo().removeForChannel(channelId)
338
347
  }
348
+ catch { /* 工具治理表不可用不阻断删除(悬挂行读取时忽略) */ }
349
+ // 定时任务级联清理(FK CASCADE 兜底;显式删除保证旧库无 FK 时也收敛)
350
+ this.deps.repos.schedules?.removeByChannel(channelId)
351
+ // workspace 挂载级联,兼容未注入用户仓储的旧脚手架。
352
+ this.deps.repos.users?.unmountChannelEverywhere(channelId)
353
+ this.deps.repos.channels.remove(channelId)
354
+ // A late subscriber can create an empty runtime while the unload is settling.
339
355
  this.channels.delete(channelId)
340
356
  this.buses.delete(channelId)
341
- }
342
- // 记忆级联清理:成员私有行 + team 公共行(防残留行污染他 channel 的 FTS/team 检索域)
343
- this.deps.repos.memories.deleteByChannel(channelId)
344
- // 工具治理级联:插件开关 + Channel 工具策略/选择行(无外键,必须显式删除)
357
+ this.deferredChannelRecycles.delete(channelId)
358
+ }).finally(() => {
359
+ this.channelRemovals.delete(channelId)
360
+ })
361
+ this.channelRemovals.set(channelId, removal)
345
362
  try {
346
- getChannelPluginsRepo().removeForChannel(channelId)
347
- getToolRegistryRepo().removeForChannel(channelId)
363
+ unloading = this.unloadChannelAgents(channelId)
364
+ }
365
+ catch (error) {
366
+ unloading = Promise.reject(error)
348
367
  }
349
- catch { /* 工具治理表不可用不阻断删除(悬挂行读取时忽略) */ }
350
- // 定时任务级联清理(FK CASCADE 兜底;显式删除保证旧库无 FK 时也收敛)
351
- this.deps.repos.schedules?.removeByChannel(channelId)
352
- // workspace 挂载级联:不清理会留下"幽灵频道"(左栏有条目、右栏永空)——
353
- // 这是 listWorkspaces 读路径兜底要解决的问题,现在在删除侧一次性收敛
354
- // (与上一行 schedules 同口径:`repos` 允许旧脚手架只注入部分仓储,缺省即跳过级联)
355
- this.deps.repos.users?.unmountChannelEverywhere(channelId)
356
- this.deps.repos.channels.remove(channelId)
368
+ return removal
357
369
  }
358
370
 
359
371
  // ===== Agent 模板管理面(全局,可复用;v10 可见性隔离) =====