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
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { A2AMessage, A2AArtifact, A2AError, ChannelMail, Part } from '../types/a2a'
8
8
  import type { WorkspaceTask, AgentTaskQueueView, AgentStatusView, AgentContextStats } from '../types/task'
9
+ import type { ExecutionScope } from './execution-scope'
9
10
 
10
11
  /** Agent 元信息:Channel 内成员声明(hook harness 类型与配置) */
11
12
  export interface AgentInfo {
@@ -259,6 +260,8 @@ export interface AgentRunContext {
259
260
  role: 'lead' | 'worker'
260
261
  workspace: AgentWorkspace
261
262
  signal: AbortSignal
263
+ /** Trusted lease scope supplied by the runtime for an assigned task or root. */
264
+ executionScope?: ExecutionScope
262
265
  /** 平台记忆块(supervise 路径注入;run 路径用 AgentRunRequest.memory) */
263
266
  memory?: string
264
267
  /** Session Context:当前 supervision/run 的会话身份与上下文块(profile 标注装配档位) */
@@ -29,6 +29,7 @@ import type {
29
29
  SupervisionSnapshot,
30
30
  } from './agent-interface'
31
31
  import { createSessionState, dispatchHostTool, type HostToolBridgeContext, type HostToolSessionState } from './host-tool-bridge'
32
+ import { runWithExecutionScope, type ExecutionScope } from './execution-scope'
32
33
  import { channelOverlayText } from '../experience/overlay'
33
34
  import { workshopSettings } from '../settings'
34
35
  import {
@@ -64,6 +65,7 @@ export abstract class BaseAgentImpl implements AgentInterface {
64
65
  protected workspace: AgentRunContext['workspace'] | null = null
65
66
  protected readonly toolState: HostToolSessionState = createSessionState()
66
67
  protected readonly bridgeCtx: HostToolBridgeContext
68
+ private turnScope: { scope: ExecutionScope, controller: AbortController } | undefined
67
69
  /** 名册缓存:仅由 refreshIdentity() 装配(构造函数必经路径),故用明确赋值断言 */
68
70
  protected roster!: ReturnType<typeof createRosterCache>
69
71
 
@@ -126,7 +128,70 @@ export abstract class BaseAgentImpl implements AgentInterface {
126
128
  }
127
129
 
128
130
  dispatchHostTool(toolName: string, args: Record<string, unknown>, activeRootTaskId?: string): Promise<{ text: string, isError?: boolean }> {
129
- return dispatchHostTool(this.bridgeCtx, { toolName, arguments: args }, activeRootTaskId)
131
+ const channelScope = this.bridgeCtx.channelSessionScope
132
+ const state = createSessionState()
133
+ state.sessionId = channelScope?.sessionId ?? null
134
+ const bridge: HostToolBridgeContext = {
135
+ identity: { ...this.bridgeCtx.identity },
136
+ state,
137
+ channelSessionScope: channelScope ? { ...channelScope, recipes: channelScope.recipes.map(recipe => ({ ...recipe })) } : null,
138
+ getWorkspace: this.bridgeCtx.getWorkspace,
139
+ }
140
+ return runWithExecutionScope(undefined, () =>
141
+ dispatchHostTool(bridge, { toolName, arguments: args }, activeRootTaskId))
142
+ }
143
+
144
+ protected get currentTurnScope(): ExecutionScope | undefined {
145
+ return this.turnScope?.scope
146
+ }
147
+
148
+ protected beginTurnScope(ctx: AgentRunContext): ExecutionScope {
149
+ if (this.turnScope) throw new Error('agent turn already active')
150
+ const trusted = ctx.executionScope
151
+ if (trusted && (trusted.agentId !== ctx.agentId || trusted.channelId !== ctx.channelId || trusted.signal !== ctx.signal)) {
152
+ throw new Error('invalid execution scope identity or signal')
153
+ }
154
+ const taskId = trusted?.taskId
155
+ const generation = trusted?.assignmentGeneration
156
+ const leaseId = trusted?.executionLeaseId
157
+ const hasLease = taskId !== undefined || generation !== undefined || leaseId !== undefined
158
+ if (hasLease && (!taskId || !Number.isSafeInteger(generation) || generation! < 0 || !leaseId)) {
159
+ throw new Error('incomplete task execution lease')
160
+ }
161
+ const validate = trusted?.assertActive
162
+ const controller = new AbortController()
163
+ const signal = AbortSignal.any([ctx.signal, controller.signal])
164
+ const scope: ExecutionScope = Object.freeze({
165
+ agentId: ctx.agentId,
166
+ channelId: ctx.channelId,
167
+ ...(hasLease ? { taskId, assignmentGeneration: generation, executionLeaseId: leaseId } : {}),
168
+ signal,
169
+ assertActive: () => {
170
+ if (signal.aborted || this.turnScope?.scope !== scope) throw new Error('agent turn is no longer active')
171
+ validate?.()
172
+ },
173
+ })
174
+ this.turnScope = { scope, controller }
175
+ return scope
176
+ }
177
+
178
+ protected endTurnScope(scope: ExecutionScope): void {
179
+ if (this.turnScope?.scope !== scope) return
180
+ const { controller } = this.turnScope
181
+ this.turnScope = undefined
182
+ controller.abort(new Error('agent turn ended'))
183
+ }
184
+
185
+ protected dispatchTurnHostTool(toolName: string, args: Record<string, unknown>, scope: ExecutionScope, activeRootTaskId?: string): Promise<{ text: string, isError?: boolean }> {
186
+ try {
187
+ scope.assertActive()
188
+ if (this.currentTurnScope !== scope) throw new Error('stale agent turn')
189
+ }
190
+ catch (error) {
191
+ return Promise.resolve({ text: error instanceof Error ? error.message : String(error), isError: true })
192
+ }
193
+ return runWithExecutionScope(scope, () =>
194
+ dispatchHostTool(this.bridgeCtx, { toolName, arguments: args }, activeRootTaskId))
130
195
  }
131
196
 
132
197
  setChannelSessionScope(scope: HostToolBridgeContext['channelSessionScope']): void {
@@ -157,8 +222,14 @@ export abstract class BaseAgentImpl implements AgentInterface {
157
222
 
158
223
  async* run(request: AgentRunRequest, ctx: AgentRunContext): AsyncIterable<AgentEvent> {
159
224
  if (!this.workspace) this.workspace = ctx.workspace
160
- this.currentSessionBlock = request.session?.block ?? null
161
225
  const kind = request.message.metadata?.['x-aw-task-kind']
226
+ const taskId = request.taskId ?? request.message.metadata?.['x-aw-task-id']
227
+ if (kind === 'assign' && ctx.role === 'worker'
228
+ && (!ctx.executionScope || !taskId || ctx.executionScope.taskId !== taskId)) {
229
+ throw new Error('assigned task requires a matching execution lease')
230
+ }
231
+ const scope = this.beginTurnScope(ctx)
232
+ this.currentSessionBlock = request.session?.block ?? null
162
233
  const sourceChatMessageId = typeof request.message.metadata?.['x-aw-source-chat-message-id'] === 'string'
163
234
  ? String(request.message.metadata['x-aw-source-chat-message-id'])
164
235
  : null
@@ -170,12 +241,13 @@ export abstract class BaseAgentImpl implements AgentInterface {
170
241
  // session 作用域贯通:memory 工具(save/search)在回合内使用当前 session id
171
242
  this.toolState.sessionId = request.session?.id ?? null
172
243
  try {
244
+ scope.assertActive()
173
245
  if (kind === 'assign' && ctx.role === 'worker') {
174
- yield* this.workerTurn(request, ctx)
246
+ yield* this.scopedTurn(this.workerTurn(request, ctx), scope)
175
247
  return
176
248
  }
177
249
  if (!kind && (request.fromAgentId || request.message.metadata?.['x-aw-from-label'])) {
178
- yield* this.peerTurn(request, ctx)
250
+ yield* this.scopedTurn(this.peerTurn(request, ctx), scope)
179
251
  return
180
252
  }
181
253
  }
@@ -183,10 +255,24 @@ export abstract class BaseAgentImpl implements AgentInterface {
183
255
  this.toolState.sourceChatMessageId = null
184
256
  this.toolState.sourceChatDeliveryId = null
185
257
  this.toolState.sessionId = null
258
+ this.endTurnScope(scope)
186
259
  this.currentSessionBlock = null
187
260
  }
188
261
  }
189
262
 
263
+ private async* scopedTurn(turn: AsyncGenerator<AgentEvent, void, unknown>, scope: ExecutionScope): AsyncGenerator<AgentEvent, void, unknown> {
264
+ try {
265
+ for (;;) {
266
+ const next = await runWithExecutionScope(scope, () => turn.next())
267
+ if (next.done) break
268
+ yield next.value
269
+ }
270
+ }
271
+ finally {
272
+ await runWithExecutionScope(scope, () => turn.return())
273
+ }
274
+ }
275
+
190
276
  /** 任务指派回合(assign) */
191
277
  protected abstract workerTurn(request: AgentRunRequest, ctx: AgentRunContext): AsyncGenerator<AgentEvent, void, unknown>
192
278
 
@@ -202,6 +288,16 @@ export abstract class BaseAgentImpl implements AgentInterface {
202
288
 
203
289
  async supervise(snapshot: SupervisionSnapshot, ctx: AgentRunContext, opts?: SupervisionOptions): Promise<SupervisionDecision[]> {
204
290
  if (this.supervising) return []
291
+ const scope = this.beginTurnScope(ctx)
292
+ try {
293
+ return await runWithExecutionScope(scope, () => this.superviseInScope(snapshot, ctx, opts))
294
+ }
295
+ finally {
296
+ this.endTurnScope(scope)
297
+ }
298
+ }
299
+
300
+ private async superviseInScope(snapshot: SupervisionSnapshot, ctx: AgentRunContext, opts?: SupervisionOptions): Promise<SupervisionDecision[]> {
205
301
  if (!this.workspace) this.workspace = ctx.workspace
206
302
  // 懒加载型 harness(如 codex)必须先确保会话进程存在:worker/peer 回合各自 ensure,
207
303
  // supervise 是唯一不经 run() 的回合入口 —— 缺这一步,全新 lead 的每轮监督都会在
@@ -0,0 +1,26 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks'
2
+
3
+ /**
4
+ * Trusted server-side scope for one turn. Task lease fields are present only
5
+ * when a validated assignment or supervision root supplies them.
6
+ */
7
+ export interface ExecutionScope {
8
+ readonly taskId?: string
9
+ readonly agentId: string
10
+ readonly channelId: string
11
+ readonly assignmentGeneration?: number
12
+ readonly executionLeaseId?: string
13
+ readonly signal: AbortSignal
14
+ readonly assertActive: () => void
15
+ }
16
+
17
+ const storage = new AsyncLocalStorage<ExecutionScope | undefined>()
18
+
19
+ export function currentExecutionScope(): ExecutionScope | undefined {
20
+ return storage.getStore()
21
+ }
22
+
23
+ export function runWithExecutionScope<T>(scope: ExecutionScope | undefined, fn: () => T): T {
24
+ // An unscoped call must not inherit the caller's ambient authority.
25
+ return storage.run(scope, fn)
26
+ }
@@ -169,9 +169,9 @@ export const DECLARATIONS: Record<string, HitlDeclaration> = {
169
169
  providerKind: 'dcw-approval',
170
170
  facets: { approval: true, question: false, multiQuestion: false, structuredResponse: false, cancel: true },
171
171
  evidence: [
172
- 'server/services/workshop/agents/tool-approvals.ts:95 getHitlRegistry',
173
- 'server/services/workshop/agents/tool-approvals.ts:225 decide',
174
- 'server/services/workshop/agents/tool-approvals.ts:275 cancelPendingFor',
172
+ 'server/services/workshop/agents/tool-approvals.ts:156 getHitlRegistry',
173
+ 'server/services/workshop/agents/tool-approvals.ts:301 decide',
174
+ 'server/services/workshop/agents/tool-approvals.ts:359 cancelPendingFor',
175
175
  ],
176
176
  unsupportedReason: '数控下发审批只有批准/拒绝二值,无提问通道(question=false)',
177
177
  },
@@ -42,6 +42,33 @@ import { PROJECT_GATED_WRITE_TOOL_NAMES, PROJECT_TOOL_NAMES } from '../../projec
42
42
  import { dispatchProjectTool } from '../../projects/tools'
43
43
  import { getProjectService } from '../../projects/service'
44
44
  import { projectExecutionGate } from '../../projects/execution-gate'
45
+ import { currentExecutionScope, runWithExecutionScope, type ExecutionScope } from '../execution-scope'
46
+
47
+ /** A peer turn has no task lease, so its writes must honor the channel hold. */
48
+ export function peerWriteScope(scope: ExecutionScope, identity: HostToolBridgeContext['identity']): ExecutionScope {
49
+ const assertActive = () => {
50
+ scope.assertActive()
51
+ if (!identity.channelId || scope.channelId !== identity.channelId || scope.agentId !== identity.agentId) {
52
+ throw new Error('LEGACY_EXECUTION_RECOVERY_STATUS_UNAVAILABLE: agent turn identity does not match channel')
53
+ }
54
+ let held: unknown
55
+ try {
56
+ // getTaskEngine is protected in TypeScript, but is the manager's shared runtime engine.
57
+ const manager = globalThis.__workshopManager as unknown as { getTaskEngine?: () => { hasLegacyRecoveryHold?: (channelId: string) => boolean } } | undefined
58
+ const engine = manager?.getTaskEngine?.()
59
+ if (typeof engine?.hasLegacyRecoveryHold !== 'function') throw new Error('recovery status unavailable')
60
+ held = engine.hasLegacyRecoveryHold(identity.channelId)
61
+ }
62
+ catch {
63
+ throw new Error('LEGACY_EXECUTION_RECOVERY_STATUS_UNAVAILABLE: cannot verify channel recovery status')
64
+ }
65
+ if (held !== false) {
66
+ if (held === true) throw new Error('LEGACY_EXECUTION_RECOVERY_REQUIRED: channel requires operator investigation before agent writes')
67
+ throw new Error('LEGACY_EXECUTION_RECOVERY_STATUS_UNAVAILABLE: invalid channel recovery status')
68
+ }
69
+ }
70
+ return Object.freeze({ ...scope, assertActive })
71
+ }
45
72
 
46
73
  /**
47
74
  * 分发一次 host tool 调用(全引擎唯一入口):
@@ -72,8 +99,21 @@ export async function dispatchHostTool(ctx: HostToolBridgeContext, req: HostTool
72
99
  // 活性打点先于一切校验:被拒的工具调用同样证明 agent 在推进(不是死锁)
73
100
  noteToolActivity(ctx.identity.agentId)
74
101
  try {
75
- return await withGovernanceHarnessToolAudit(ctx, req, activeRootTaskId, async () =>
76
- truncateToolResult(await dispatchHostToolInner(ctx, req, activeRootTaskId), req.toolName))
102
+ return await withGovernanceHarnessToolAudit(ctx, req, activeRootTaskId, async () => {
103
+ const scope = currentExecutionScope()
104
+ if (scope && !scope.taskId && OBSERVE_BLOCKED_TOOL_NAMES.has(req.toolName)) {
105
+ const guarded = peerWriteScope(scope, ctx.identity)
106
+ try {
107
+ guarded.assertActive()
108
+ }
109
+ catch (error) {
110
+ return { text: error instanceof Error ? error.message : String(error), isError: true }
111
+ }
112
+ return runWithExecutionScope(guarded, async () =>
113
+ truncateToolResult(await dispatchHostToolInner(ctx, req, activeRootTaskId), req.toolName))
114
+ }
115
+ return truncateToolResult(await dispatchHostToolInner(ctx, req, activeRootTaskId), req.toolName)
116
+ })
77
117
  }
78
118
  catch (error) {
79
119
  if (!(error instanceof GovernanceHarnessAuditError)) throw error
@@ -7,6 +7,7 @@ import type { AgentWorkspace } from '../../agent-interface'
7
7
  import type { A2AArtifact } from '../../../types/a2a'
8
8
  import type { GoalCompletionVerifier } from '../../../verify/goal-completion'
9
9
  import type { HostToolResult, HostToolSessionState } from '../types'
10
+ import { currentExecutionScope } from '../../execution-scope'
10
11
 
11
12
  export async function handleReportProgress(
12
13
  args: Record<string, unknown>,
@@ -34,6 +35,7 @@ export async function handleReportProgress(
34
35
  isError: true,
35
36
  }
36
37
  }
38
+ currentExecutionScope()?.assertActive()
37
39
  await ws.reportTask({ taskId, progress, message })
38
40
  return { text: `进度已上报: ${progress}%${message ? ` (${message})` : ''}` }
39
41
  }
@@ -120,6 +122,7 @@ export async function handleCompleteTask(
120
122
  parts: [{ text: deliverable ?? summary }],
121
123
  })
122
124
  }
125
+ currentExecutionScope()?.assertActive()
123
126
  await ws.completeTask(taskId, artifacts)
124
127
  state.currentTaskId = null
125
128
  // 完成即衔接:报告队列余量与下一项(状态同步 + 驱动继续处理)
@@ -150,6 +153,7 @@ export async function handleSupersedeTask(
150
153
  if (!taskId || !replacementTaskId) {
151
154
  return { text: '参数缺失:需要 task_id(失败/取消的分支任务)与 replacement_task_id(覆盖其工作的替代任务)', isError: true }
152
155
  }
156
+ currentExecutionScope()?.assertActive()
153
157
  const superseded = await ws.supersedeTask(taskId, replacementTaskId, reason)
154
158
  return {
155
159
  text: `分支「${superseded.title}」(${superseded.state})已标记为被 ${replacementTaskId.slice(0, 8)} 替代,不再阻塞父任务收口。失败事实保留在任务记录中;现在可对父任务检查交付并 complete_task。`,
@@ -7,6 +7,7 @@ import type { AgentWorkspace } from '../../agent-interface'
7
7
  import type { WorkspaceTask } from '../../../types/task'
8
8
  import { TERMINAL_TASK_STATES } from '../../../types/task'
9
9
  import { extractTaskMode } from '../../../runtime/execution-mode'
10
+ import { currentExecutionScope } from '../../execution-scope'
10
11
  import type { HostToolBridgeContext, HostToolResult, HostToolSessionState } from '../types'
11
12
 
12
13
  export async function handleSubmitTask(args: Record<string, unknown>, state: HostToolSessionState, ws: AgentWorkspace): Promise<HostToolResult> {
@@ -52,11 +53,15 @@ export async function handleDispatchTask(args: Record<string, unknown>, ws: Agen
52
53
  }
53
54
  parentTaskId = activeRootTaskId
54
55
  }
56
+ const rawGrant = args.grant_node_ids ?? args.grantNodeIds
57
+ if (rawGrant != null) {
58
+ return {
59
+ text: '未派发:随任务授权暂不可用,因为授权与任务派发无法原子提交。请先单独确认并授予节点权限,再不带 grant_node_ids 派发任务。',
60
+ isError: true,
61
+ }
62
+ }
55
63
  // 重复派发守卫(真实场景实测:lead 模型可能对同一目标重复派发,引发协调风暴):
56
64
  // 同父任务下已存在同标题非终态子任务 → 不再创建,直接指路既有任务。
57
- // 2026-10-30 前移到授权之前:原顺序先落库 grant_node_ids 再判重,判重命中时授权
58
- // (grant_mode=auto 还会摘除逐次人工审批)已生效却无任务上下文 —— 悬空授权面,
59
- // 且 lead 每次重复派发尝试都会重放授权,把偶发幻觉放大成常态越权面。
60
65
  const dup = await ws.listTasks()
61
66
  const existing = dup.find(t =>
62
67
  t.parentId === parentTaskId
@@ -67,36 +72,14 @@ export async function handleDispatchTask(args: Record<string, unknown>, ws: Agen
67
72
  text: `未创建:同父任务下已存在同标题进行中子任务 ${existing.id}("${existing.title}",state=${existing.state},assignee=${existing.assigneeId})。请勿重复派发;若需跟进请对该任务 notify 或 reassign。`,
68
73
  }
69
74
  }
70
- // 派发时随任务授予节点权限(lead 专属;grant_node_ids ⊆ lead 自身绑定面,fail-closed):
71
- // 任一节点不满足则整单拒绝,任务不创建 —— 避免 worker 拿到任务却没有节点权限的半途态。
72
- let grantNote = ''
73
- let grantedNodeIds: string[] = []
74
- const rawGrant = args.grant_node_ids ?? args.grantNodeIds
75
- if (rawGrant != null && identity) {
76
- const { grantNodesForDispatch } = await import('./team-delegation')
77
- const grantNodeIds = (Array.isArray(rawGrant) ? rawGrant : String(rawGrant).split(',')).map(x => String(x ?? '').trim()).filter(Boolean)
78
- if (!grantNodeIds.length) return { text: 'grant_node_ids 为空:要么不传,要么给出至少一个节点 id。', isError: true }
79
- const grantMode = args.grant_mode === 'manual' || args.grant_mode === 'auto' ? (args.grant_mode as 'auto' | 'manual') : undefined
80
- const grant = await grantNodesForDispatch(identity, assigneeId, grantNodeIds, grantMode, ws, args.grant_confirm)
81
- if (!grant.ok) return { text: `未派发:${grant.text}\n请先用 team_grant_nodes 确认你持有这些节点,或修正 node id 后重试。`, isError: true }
82
- grantedNodeIds = grantNodeIds
83
- grantNote = `\n${grant.text}`
84
- }
85
75
  try {
76
+ currentExecutionScope()?.assertActive()
86
77
  const task = await ws.dispatchTask({ assigneeId, title, description, parentTaskId, routeReason })
87
- return { text: `子任务 ${task.id} 已创建并指派 → ${assigneeId}(父任务 ${parentTaskId ?? '无'},标题: ${title}${routeReason ? `,路由理由: ${routeReason}` : ''})${grantNote}` }
78
+ return { text: `子任务 ${task.id} 已创建并指派 → ${assigneeId}(父任务 ${parentTaskId ?? '无'},标题: ${title}${routeReason ? `,路由理由: ${routeReason}` : ''})` }
88
79
  }
89
80
  catch (err) {
90
- // 2026-10-30 修复(授权-任务绑定不变量):manager 侧判重 409/父任务终态/harness
91
- // 不可用/预算超限等拒绝发生在授权落库之后 —— 任务没创建,节点授权已生效。
92
- // 失败即回滚本轮授权再如实回报,杜绝「派发失败留下无任务授权」。
93
- if (grantedNodeIds.length && identity) {
94
- const { revokeNodesForDispatchRollback } = await import('./team-delegation')
95
- const revoked = await revokeNodesForDispatchRollback(identity, assigneeId, grantedNodeIds, ws)
96
- grantNote = revoked > 0 ? `\n(派发失败,已回滚本轮 ${revoked} 条随单授权)` : '\n(派发失败;随单授权回滚未完成,请用 team_revoke_nodes 手工核销)'
97
- }
98
81
  const msg = err instanceof Error ? err.message : String(err)
99
- return { text: `未派发:${msg}${grantNote}`, isError: true }
82
+ return { text: `未派发:${msg}`, isError: true }
100
83
  }
101
84
  }
102
85
 
@@ -1,129 +1,83 @@
1
- /**
2
- * 团队节点权限委派工具(lead 专属):team_grant_nodes / team_revoke_nodes。
3
- *
4
- * lead 把**自己已绑定**的 DAQ/DCW 节点授权给同频道 worker(派发前、执行中均可),
5
- * 授权面不可超越 lead 本人的绑定面(planDelegation fail-closed 校验)。
6
- * 校验核心在 agents/node-delegation.ts;本文件只做工具面参数解析与结果文本。
7
- */
8
- import { AppError } from '../../../../../utils/errors'
9
- import { applyDelegation, planDelegation, revokeDelegation, type DelegationMember } from '../../node-delegation'
10
- import type { HostToolBridgeContext, HostToolResult } from '../types'
11
-
12
- /** workspace 成员视图(listAgents 与本工具面的最小接口;便于单测桩替换) */
13
- interface MembersView {
14
- listAgents(): Promise<Array<{ id: string, role: 'lead' | 'worker', enabled?: number }>>
15
- }
16
-
17
- function membersOf(ws: MembersView): Promise<DelegationMember[]> {
18
- return ws.listAgents() as Promise<DelegationMember[]>
19
- }
20
-
21
- function summaryText(bindings: Array<{ nodeId: string, kind: string, mode: string }>): string {
22
- const kindLabel: Record<string, string> = { 'daq': '数采', 'dcw': '写控', 'line-recipe': '产线配方管理' }
23
- const lines = bindings.map(b => ` - ${kindLabel[b.kind] ?? b.kind} ${b.nodeId}(mode=${b.mode})`)
24
- return `\n${lines.join('\n')}`
25
- }
26
-
27
- function parseNodeIds(args: Record<string, unknown>): string[] {
28
- const raw = args.node_ids ?? args.nodeIds
29
- const list = Array.isArray(raw) ? raw : String(raw ?? '').split(',')
30
- return list.map(x => String(x ?? '').trim()).filter(Boolean)
31
- }
32
-
33
- /** lead → worker 授予节点(自己绑定面内的节点;fail-closed 全成全败) */
34
- export async function handleGrantNodes(identity: HostToolBridgeContext['identity'], args: Record<string, unknown>, ws: MembersView): Promise<HostToolResult> {
35
- const targetAgentId = String(args.agent_id ?? args.assignee_id ?? '').trim()
36
- const nodeIds = parseNodeIds(args)
37
- const mode = args.mode === 'manual' || args.mode === 'auto' ? (args.mode as 'auto' | 'manual') : undefined
38
- try {
39
- const plan = planDelegation({
40
- leaderAgentId: identity.agentId,
41
- channelId: identity.channelId,
42
- targetAgentId,
43
- nodeIds,
44
- members: await membersOf(ws),
45
- mode,
46
- // B-P1-3:mode=auto 摘除逐次人工审批,须显式风险确认(与 REST 同语义)
47
- confirm: args.confirm,
48
- })
49
- const bindings = applyDelegation(plan, identity.agentId)
50
- return {
51
- text: `已把 ${bindings.length} 条节点授权授予 ${targetAgentId}:${summaryText(bindings)}\n来源:lead 绑定面内的节点;worker 现在可用 my_industrial_nodes 查看自己的授权。`,
52
- }
53
- }
54
- catch (err) {
55
- return { text: err instanceof AppError ? err.message : `节点授权失败: ${err instanceof Error ? err.message : String(err)}`, isError: true }
56
- }
57
- }
58
-
59
- /** lead 收回授予给 worker 的节点授权 */
60
- export async function handleRevokeNodes(identity: HostToolBridgeContext['identity'], args: Record<string, unknown>, ws: MembersView): Promise<HostToolResult> {
61
- const targetAgentId = String(args.agent_id ?? args.assignee_id ?? '').trim()
62
- const nodeIds = parseNodeIds(args)
63
- try {
64
- const results = revokeDelegation({
65
- leaderAgentId: identity.agentId,
66
- targetAgentId,
67
- nodeIds,
68
- members: await membersOf(ws),
69
- })
70
- const okList = results.filter(r => r.revoked)
71
- const missList = results.filter(r => !r.revoked)
72
- const parts = [`已收回 ${okList.length} 条授权`, ...okList.map(r => ` - ${r.kind} ${r.nodeId}`)]
73
- if (missList.length) parts.push(`未收回(不在其绑定面或非你授予):${missList.map(r => `${r.kind}:${r.nodeId}`).join('、')}`)
74
- return { text: parts.join('\n') }
75
- }
76
- catch (err) {
77
- return { text: err instanceof AppError ? err.message : `收回授权失败: ${err instanceof Error ? err.message : String(err)}`, isError: true }
78
- }
79
- }
80
-
81
- export interface DispatchGrantResult {
82
- ok: boolean
83
- text: string
84
- }
85
-
86
- /**
87
- * 派发时随任务授予节点(dispatch_task 的 grant_node_ids;lead 专属)。
88
- * fail-closed:任一节点不在 lead 绑定面 → 整单失败,任务不创建。
89
- */
90
- export async function grantNodesForDispatch(identity: HostToolBridgeContext['identity'], assigneeId: string, nodeIds: string[], mode: 'auto' | 'manual' | undefined, ws: MembersView, confirm?: unknown): Promise<DispatchGrantResult> {
91
- try {
92
- const plan = planDelegation({
93
- leaderAgentId: identity.agentId,
94
- channelId: identity.channelId,
95
- targetAgentId: assigneeId,
96
- nodeIds,
97
- members: await membersOf(ws),
98
- mode,
99
- // B-P1-3:随任务授予同样不得绕过 auto 的显式确认(dispatch_task.grant_confirm)
100
- confirm,
101
- })
102
- const bindings = applyDelegation(plan, identity.agentId)
103
- return { ok: true, text: `随任务授予 ${bindings.length} 条节点授权 → ${assigneeId}${summaryText(bindings)}` }
104
- }
105
- catch (err) {
106
- const msg = err instanceof AppError ? err.message : `随任务授予节点失败: ${err instanceof Error ? err.message : String(err)}`
107
- return { ok: false, text: msg }
108
- }
109
- }
110
-
111
- /**
112
- * 2026-10-30 新增:dispatch 失败回滚 —— 尽力撤销 grantNodesForDispatch 刚落库的授权。
113
- * 授权-任务绑定不变量:任务没创建,授权不得残留(尤其 grant_mode=auto 摘过人工审批的)。
114
- * 返回实际撤销条数;任何异常按 0 处理(调用方如实标注"请手工核销")。
115
- */
116
- export async function revokeNodesForDispatchRollback(identity: HostToolBridgeContext['identity'], assigneeId: string, nodeIds: string[], ws: MembersView): Promise<number> {
117
- try {
118
- const results = revokeDelegation({
119
- leaderAgentId: identity.agentId,
120
- targetAgentId: assigneeId,
121
- nodeIds,
122
- members: await membersOf(ws),
123
- })
124
- return results.filter(r => r.revoked).length
125
- }
126
- catch {
127
- return 0
128
- }
129
- }
1
+ /**
2
+ * 团队节点权限委派工具(lead 专属):team_grant_nodes / team_revoke_nodes。
3
+ *
4
+ * lead 把**自己已绑定**的 DAQ/DCW 节点授权给同频道 worker(派发前、执行中均可),
5
+ * 授权面不可超越 lead 本人的绑定面(planDelegation fail-closed 校验)。
6
+ * 校验核心在 agents/node-delegation.ts;本文件只做工具面参数解析与结果文本。
7
+ */
8
+ import { AppError } from '../../../../../utils/errors'
9
+ import { applyDelegation, planDelegation, revokeDelegation, type DelegationMember } from '../../node-delegation'
10
+ import { currentExecutionScope } from '../../execution-scope'
11
+ import type { HostToolBridgeContext, HostToolResult } from '../types'
12
+
13
+ /** workspace 成员视图(listAgents 与本工具面的最小接口;便于单测桩替换) */
14
+ interface MembersView {
15
+ listAgents(): Promise<Array<{ id: string, role: 'lead' | 'worker', enabled?: number }>>
16
+ }
17
+
18
+ function membersOf(ws: MembersView): Promise<DelegationMember[]> {
19
+ return ws.listAgents() as Promise<DelegationMember[]>
20
+ }
21
+
22
+ function summaryText(bindings: Array<{ nodeId: string, kind: string, mode: string }>): string {
23
+ const kindLabel: Record<string, string> = { 'daq': '数采', 'dcw': '写控', 'line-recipe': '产线配方管理' }
24
+ const lines = bindings.map(b => ` - ${kindLabel[b.kind] ?? b.kind} ${b.nodeId}(mode=${b.mode})`)
25
+ return `\n${lines.join('\n')}`
26
+ }
27
+
28
+ function parseNodeIds(args: Record<string, unknown>): string[] {
29
+ const raw = args.node_ids ?? args.nodeIds
30
+ const list = Array.isArray(raw) ? raw : String(raw ?? '').split(',')
31
+ return list.map(x => String(x ?? '').trim()).filter(Boolean)
32
+ }
33
+
34
+ /** lead → worker 授予节点(自己绑定面内的节点;fail-closed 全成全败) */
35
+ export async function handleGrantNodes(identity: HostToolBridgeContext['identity'], args: Record<string, unknown>, ws: MembersView): Promise<HostToolResult> {
36
+ const targetAgentId = String(args.agent_id ?? args.assignee_id ?? '').trim()
37
+ const nodeIds = parseNodeIds(args)
38
+ const mode = args.mode === 'manual' || args.mode === 'auto' ? (args.mode as 'auto' | 'manual') : undefined
39
+ try {
40
+ const plan = planDelegation({
41
+ leaderAgentId: identity.agentId,
42
+ channelId: identity.channelId,
43
+ targetAgentId,
44
+ nodeIds,
45
+ members: await membersOf(ws),
46
+ mode,
47
+ // B-P1-3:mode=auto 摘除逐次人工审批,须显式风险确认(与 REST 同语义)
48
+ confirm: args.confirm,
49
+ })
50
+ currentExecutionScope()?.assertActive()
51
+ const bindings = applyDelegation(plan, identity.agentId)
52
+ return {
53
+ text: `已把 ${bindings.length} 条节点授权授予 ${targetAgentId}:${summaryText(bindings)}\n来源:lead 绑定面内的节点;worker 现在可用 my_industrial_nodes 查看自己的授权。`,
54
+ }
55
+ }
56
+ catch (err) {
57
+ return { text: err instanceof AppError ? err.message : `节点授权失败: ${err instanceof Error ? err.message : String(err)}`, isError: true }
58
+ }
59
+ }
60
+
61
+ /** lead 收回授予给 worker 的节点授权 */
62
+ export async function handleRevokeNodes(identity: HostToolBridgeContext['identity'], args: Record<string, unknown>, ws: MembersView): Promise<HostToolResult> {
63
+ const targetAgentId = String(args.agent_id ?? args.assignee_id ?? '').trim()
64
+ const nodeIds = parseNodeIds(args)
65
+ try {
66
+ const members = await membersOf(ws)
67
+ currentExecutionScope()?.assertActive()
68
+ const results = revokeDelegation({
69
+ leaderAgentId: identity.agentId,
70
+ targetAgentId,
71
+ nodeIds,
72
+ members,
73
+ })
74
+ const okList = results.filter(r => r.revoked)
75
+ const missList = results.filter(r => !r.revoked)
76
+ const parts = [`已收回 ${okList.length} 条授权`, ...okList.map(r => ` - ${r.kind} ${r.nodeId}`)]
77
+ if (missList.length) parts.push(`未收回(不在其绑定面或非你授予):${missList.map(r => `${r.kind}:${r.nodeId}`).join('、')}`)
78
+ return { text: parts.join('\n') }
79
+ }
80
+ catch (err) {
81
+ return { text: err instanceof AppError ? err.message : `收回授权失败: ${err instanceof Error ? err.message : String(err)}`, isError: true }
82
+ }
83
+ }