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
@@ -1,145 +1,149 @@
1
- #!/usr/bin/env node
2
- /**
3
- * scripts/onboarding/verify-mirror.mjs —— 镜像采集/导出正确性验收(只读)。
4
- *
5
- * 在模拟端点跑通后,用它回答“数据真的按文档值落库了吗?”:
6
- * scalar: 窗口内有样本,且至少一个桶的 avg/min/max 命中期望值(容差内)
7
- * vector: 窗口内有帧,点数/指标/首末点符合期望
8
- * image : 窗口内有帧,objectKey/mime/宽高存在,内容端点返回非空字节
9
- *
10
- * 用法:
11
- * node scripts/onboarding/verify-mirror.mjs --node dn-xxx --kind scalar \
12
- * --expect '{"value":25.3,"tolerance":0.2}' [--window-ms 120000] [--json]
13
- *
14
- * 鉴权:--token / AW_TOKEN;缺省用 AW_EMAIL/AW_PASS 登录(默认 admin@awshop.local/admin123)。
15
- * 只读:不写库、不改节点、不触发采集控制。
16
- */
17
- const args = process.argv.slice(2)
18
- const flag = n => args.includes(`--${n}`)
19
- const valueOf = (n) => {
20
- const i = args.indexOf(`--${n}`)
21
- return i >= 0 ? args[i + 1] : undefined
22
- }
23
- const BASE = (valueOf('base') ?? process.env.AW_BASE ?? 'http://127.0.0.1:3001').replace(/\/+$/, '')
24
- const NODE = valueOf('node') ?? ''
25
- const KIND = (valueOf('kind') ?? 'scalar').toLowerCase()
26
- const WINDOW_MS = Math.max(5000, Number(valueOf('window-ms') ?? 120000))
27
- const MIN_SAMPLES = Math.max(1, Number(valueOf('min-samples') ?? 1))
28
- const EXPECT = JSON.parse(valueOf('expect') ?? '{}')
29
- const JSON_OUT = flag('json')
30
-
31
- if (!NODE) {
32
- console.error('用法: node scripts/onboarding/verify-mirror.mjs --node <id> [--kind scalar|vector|image] [--expect <json>]')
33
- process.exit(2)
34
- }
35
- if (!['scalar', 'vector', 'image'].includes(KIND)) {
36
- console.error(`--kind 必须是 scalar|vector|image(收到 ${KIND})`)
37
- process.exit(2)
38
- }
39
-
40
- let token = valueOf('token') ?? process.env.AW_TOKEN ?? ''
41
- const results = []
42
- const ok = (name, cond, detail = '') => {
43
- results.push({ name, pass: Boolean(cond), detail: String(detail).slice(0, 600) })
44
- if (!JSON_OUT) console.log(`${cond ? '✅' : '❌'} ${name}${detail ? ` — ${detail}` : ''}`)
45
- return Boolean(cond)
46
- }
47
-
48
- async function api(method, path, body) {
49
- const headers = { accept: 'application/json' }
50
- if (token) headers.authorization = `Bearer ${token}`
51
- if (body !== undefined) headers['content-type'] = 'application/json'
52
- const res = await fetch(BASE + path, {
53
- method,
54
- headers,
55
- body: body === undefined ? undefined : JSON.stringify(body),
56
- redirect: 'manual',
57
- signal: AbortSignal.timeout(20000),
58
- })
59
- const json = await res.json().catch(() => null)
60
- if (!res.ok) throw new Error(`${method} ${path} → ${res.status} ${json?.message ?? ''}`)
61
- if (json && typeof json === 'object' && 'code' in json && json.code !== 0) {
62
- throw new Error(`${method} ${path} → code ${json.code} ${json.message ?? ''}`)
63
- }
64
- return json?.data ?? json
65
- }
66
-
67
- async function login() {
68
- if (token) return
69
- const email = process.env.AW_EMAIL ?? 'admin@awshop.local'
70
- const password = process.env.AW_PASS ?? 'admin123'
71
- const d = await api('POST', '/api/users/login', { email, password })
72
- token = d?.token ?? ''
73
- if (!token) throw new Error('登录失败:未拿到 token(可用 AW_TOKEN 覆盖)')
74
- }
75
-
76
- const near = (a, b, tol) => Number.isFinite(a) && Number.isFinite(b) && Math.abs(a - b) <= tol
77
-
78
- try {
79
- await login()
80
- const to = Date.now()
81
- const from = to - WINDOW_MS
82
-
83
- if (KIND === 'scalar') {
84
- const d = await api('GET', `/api/workshop/daq/${encodeURIComponent(NODE)}/samples?from=${from}&to=${to}&bucketMs=1000&limit=1000`)
85
- const points = d?.points ?? []
86
- const total = points.reduce((s, p) => s + (Number(p.cnt) || 0), 0)
87
- ok('scalar:窗口内有样本', total >= MIN_SAMPLES, `buckets=${points.length} samples=${total} window=${Math.round(WINDOW_MS / 1000)}s`)
88
- if (EXPECT.value !== undefined) {
89
- const tol = Number(EXPECT.tolerance ?? 0)
90
- const hit = points.some(p => near(Number(p.avg), Number(EXPECT.value), tol) || near(Number(p.min), Number(EXPECT.value), tol) || near(Number(p.max), Number(EXPECT.value), tol))
91
- ok('scalar:期望值命中', hit, `expect=${EXPECT.value}±${tol} observed=${points.slice(-4).map(p => p.avg).join(',')}`)
92
- }
93
- ok('scalar:时间戳单调', points.every((p, i) => i === 0 || Number(p.at) >= Number(points[i - 1].at)), `last=${points.at(-1)?.at ?? '-'}`)
94
- }
95
- else if (KIND === 'vector') {
96
- const d = await api('GET', `/api/workshop/daq/${encodeURIComponent(NODE)}/frames?from=${from}&to=${to}&kind=vector&limit=200`)
97
- const frames = d?.frames ?? []
98
- ok('vector:窗口内有帧', frames.length >= MIN_SAMPLES, `frames=${frames.length}`)
99
- const f = frames.at(-1)
100
- if (f) {
101
- if (EXPECT.points !== undefined) ok('vector:点数符合期望', (f.points?.length ?? 0) === Number(EXPECT.points), `expect=${EXPECT.points} actual=${f.points?.length}`)
102
- if (EXPECT.metrics && typeof EXPECT.metrics === 'object') {
103
- for (const [k, v] of Object.entries(EXPECT.metrics)) {
104
- ok(`vector:指标 ${k}`, near(Number(f.metrics?.[k]), Number(v), Number(EXPECT.tolerance ?? 0)), `expect=${v} actual=${f.metrics?.[k]}`)
105
- }
106
- }
107
- if (EXPECT.first !== undefined) ok('vector:首点符合期望', near(Number(f.points?.[0]), Number(EXPECT.first), Number(EXPECT.tolerance ?? 0)), `expect=${EXPECT.first} actual=${f.points?.[0]}`)
108
- if (EXPECT.last !== undefined) ok('vector:末点符合期望', near(Number(f.points?.at(-1)), Number(EXPECT.last), Number(EXPECT.tolerance ?? 0)), `expect=${EXPECT.last} actual=${f.points?.at(-1)}`)
109
- }
110
- }
111
- else {
112
- const d = await api('GET', `/api/workshop/daq/${encodeURIComponent(NODE)}/frames?from=${from}&to=${to}&kind=image&limit=20`)
113
- const frames = d?.frames ?? []
114
- ok('image:窗口内有帧', frames.length >= MIN_SAMPLES, `frames=${frames.length}`)
115
- const f = frames.at(-1)
116
- if (f) {
117
- ok('image:对象键存在', Boolean(f.meta?.objectKey), `objectKey=${f.meta?.objectKey ?? '-'}`)
118
- const mime = String(f.meta?.mime ?? '').toLowerCase()
119
- const raster = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/bmp', 'image/gif', 'image/tiff'])
120
- ok('image:MIME 为受支持的栅格类型', raster.has(mime), `mime=${mime}`)
121
- if (EXPECT.width) ok('image:宽度符合期望', Number(f.meta?.width) === Number(EXPECT.width), `expect=${EXPECT.width} actual=${f.meta?.width}`)
122
- if (EXPECT.height) ok('image:高度符合期望', Number(f.meta?.height) === Number(EXPECT.height), `expect=${EXPECT.height} actual=${f.meta?.height}`)
123
- if (f.contentUrl) {
124
- const res = await fetch(BASE + f.contentUrl, { headers: { authorization: `Bearer ${token}` }, redirect: 'manual', signal: AbortSignal.timeout(15000) })
125
- const buf = Buffer.from(await res.arrayBuffer())
126
- ok('image:内容端点返回非空字节', res.ok && buf.length > 0, `status=${res.status} bytes=${buf.length} type=${res.headers.get('content-type')}`)
127
- }
128
- }
129
- }
130
- }
131
- catch (err) {
132
- ok('请求/断言执行', false, err instanceof Error ? err.message : String(err))
133
- }
134
-
135
- const pass = results.filter(r => r.pass).length
136
- const verdict = pass === results.length ? 'PASS' : 'FAIL'
137
- if (JSON_OUT) {
138
- console.log(JSON.stringify({ suite: 'verify-mirror', node: NODE, kind: KIND, base: BASE, checks: results, verdict: `${verdict}(${pass}/${results.length})`, at: new Date().toISOString() }, null, 2))
139
- }
140
- else {
141
- console.log(`\n=== verify-mirror: ${pass}/${results.length} ${verdict} ===`)
142
- }
143
- process.exitCode = verdict === 'PASS' ? 0 : 1
144
- // 不立即 process.exit:Windows 上 undici socket 关闭中强退会触发 libuv 断言
145
- // (async.c UV_HANDLE_CLOSING)。设置 exitCode 后让事件循环自然退出。
1
+ #!/usr/bin/env node
2
+ /**
3
+ * scripts/onboarding/verify-mirror.mjs —— 镜像采集/导出正确性验收。
4
+ *
5
+ * 在模拟端点跑通后,用它回答“数据真的按文档值落库了吗?”:
6
+ * scalar: 窗口内有样本,且至少一个桶的 avg/min/max 命中期望值(容差内)
7
+ * vector: 窗口内有帧,点数/指标/首末点符合期望
8
+ * image : 窗口内有帧,objectKey/mime/宽高存在,内容端点返回非空字节
9
+ *
10
+ * 用法:
11
+ * node scripts/onboarding/verify-mirror.mjs --node dn-xxx --kind scalar \
12
+ * --expect '{"value":25.3,"tolerance":0.2}' [--window-ms 120000] [--json]
13
+ *
14
+ * 鉴权:--token / AW_TOKEN;缺省用 AW_EMAIL/AW_PASS 登录(默认 admin@awshop.local/admin123)。
15
+ * 请求可能初始化全局采集控制器,不能据 HTTP 方法推断无副作用。
16
+ */
17
+ import { assertOnboardingOwnership } from './lib.mjs'
18
+
19
+ await assertOnboardingOwnership()
20
+
21
+ const args = process.argv.slice(2)
22
+ const flag = n => args.includes(`--${n}`)
23
+ const valueOf = (n) => {
24
+ const i = args.indexOf(`--${n}`)
25
+ return i >= 0 ? args[i + 1] : undefined
26
+ }
27
+ const BASE = (valueOf('base') ?? process.env.AW_BASE ?? 'http://127.0.0.1:3001').replace(/\/+$/, '')
28
+ const NODE = valueOf('node') ?? ''
29
+ const KIND = (valueOf('kind') ?? 'scalar').toLowerCase()
30
+ const WINDOW_MS = Math.max(5000, Number(valueOf('window-ms') ?? 120000))
31
+ const MIN_SAMPLES = Math.max(1, Number(valueOf('min-samples') ?? 1))
32
+ const EXPECT = JSON.parse(valueOf('expect') ?? '{}')
33
+ const JSON_OUT = flag('json')
34
+
35
+ if (!NODE) {
36
+ console.error('用法: node scripts/onboarding/verify-mirror.mjs --node <id> [--kind scalar|vector|image] [--expect <json>]')
37
+ process.exit(2)
38
+ }
39
+ if (!['scalar', 'vector', 'image'].includes(KIND)) {
40
+ console.error(`--kind 必须是 scalar|vector|image(收到 ${KIND})`)
41
+ process.exit(2)
42
+ }
43
+
44
+ let token = valueOf('token') ?? process.env.AW_TOKEN ?? ''
45
+ const results = []
46
+ const ok = (name, cond, detail = '') => {
47
+ results.push({ name, pass: Boolean(cond), detail: String(detail).slice(0, 600) })
48
+ if (!JSON_OUT) console.log(`${cond ? '✅' : '❌'} ${name}${detail ? ` — ${detail}` : ''}`)
49
+ return Boolean(cond)
50
+ }
51
+
52
+ async function api(method, path, body) {
53
+ const headers = { accept: 'application/json' }
54
+ if (token) headers.authorization = `Bearer ${token}`
55
+ if (body !== undefined) headers['content-type'] = 'application/json'
56
+ const res = await fetch(BASE + path, {
57
+ method,
58
+ headers,
59
+ body: body === undefined ? undefined : JSON.stringify(body),
60
+ redirect: 'manual',
61
+ signal: AbortSignal.timeout(20000),
62
+ })
63
+ const json = await res.json().catch(() => null)
64
+ if (!res.ok) throw new Error(`${method} ${path} → ${res.status} ${json?.message ?? ''}`)
65
+ if (json && typeof json === 'object' && 'code' in json && json.code !== 0) {
66
+ throw new Error(`${method} ${path} → code ${json.code} ${json.message ?? ''}`)
67
+ }
68
+ return json?.data ?? json
69
+ }
70
+
71
+ async function login() {
72
+ if (token) return
73
+ const email = process.env.AW_EMAIL ?? 'admin@awshop.local'
74
+ const password = process.env.AW_PASS ?? 'admin123'
75
+ const d = await api('POST', '/api/users/login', { email, password })
76
+ token = d?.token ?? ''
77
+ if (!token) throw new Error('登录失败:未拿到 token(可用 AW_TOKEN 覆盖)')
78
+ }
79
+
80
+ const near = (a, b, tol) => Number.isFinite(a) && Number.isFinite(b) && Math.abs(a - b) <= tol
81
+
82
+ try {
83
+ await login()
84
+ const to = Date.now()
85
+ const from = to - WINDOW_MS
86
+
87
+ if (KIND === 'scalar') {
88
+ const d = await api('GET', `/api/workshop/daq/${encodeURIComponent(NODE)}/samples?from=${from}&to=${to}&bucketMs=1000&limit=1000`)
89
+ const points = d?.points ?? []
90
+ const total = points.reduce((s, p) => s + (Number(p.cnt) || 0), 0)
91
+ ok('scalar:窗口内有样本', total >= MIN_SAMPLES, `buckets=${points.length} samples=${total} window=${Math.round(WINDOW_MS / 1000)}s`)
92
+ if (EXPECT.value !== undefined) {
93
+ const tol = Number(EXPECT.tolerance ?? 0)
94
+ const hit = points.some(p => near(Number(p.avg), Number(EXPECT.value), tol) || near(Number(p.min), Number(EXPECT.value), tol) || near(Number(p.max), Number(EXPECT.value), tol))
95
+ ok('scalar:期望值命中', hit, `expect=${EXPECT.value}±${tol} observed=${points.slice(-4).map(p => p.avg).join(',')}`)
96
+ }
97
+ ok('scalar:时间戳单调', points.every((p, i) => i === 0 || Number(p.at) >= Number(points[i - 1].at)), `last=${points.at(-1)?.at ?? '-'}`)
98
+ }
99
+ else if (KIND === 'vector') {
100
+ const d = await api('GET', `/api/workshop/daq/${encodeURIComponent(NODE)}/frames?from=${from}&to=${to}&kind=vector&limit=200`)
101
+ const frames = d?.frames ?? []
102
+ ok('vector:窗口内有帧', frames.length >= MIN_SAMPLES, `frames=${frames.length}`)
103
+ const f = frames.at(-1)
104
+ if (f) {
105
+ if (EXPECT.points !== undefined) ok('vector:点数符合期望', (f.points?.length ?? 0) === Number(EXPECT.points), `expect=${EXPECT.points} actual=${f.points?.length}`)
106
+ if (EXPECT.metrics && typeof EXPECT.metrics === 'object') {
107
+ for (const [k, v] of Object.entries(EXPECT.metrics)) {
108
+ ok(`vector:指标 ${k}`, near(Number(f.metrics?.[k]), Number(v), Number(EXPECT.tolerance ?? 0)), `expect=${v} actual=${f.metrics?.[k]}`)
109
+ }
110
+ }
111
+ if (EXPECT.first !== undefined) ok('vector:首点符合期望', near(Number(f.points?.[0]), Number(EXPECT.first), Number(EXPECT.tolerance ?? 0)), `expect=${EXPECT.first} actual=${f.points?.[0]}`)
112
+ if (EXPECT.last !== undefined) ok('vector:末点符合期望', near(Number(f.points?.at(-1)), Number(EXPECT.last), Number(EXPECT.tolerance ?? 0)), `expect=${EXPECT.last} actual=${f.points?.at(-1)}`)
113
+ }
114
+ }
115
+ else {
116
+ const d = await api('GET', `/api/workshop/daq/${encodeURIComponent(NODE)}/frames?from=${from}&to=${to}&kind=image&limit=20`)
117
+ const frames = d?.frames ?? []
118
+ ok('image:窗口内有帧', frames.length >= MIN_SAMPLES, `frames=${frames.length}`)
119
+ const f = frames.at(-1)
120
+ if (f) {
121
+ ok('image:对象键存在', Boolean(f.meta?.objectKey), `objectKey=${f.meta?.objectKey ?? '-'}`)
122
+ const mime = String(f.meta?.mime ?? '').toLowerCase()
123
+ const raster = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/bmp', 'image/gif', 'image/tiff'])
124
+ ok('image:MIME 为受支持的栅格类型', raster.has(mime), `mime=${mime}`)
125
+ if (EXPECT.width) ok('image:宽度符合期望', Number(f.meta?.width) === Number(EXPECT.width), `expect=${EXPECT.width} actual=${f.meta?.width}`)
126
+ if (EXPECT.height) ok('image:高度符合期望', Number(f.meta?.height) === Number(EXPECT.height), `expect=${EXPECT.height} actual=${f.meta?.height}`)
127
+ if (f.contentUrl) {
128
+ const res = await fetch(BASE + f.contentUrl, { headers: { authorization: `Bearer ${token}` }, redirect: 'manual', signal: AbortSignal.timeout(15000) })
129
+ const buf = Buffer.from(await res.arrayBuffer())
130
+ ok('image:内容端点返回非空字节', res.ok && buf.length > 0, `status=${res.status} bytes=${buf.length} type=${res.headers.get('content-type')}`)
131
+ }
132
+ }
133
+ }
134
+ }
135
+ catch (err) {
136
+ ok('请求/断言执行', false, err instanceof Error ? err.message : String(err))
137
+ }
138
+
139
+ const pass = results.filter(r => r.pass).length
140
+ const verdict = pass === results.length ? 'PASS' : 'FAIL'
141
+ if (JSON_OUT) {
142
+ console.log(JSON.stringify({ suite: 'verify-mirror', node: NODE, kind: KIND, base: BASE, checks: results, verdict: `${verdict}(${pass}/${results.length})`, at: new Date().toISOString() }, null, 2))
143
+ }
144
+ else {
145
+ console.log(`\n=== verify-mirror: ${pass}/${results.length} ${verdict} ===`)
146
+ }
147
+ process.exitCode = verdict === 'PASS' ? 0 : 1
148
+ // 不立即 process.exit:Windows 上 undici socket 关闭中强退会触发 libuv 断言
149
+ // (async.c UV_HANDLE_CLOSING)。设置 exitCode 后让事件循环自然退出。
@@ -13,6 +13,14 @@ import { getQuery, getHeader, setHeader, setResponseStatus, defineEventHandler }
13
13
  import { resolveUser } from '@/server/api/workshop/caller'
14
14
  import { AppError } from '@/server/utils/errors'
15
15
  import { getWorkshopManager } from '@/server/plugins/workshop'
16
+ import { HOST_TOOLS } from '@/server/services/workshop/agents/host-tool-bridge'
17
+ import { listPluginTools } from '@/server/services/workshop/agents/plugin-tools'
18
+ import { allowedWithoutTurnProvenance } from '@/server/services/workshop/agents/tool-classes'
19
+
20
+ function allowedForAgentToken(name: string): boolean {
21
+ const isBuiltin = HOST_TOOLS.some(tool => tool.name === name)
22
+ return allowedWithoutTurnProvenance(name, isBuiltin, isBuiltin ? undefined : listPluginTools().get(name))
23
+ }
16
24
 
17
25
  /** 稳定序列化(键排序;数组保序)+ 弱 ETag */
18
26
  function weakEtagOf(tools: unknown): string {
@@ -47,7 +55,8 @@ export default defineEventHandler(async (event) => {
47
55
  throw new AppError(403, 'SCOPE_VIOLATION', '该 Agent 所属 Channel 对你不可见,无权读取其工具面')
48
56
  }
49
57
  }
50
- const tools = manager.hostToolDefsFor(agentId)
58
+ const definitions = manager.hostToolDefsFor(agentId)
59
+ const tools = agentToken ? definitions.filter(tool => allowedForAgentToken(tool.name)) : definitions
51
60
  const etag = weakEtagOf(tools)
52
61
  setHeader(event, 'ETag', etag)
53
62
  setHeader(event, 'Cache-Control', 'no-cache')
@@ -0,0 +1,32 @@
1
+ /**
2
+ * POST /api/workshop/tasks/:id/recovery-disposition —— 显式释放 legacy 恢复保留(admin only)。
3
+ * 处置语义(fail-closed 设计的另一半):
4
+ * - action 必须 = "release"(显式操作,无默认行为);note 记入审计
5
+ * - 清除本连接树上全部 hold 标记(保留其余 close_reason 内容)
6
+ * - 在飞 consuming 消息按重投预算复位(pending/dead);pending 联动消息自动恢复可投递
7
+ * - 任务状态不改动:重新执行必须走显式 retry/reopen,绝不自动重放
8
+ * - 全程写 audit_log(task.recovery_disposition)
9
+ */
10
+ import { getRouterParam, readBody } from 'h3'
11
+ import { requireAdmin } from '@/server/api/workshop/caller'
12
+ import { AppError } from '@/server/utils/errors'
13
+ import { defineApiHandler } from '@/server/utils/response'
14
+ import { getWorkshopManager } from '@/server/plugins/workshop'
15
+ import type { AgentChannelManager } from '@/server/services/workshop/runtime/manager'
16
+ import type { TaskEngine } from '@/server/services/workshop/runtime/agent-runtime'
17
+
18
+ function taskEngineOf(manager: AgentChannelManager): TaskEngine {
19
+ return (manager as unknown as { getTaskEngine(): TaskEngine }).getTaskEngine()
20
+ }
21
+
22
+ export default defineApiHandler(async (event) => {
23
+ const taskId = getRouterParam(event, 'id')!
24
+ const user = requireAdmin(event)
25
+ const body = await readBody<{ action?: string, note?: string }>(event) ?? {}
26
+ if (body.action !== 'release') {
27
+ throw new AppError(400, 'VALIDATION_ERROR', 'action 必须显式为 "release"(处置无默认行为)')
28
+ }
29
+ const manager = getWorkshopManager()
30
+ const engine = taskEngineOf(manager)
31
+ return engine.disposeLegacyRecoveryHold(taskId, { id: user.id, name: user.name }, body.note)
32
+ })
@@ -0,0 +1,22 @@
1
+ /**
2
+ * GET /api/workshop/tasks/recovery-holds —— legacy 恢复保留清单(运维处置面)。
3
+ * admin only:返回当前全部 hold 任务(连接树成员、close_reason、树内消息计数),
4
+ * 供操作员在显式处置(recovery-disposition)前调查。只读,不触发任何重放。
5
+ */
6
+ import { requireAdmin } from '@/server/api/workshop/caller'
7
+ import { defineApiHandler } from '@/server/utils/response'
8
+ import { getWorkshopManager } from '@/server/plugins/workshop'
9
+ import type { AgentChannelManager } from '@/server/services/workshop/runtime/manager'
10
+ import type { TaskEngine } from '@/server/services/workshop/runtime/agent-runtime'
11
+
12
+ /** manager 未公开 TaskEngine 访问;经内部方法只读获取(类型收窄,与 retry.post.ts 同口径) */
13
+ function taskEngineOf(manager: AgentChannelManager): TaskEngine {
14
+ return (manager as unknown as { getTaskEngine(): TaskEngine }).getTaskEngine()
15
+ }
16
+
17
+ export default defineApiHandler(async (event) => {
18
+ requireAdmin(event)
19
+ const manager = getWorkshopManager()
20
+ const engine = taskEngineOf(manager)
21
+ return { holds: engine.listLegacyRecoveryHolds() }
22
+ })
@@ -133,6 +133,24 @@ export default {
133
133
 
134
134
  const outboundOff = () => ({ ok: false, error: '出站调用已禁用:kv["kb.base_url"] 非法(仅允许 http/https 且 host 为 127.0.0.1/localhost)' })
135
135
 
136
+ // kb_agent 失败分类文案(2026-11-16 实测回归):过去一切失败都套同一句
137
+ // "请确认 rag-knowledge web 已启动" —— 401(token 过期)时把人引去查一个活着的
138
+ // web,完全误导。按 status/错误形态分四类给出可执行的下一步。
139
+ const describeKbFailure = (r) => {
140
+ const st = Number(r?.status ?? 0)
141
+ const raw = String(r?.error ?? '')
142
+ if (st === 401 || st === 403) {
143
+ return `rag-knowledge Token 被拒绝(HTTP ${st}):token 可能已过期或权限不足 —— 请在设置页「rag-knowledge 鉴权」轮换 plugins.rag-bridge.token 后重试(web/backend 本身不受影响)。`
144
+ }
145
+ if (/abort|timeout|timed?\s*out/i.test(raw)) {
146
+ return `等待窗内知识库 Agent 未返回终态(${raw})——知识库内部执行慢或连接被对端挂断。建议改用 mode:'async' 提交,再用 kb_agent_status(task_id, wait_seconds=120) 轮询结果。`
147
+ }
148
+ if (/fetch failed|ECONN|socket|network/i.test(raw)) {
149
+ return `到 rag-knowledge web(${web()})的请求失败(${raw})。请确认 web/backend 存活;若两者健康(可用 /api/plugins/rag-bridge/health 核对),多为知识库内部 agent 回合挂断 —— 同样建议改用 async + kb_agent_status。`
150
+ }
151
+ return raw || '未知错误'
152
+ }
153
+
136
154
  // ================= 异步任务生命周期(提交 → 跟踪 → 进度/结果 → 回执) =================
137
155
  // rag-knowledge web 的任务登记表是进程内 Map(TTL 2h / 200 条),进程重启即丢失;
138
156
  // 这里把 task_id 与发起者归因落到插件 kv,15s 轮询终态并主动投递平台通告 ——
@@ -325,7 +343,7 @@ export default {
325
343
  // 异步:立即返回 task_id,知识库后台完成;结果稍后用 kb_agent_status 查询
326
344
  const sub = await ragCall('POST', web() + '/api/kb/agent/chat', body, { timeoutMs: 30000, retries: 0 })
327
345
  if (!sub.ok) {
328
- return { text: '知识库异步任务提交失败:' + String(sub.error ?? '').slice(0, 200) + '。请确认 rag-knowledge web(' + web() + ') 已启动后重试。', isError: true }
346
+ return { text: '知识库异步任务提交失败:' + describeKbFailure(sub), isError: true }
329
347
  }
330
348
  const taskId = String(sub.body?.task_id ?? '')
331
349
  if (!taskId) return { text: '知识库异步任务提交异常:响应缺少 task_id。', isError: true }
@@ -344,7 +362,7 @@ export default {
344
362
  // 同步请求禁止网络重试:POST 可能已在知识库侧启动回合,重试会重复入库/重复生成
345
363
  const r = await ragCall('POST', web() + '/api/kb/agent/chat', body, { timeoutMs: waitSec * 1000 + 30000, retries: 0 })
346
364
  if (!r.ok) {
347
- return { text: '知识库 Agent 调用失败(本次调用即终态,失败结果已如实返回):' + String(r.error ?? '').slice(0, 300) + '。请确认 rag-knowledge web(' + web() + ') 已启动后重试。', isError: true }
365
+ return { text: '知识库 Agent 调用失败(本次调用即终态,失败结果已如实返回):' + describeKbFailure(r), isError: true }
348
366
  }
349
367
  const reply = String(r.body?.reply ?? '').trim()
350
368
  return { text: '✅ 知识库任务完成(等待到终态)。\n\n' + (reply || '(知识库 Agent 返回空回复)') }
@@ -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 的每轮监督都会在