agentworkshop 0.8.1 → 0.8.3

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 (1563) hide show
  1. package/.output/.AgentWorkShop/aml-python/train-example.py +92 -92
  2. package/.output/nitro.json +1 -1
  3. package/.output/public/_nuxt/{BCLUwdP52.js → 39W1CH-l2.js} +1 -1
  4. package/.output/public/_nuxt/7xbYPfY6.js +1 -0
  5. package/.output/public/_nuxt/{BfvuWqSa.js → ATAvN55g.js} +1 -1
  6. package/.output/public/_nuxt/{B2NbzUau2.js → B3eCVqcT2.js} +1 -1
  7. package/.output/public/_nuxt/{DuUc4bbY2.js → B9qIhT7k2.js} +1 -1
  8. package/.output/public/_nuxt/{BkEokGX5.js → BE9oKpOt.js} +1 -1
  9. package/.output/public/_nuxt/{D_59BNP1.js → Bbk1XCCM.js} +3 -3
  10. package/.output/public/_nuxt/{Dz9C2pTa.js → CMzExk8F.js} +1 -1
  11. package/.output/public/_nuxt/{dHwWyr6b.js → CT4bi_Y4.js} +1 -1
  12. package/.output/public/_nuxt/{26OL4Ao82.js → CeCSjB9O2.js} +1 -1
  13. package/.output/public/_nuxt/{Dyxf2xZw.js → Cot5VNae.js} +1 -1
  14. package/.output/public/_nuxt/{BVg2R2VB2.js → Crf8_Ad02.js} +1 -1
  15. package/.output/public/_nuxt/{rDvMijKA.js → D9tNM-1a.js} +2 -2
  16. package/.output/public/_nuxt/{YAA98rWJ.js → DAug2CPf.js} +7 -7
  17. package/.output/public/_nuxt/{CQSxS_Ek.js → DbhTN7-T.js} +1 -1
  18. package/.output/public/_nuxt/DgGzwjAr2.js +2 -0
  19. package/.output/public/_nuxt/DkRozlDP2.js +1 -0
  20. package/.output/public/_nuxt/{DGu_fna7.js → DoChWkff.js} +1 -1
  21. package/.output/public/_nuxt/{Byiiiwc72.js → DxH5focQ2.js} +1 -1
  22. package/.output/public/_nuxt/Dyr3LPGL.js +1 -0
  23. package/.output/public/_nuxt/{CC2Pv8VL2.js → MC_i34H42.js} +1 -1
  24. package/.output/public/_nuxt/OmpTerminalPanel.DMWgGwDs.css +1 -0
  25. package/.output/public/_nuxt/PluginSlot.BqBzLD4T.css +1 -0
  26. package/.output/public/_nuxt/TownView.Cn8SPG7S.css +1 -0
  27. package/.output/public/_nuxt/{CmuGMxDP.js → TugRY_4O.js} +1 -1
  28. package/.output/public/_nuxt/{BPUQZ9Lq2.js → WybiLTow2.js} +1 -1
  29. package/.output/public/_nuxt/{BaYDgyaR.js → Zn0BZpf0.js} +3 -3
  30. package/.output/public/_nuxt/{_id_.BQRWK7J2.css → _id_.Be5JaH-P.css} +1 -1
  31. package/.output/public/_nuxt/{_wsId_.DCnKQQdY.css → _wsId_.p_vAYtTp.css} +1 -1
  32. package/.output/public/_nuxt/{agents.D-JPovTZ.css → agents.CRomddYR.css} +1 -1
  33. package/.output/public/_nuxt/aml.DgOMpDpv.css +1 -0
  34. package/.output/public/_nuxt/builds/latest.json +1 -1
  35. package/.output/public/_nuxt/builds/meta/fd0033e4-1eaa-42f8-9a04-3132717a703b.json +1 -0
  36. package/.output/public/_nuxt/{default.BEXGWZFQ.css → default.CpAx70gC.css} +1 -1
  37. package/.output/public/_nuxt/{logs.BkJPbR_K.css → logs.DcSvz6vi.css} +1 -1
  38. package/.output/public/_nuxt/{monitor.D3yEqqrv.css → monitor.OoNTwfMJ.css} +1 -1
  39. package/.output/public/_nuxt/{ontology.B_3Wn907.css → ontology.JqJ6PjV1.css} +1 -1
  40. package/.output/public/_nuxt/{operations.-l6u44Ar.css → operations.C48ggFa5.css} +1 -1
  41. package/.output/public/_nuxt/{pages.Cdpm_B-G.css → pages.Dpa28tJW.css} +1 -1
  42. package/.output/public/_nuxt/permissions.CrV-4t-6.css +1 -0
  43. package/.output/public/_nuxt/{BfeXib9G.js → rcdmiszh2.js} +1 -1
  44. package/.output/public/_nuxt/schedules.DYWOjGHm.css +1 -0
  45. package/.output/public/_nuxt/{teams.CLQaXno5.css → teams.DEJoJ4QV.css} +1 -1
  46. package/.output/public/_nuxt/{tokens.BDSUWF-L.css → tokens.DKZWCP5v.css} +1 -1
  47. package/.output/public/_nuxt/tools.DP-nsTli.css +1 -0
  48. package/.output/public/_nuxt/wK6Pp4Zc2.js +2 -0
  49. package/.output/public/_nuxt/{workshop.BBiFhXuM.css → workshop.PT1xhP8C.css} +1 -1
  50. package/.output/public/favicon.svg +14 -14
  51. package/.output/public/robots.txt +3 -3
  52. package/.output/server/chunks/_/LeftOutlined.mjs.map +1 -1
  53. package/.output/server/chunks/_/RightOutlined.mjs.map +1 -1
  54. package/.output/server/chunks/_/SearchOutlined.mjs +1230 -1261
  55. package/.output/server/chunks/_/SearchOutlined.mjs.map +1 -1
  56. package/.output/server/chunks/_/error-500.mjs.map +1 -1
  57. package/.output/server/chunks/_/nitro.mjs +3308 -3389
  58. package/.output/server/chunks/_/nitro.mjs.map +1 -1
  59. package/.output/server/chunks/build/AuthGate-G74Wr5IV.mjs +704 -0
  60. package/.output/server/chunks/build/AuthGate-G74Wr5IV.mjs.map +1 -0
  61. package/.output/server/chunks/build/FormItemContext-DmuQqaeJ.mjs +77 -0
  62. package/.output/server/chunks/build/FormItemContext-DmuQqaeJ.mjs.map +1 -0
  63. package/.output/server/chunks/build/OmpTerminalPanel-5cB-78zp.mjs +889 -0
  64. package/.output/server/chunks/build/OmpTerminalPanel-5cB-78zp.mjs.map +1 -0
  65. package/.output/server/chunks/build/PluginSlot-CZlGlRoR.mjs +131 -0
  66. package/.output/server/chunks/build/PluginSlot-CZlGlRoR.mjs.map +1 -0
  67. package/.output/server/chunks/build/TownView-CUbzOT_M.mjs +5960 -0
  68. package/.output/server/chunks/build/TownView-CUbzOT_M.mjs.map +1 -0
  69. package/.output/server/chunks/build/_id_-BHWZiRQZ.mjs +373 -0
  70. package/.output/server/chunks/build/_id_-BHWZiRQZ.mjs.map +1 -0
  71. package/.output/server/chunks/build/_id_-JaGx0yBE.mjs +1922 -0
  72. package/.output/server/chunks/build/_id_-JaGx0yBE.mjs.map +1 -0
  73. package/.output/server/chunks/build/_wsId_-C4DKkEqv.mjs +13707 -0
  74. package/.output/server/chunks/build/_wsId_-C4DKkEqv.mjs.map +1 -0
  75. package/.output/server/chunks/build/agents-DRod4lTC.mjs +1047 -0
  76. package/.output/server/chunks/build/agents-DRod4lTC.mjs.map +1 -0
  77. package/.output/server/chunks/build/alert-CNGhs--Y.mjs +260 -0
  78. package/.output/server/chunks/build/alert-CNGhs--Y.mjs.map +1 -0
  79. package/.output/server/chunks/build/aml-B3Umz4DR.mjs +729 -0
  80. package/.output/server/chunks/build/aml-B3Umz4DR.mjs.map +1 -0
  81. package/.output/server/chunks/build/analysis-tNpFLtMt.mjs +502 -0
  82. package/.output/server/chunks/build/analysis-tNpFLtMt.mjs.map +1 -0
  83. package/.output/server/chunks/build/{api-B4Om0mEc.mjs → api-D-zkgkj-.mjs} +8 -10
  84. package/.output/server/chunks/build/api-D-zkgkj-.mjs.map +1 -0
  85. package/.output/server/chunks/build/{api-BsAgXWxi.mjs → api-D3gy2e2q.mjs} +22 -24
  86. package/.output/server/chunks/build/api-D3gy2e2q.mjs.map +1 -0
  87. package/.output/server/chunks/build/{api-BEW_ebY_.mjs → api-bn4OKkl_.mjs} +17 -19
  88. package/.output/server/chunks/build/api-bn4OKkl_.mjs.map +1 -0
  89. package/.output/server/chunks/build/api-error-CnW_xiNI.mjs +46 -0
  90. package/.output/server/chunks/build/api-error-CnW_xiNI.mjs.map +1 -0
  91. package/.output/server/chunks/build/apiClient-DIXx9sfD.mjs +70 -0
  92. package/.output/server/chunks/build/apiClient-DIXx9sfD.mjs.map +1 -0
  93. package/.output/server/chunks/build/board-B2oYXGBy.mjs +172 -0
  94. package/.output/server/chunks/build/board-B2oYXGBy.mjs.map +1 -0
  95. package/.output/server/chunks/build/builtin-catalog-edpDcgfL.mjs +81 -94
  96. package/.output/server/chunks/build/builtin-catalog-edpDcgfL.mjs.map +1 -1
  97. package/.output/server/chunks/build/card-BECE6y_G.mjs +922 -0
  98. package/.output/server/chunks/build/card-BECE6y_G.mjs.map +1 -0
  99. package/.output/server/chunks/build/channel-templates-R2TInv8B.mjs +950 -0
  100. package/.output/server/chunks/build/channel-templates-R2TInv8B.mjs.map +1 -0
  101. package/.output/server/chunks/build/chart-trend-BWeZh5Lv.mjs +113 -112
  102. package/.output/server/chunks/build/chart-trend-BWeZh5Lv.mjs.map +1 -1
  103. package/.output/server/chunks/build/checkbox-C6xY5uc6.mjs +429 -0
  104. package/.output/server/chunks/build/checkbox-C6xY5uc6.mjs.map +1 -0
  105. package/.output/server/chunks/build/client-only-S7k53PIm.mjs +42 -0
  106. package/.output/server/chunks/build/client-only-S7k53PIm.mjs.map +1 -0
  107. package/.output/server/chunks/build/constants-HPHJvjne.mjs +65 -75
  108. package/.output/server/chunks/build/constants-HPHJvjne.mjs.map +1 -1
  109. package/.output/server/chunks/build/core-CRlsQhzd.mjs +292 -0
  110. package/.output/server/chunks/build/core-CRlsQhzd.mjs.map +1 -0
  111. package/.output/server/chunks/build/daq-DHsYtWC-.mjs +1210 -0
  112. package/.output/server/chunks/build/daq-DHsYtWC-.mjs.map +1 -0
  113. package/.output/server/chunks/build/data-Cl4wRZO6.mjs +459 -0
  114. package/.output/server/chunks/build/data-Cl4wRZO6.mjs.map +1 -0
  115. package/.output/server/chunks/build/dcw-DnjOM6p1.mjs +467 -0
  116. package/.output/server/chunks/build/dcw-DnjOM6p1.mjs.map +1 -0
  117. package/.output/server/chunks/build/dcw-driver-badge-Df5wL_ZA.mjs +3 -15
  118. package/.output/server/chunks/build/dcw-driver-badge-Df5wL_ZA.mjs.map +1 -1
  119. package/.output/server/chunks/build/default-DDRKP2Mb.mjs +2246 -0
  120. package/.output/server/chunks/build/default-DDRKP2Mb.mjs.map +1 -0
  121. package/.output/server/chunks/build/descriptions-B3uhDesi.mjs +401 -0
  122. package/.output/server/chunks/build/descriptions-B3uhDesi.mjs.map +1 -0
  123. package/.output/server/chunks/build/drawer-DwXxapMg.mjs +822 -0
  124. package/.output/server/chunks/build/drawer-DwXxapMg.mjs.map +1 -0
  125. package/.output/server/chunks/build/dropdown-DLrGy-Fs.mjs +12 -0
  126. package/.output/server/chunks/build/dropdown-DLrGy-Fs.mjs.map +1 -0
  127. package/.output/server/chunks/build/dropdown-nsGv8Gqx.mjs +530 -0
  128. package/.output/server/chunks/build/dropdown-nsGv8Gqx.mjs.map +1 -0
  129. package/.output/server/chunks/build/{es-Bxu10NJ2.mjs → es-DXSEkmAm.mjs} +1 -2
  130. package/.output/server/chunks/build/es-DXSEkmAm.mjs.map +1 -0
  131. package/.output/server/chunks/build/firstNotUndefined-laiThpLD.mjs +2082 -0
  132. package/.output/server/chunks/build/firstNotUndefined-laiThpLD.mjs.map +1 -0
  133. package/.output/server/chunks/build/form-Cw2Ex9w5.mjs +3543 -0
  134. package/.output/server/chunks/build/form-Cw2Ex9w5.mjs.map +1 -0
  135. package/.output/server/chunks/build/hasIn-RYRGomyg.mjs +192 -0
  136. package/.output/server/chunks/build/hasIn-RYRGomyg.mjs.map +1 -0
  137. package/.output/server/chunks/build/hitl-B4cHRlkC.mjs +120 -0
  138. package/.output/server/chunks/build/hitl-B4cHRlkC.mjs.map +1 -0
  139. package/.output/server/chunks/build/input-CJgB-RL6.mjs +1705 -0
  140. package/.output/server/chunks/build/input-CJgB-RL6.mjs.map +1 -0
  141. package/.output/server/chunks/build/input-number-CQKL42p_.mjs +1027 -0
  142. package/.output/server/chunks/build/input-number-CQKL42p_.mjs.map +1 -0
  143. package/.output/server/chunks/build/interval-DiAUqODq.mjs +8 -0
  144. package/.output/server/chunks/build/interval-DiAUqODq.mjs.map +1 -0
  145. package/.output/server/chunks/build/isNumeric-DQiJ-b15.mjs +6 -0
  146. package/.output/server/chunks/build/isNumeric-DQiJ-b15.mjs.map +1 -0
  147. package/.output/server/chunks/build/logs-C4vKFkHQ.mjs +381 -0
  148. package/.output/server/chunks/build/logs-C4vKFkHQ.mjs.map +1 -0
  149. package/.output/server/chunks/build/menu-xO8ocVtL.mjs +1833 -0
  150. package/.output/server/chunks/build/menu-xO8ocVtL.mjs.map +1 -0
  151. package/.output/server/chunks/build/monitor-BNrG6v3b.mjs +2216 -0
  152. package/.output/server/chunks/build/monitor-BNrG6v3b.mjs.map +1 -0
  153. package/.output/server/chunks/build/narrow-fetch-CcG-BPxc.mjs +0 -2
  154. package/.output/server/chunks/build/narrow-fetch-CcG-BPxc.mjs.map +1 -1
  155. package/.output/server/chunks/build/ontology-B_0Vm6j-.mjs +1416 -0
  156. package/.output/server/chunks/build/ontology-B_0Vm6j-.mjs.map +1 -0
  157. package/.output/server/chunks/build/operations-D8D6-Jm-.mjs +278 -0
  158. package/.output/server/chunks/build/operations-D8D6-Jm-.mjs.map +1 -0
  159. package/.output/server/chunks/build/optimizer-DaTyaY3c.mjs +202 -0
  160. package/.output/server/chunks/build/optimizer-DaTyaY3c.mjs.map +1 -0
  161. package/.output/server/chunks/build/pages-Dac4icQC.mjs +439 -0
  162. package/.output/server/chunks/build/pages-Dac4icQC.mjs.map +1 -0
  163. package/.output/server/chunks/build/pagination-BTzq7dD5.mjs +1330 -0
  164. package/.output/server/chunks/build/pagination-BTzq7dD5.mjs.map +1 -0
  165. package/.output/server/chunks/build/permissions-qmimwB0M.mjs +649 -0
  166. package/.output/server/chunks/build/permissions-qmimwB0M.mjs.map +1 -0
  167. package/.output/server/chunks/build/plugins-Dh_goy-k.mjs +269 -0
  168. package/.output/server/chunks/build/plugins-Dh_goy-k.mjs.map +1 -0
  169. package/.output/server/chunks/build/popconfirm-DuGF7ty-.mjs +333 -0
  170. package/.output/server/chunks/build/popconfirm-DuGF7ty-.mjs.map +1 -0
  171. package/.output/server/chunks/build/responsiveObserve-CzRpNXkr.mjs +77 -0
  172. package/.output/server/chunks/build/responsiveObserve-CzRpNXkr.mjs.map +1 -0
  173. package/.output/server/chunks/build/schedules-C2_x38gj.mjs +7039 -0
  174. package/.output/server/chunks/build/schedules-C2_x38gj.mjs.map +1 -0
  175. package/.output/server/chunks/build/segmented-29uEKZ3D.mjs +332 -0
  176. package/.output/server/chunks/build/segmented-29uEKZ3D.mjs.map +1 -0
  177. package/.output/server/chunks/build/select-CJb2XrQf.mjs +3734 -0
  178. package/.output/server/chunks/build/select-CJb2XrQf.mjs.map +1 -0
  179. package/.output/server/chunks/build/settings-Cz2Plds0.mjs +944 -0
  180. package/.output/server/chunks/build/settings-Cz2Plds0.mjs.map +1 -0
  181. package/.output/server/chunks/build/space-BByD-mFE.mjs +107 -0
  182. package/.output/server/chunks/build/space-BByD-mFE.mjs.map +1 -0
  183. package/.output/server/chunks/build/spin-XhbgGeLP.mjs +313 -0
  184. package/.output/server/chunks/build/spin-XhbgGeLP.mjs.map +1 -0
  185. package/.output/server/chunks/build/studio-CwYXl00G.mjs +329 -0
  186. package/.output/server/chunks/build/studio-CwYXl00G.mjs.map +1 -0
  187. package/.output/server/chunks/build/switch-DWcwVFxW.mjs +374 -0
  188. package/.output/server/chunks/build/switch-DWcwVFxW.mjs.map +1 -0
  189. package/.output/server/chunks/build/table-Zhuo7Fq-.mjs +7249 -0
  190. package/.output/server/chunks/build/table-Zhuo7Fq-.mjs.map +1 -0
  191. package/.output/server/chunks/build/tabs-BCwBXjNt.mjs +1838 -0
  192. package/.output/server/chunks/build/tabs-BCwBXjNt.mjs.map +1 -0
  193. package/.output/server/chunks/build/tag-CRW-anwy.mjs +1010 -0
  194. package/.output/server/chunks/build/tag-CRW-anwy.mjs.map +1 -0
  195. package/.output/server/chunks/build/teams-CwhFdcYn.mjs +1160 -0
  196. package/.output/server/chunks/build/teams-CwhFdcYn.mjs.map +1 -0
  197. package/.output/server/chunks/build/tokens-C5ODO1HA.mjs +992 -0
  198. package/.output/server/chunks/build/tokens-C5ODO1HA.mjs.map +1 -0
  199. package/.output/server/chunks/build/tools-C0YKragH.mjs +487 -0
  200. package/.output/server/chunks/build/tools-C0YKragH.mjs.map +1 -0
  201. package/.output/server/chunks/build/tooltip-GlMrUZzx.mjs +888 -0
  202. package/.output/server/chunks/build/tooltip-GlMrUZzx.mjs.map +1 -0
  203. package/.output/server/chunks/build/town-BV-hbwb5.mjs +16 -29
  204. package/.output/server/chunks/build/town-BV-hbwb5.mjs.map +1 -1
  205. package/.output/server/chunks/build/town-LkDwWnKA.mjs +117 -0
  206. package/.output/server/chunks/build/town-LkDwWnKA.mjs.map +1 -0
  207. package/.output/server/chunks/build/types-D6J7slEa.mjs.map +1 -1
  208. package/.output/server/chunks/build/types-DWqIeMRP.mjs +28 -29
  209. package/.output/server/chunks/build/types-DWqIeMRP.mjs.map +1 -1
  210. package/.output/server/chunks/build/useAgentHarnessOptions-CYKuLtZ2.mjs +120 -0
  211. package/.output/server/chunks/build/useAgentHarnessOptions-CYKuLtZ2.mjs.map +1 -0
  212. package/.output/server/chunks/build/useAgentTemplateActions-Da_V1LSD.mjs +71 -0
  213. package/.output/server/chunks/build/useAgentTemplateActions-Da_V1LSD.mjs.map +1 -0
  214. package/.output/server/chunks/build/useAgentTemplateDialogState-CZzpu5og.mjs +16 -23
  215. package/.output/server/chunks/build/useAgentTemplateDialogState-CZzpu5og.mjs.map +1 -1
  216. package/.output/server/chunks/build/useAgentTemplateForm-BWvax5_E.mjs +112 -0
  217. package/.output/server/chunks/build/useAgentTemplateForm-BWvax5_E.mjs.map +1 -0
  218. package/.output/server/chunks/build/useAgentTemplatesCatalog-BnYjZy59.mjs +140 -0
  219. package/.output/server/chunks/build/useAgentTemplatesCatalog-BnYjZy59.mjs.map +1 -0
  220. package/.output/server/chunks/build/useAmlDatasets-nGi10DAl.mjs +88 -0
  221. package/.output/server/chunks/build/useAmlDatasets-nGi10DAl.mjs.map +1 -0
  222. package/.output/server/chunks/build/useAmlEntities-CTgNAgcZ.mjs +79 -0
  223. package/.output/server/chunks/build/useAmlEntities-CTgNAgcZ.mjs.map +1 -0
  224. package/.output/server/chunks/build/useAmlEnv-Da2TVfyK.mjs +188 -0
  225. package/.output/server/chunks/build/useAmlEnv-Da2TVfyK.mjs.map +1 -0
  226. package/.output/server/chunks/build/useAmlExperiments-U9AQ52RI.mjs +86 -0
  227. package/.output/server/chunks/build/useAmlExperiments-U9AQ52RI.mjs.map +1 -0
  228. package/.output/server/chunks/build/useAmlFormat-C2sl3MGB.mjs +32 -37
  229. package/.output/server/chunks/build/useAmlFormat-C2sl3MGB.mjs.map +1 -1
  230. package/.output/server/chunks/build/useAmlJobs-BM1mu5iH.mjs +251 -0
  231. package/.output/server/chunks/build/useAmlJobs-BM1mu5iH.mjs.map +1 -0
  232. package/.output/server/chunks/build/useAmlModels-C1DwIOMi.mjs +90 -0
  233. package/.output/server/chunks/build/useAmlModels-C1DwIOMi.mjs.map +1 -0
  234. package/.output/server/chunks/build/useAmlNotes-CNm47QdS.mjs +80 -0
  235. package/.output/server/chunks/build/useAmlNotes-CNm47QdS.mjs.map +1 -0
  236. package/.output/server/chunks/build/useAmlPredict-m8I1AdRn.mjs +126 -0
  237. package/.output/server/chunks/build/useAmlPredict-m8I1AdRn.mjs.map +1 -0
  238. package/.output/server/chunks/build/useAnalysisFeed-CpbOaiBD.mjs +120 -0
  239. package/.output/server/chunks/build/useAnalysisFeed-CpbOaiBD.mjs.map +1 -0
  240. package/.output/server/chunks/build/useDaqAddNode-CRorxgOY.mjs +141 -0
  241. package/.output/server/chunks/build/useDaqAddNode-CRorxgOY.mjs.map +1 -0
  242. package/.output/server/chunks/build/useDaqDetailBinding-Ck-YUW9J.mjs +72 -0
  243. package/.output/server/chunks/build/useDaqDetailBinding-Ck-YUW9J.mjs.map +1 -0
  244. package/.output/server/chunks/build/useDaqDetailFrames-CLMoreaz.mjs +78 -0
  245. package/.output/server/chunks/build/useDaqDetailFrames-CLMoreaz.mjs.map +1 -0
  246. package/.output/server/chunks/build/useDaqDetailHistory-BVNQXwC_.mjs +166 -0
  247. package/.output/server/chunks/build/useDaqDetailHistory-BVNQXwC_.mjs.map +1 -0
  248. package/.output/server/chunks/build/useDaqDetailNode-BC0e9OfX.mjs +103 -0
  249. package/.output/server/chunks/build/useDaqDetailNode-BC0e9OfX.mjs.map +1 -0
  250. package/.output/server/chunks/build/useDaqDetailParams-D173iwFg.mjs +157 -0
  251. package/.output/server/chunks/build/useDaqDetailParams-D173iwFg.mjs.map +1 -0
  252. package/.output/server/chunks/build/useDaqFilters-CC-o_21d.mjs +224 -0
  253. package/.output/server/chunks/build/useDaqFilters-CC-o_21d.mjs.map +1 -0
  254. package/.output/server/chunks/build/useDaqNodeWindow-1DWj2H5G.mjs +43 -44
  255. package/.output/server/chunks/build/useDaqNodeWindow-1DWj2H5G.mjs.map +1 -1
  256. package/.output/server/chunks/build/useDaqOptimizations-4vK2w1yn.mjs +132 -0
  257. package/.output/server/chunks/build/useDaqOptimizations-4vK2w1yn.mjs.map +1 -0
  258. package/.output/server/chunks/build/useDaqStream-BHKpSJFd.mjs +385 -0
  259. package/.output/server/chunks/build/useDaqStream-BHKpSJFd.mjs.map +1 -0
  260. package/.output/server/chunks/build/useDaqTemplates-CsXSc7yI.mjs +181 -0
  261. package/.output/server/chunks/build/useDaqTemplates-CsXSc7yI.mjs.map +1 -0
  262. package/.output/server/chunks/build/useDashboardCharts-D45083s_.mjs +312 -310
  263. package/.output/server/chunks/build/useDashboardCharts-D45083s_.mjs.map +1 -1
  264. package/.output/server/chunks/build/useDashboardData-DuKjuJTz.mjs +139 -0
  265. package/.output/server/chunks/build/useDashboardData-DuKjuJTz.mjs.map +1 -0
  266. package/.output/server/chunks/build/useDcwAddNode-C5DcxsHF.mjs +217 -0
  267. package/.output/server/chunks/build/useDcwAddNode-C5DcxsHF.mjs.map +1 -0
  268. package/.output/server/chunks/build/{useDcwCards-SaiImIYQ.mjs → useDcwCards-0bAVo6uB.mjs} +20 -23
  269. package/.output/server/chunks/build/useDcwCards-0bAVo6uB.mjs.map +1 -0
  270. package/.output/server/chunks/build/useDcwDetailScope-BNFOlt2v.mjs +184 -0
  271. package/.output/server/chunks/build/useDcwDetailScope-BNFOlt2v.mjs.map +1 -0
  272. package/.output/server/chunks/build/useDcwDetailTemplates-DSH-o0tE.mjs +143 -0
  273. package/.output/server/chunks/build/useDcwDetailTemplates-DSH-o0tE.mjs.map +1 -0
  274. package/.output/server/chunks/build/useDcwFilter-W61BFUcT.mjs +65 -0
  275. package/.output/server/chunks/build/useDcwFilter-W61BFUcT.mjs.map +1 -0
  276. package/.output/server/chunks/build/{useDcwLedger-0ie-0WTc.mjs → useDcwLedger-DsColLdc.mjs} +29 -35
  277. package/.output/server/chunks/build/useDcwLedger-DsColLdc.mjs.map +1 -0
  278. package/.output/server/chunks/build/useDcwLineMutations-Cx4Ir7g3.mjs +133 -0
  279. package/.output/server/chunks/build/useDcwLineMutations-Cx4Ir7g3.mjs.map +1 -0
  280. package/.output/server/chunks/build/useDcwLineRun-DQ0vB08z.mjs +100 -0
  281. package/.output/server/chunks/build/useDcwLineRun-DQ0vB08z.mjs.map +1 -0
  282. package/.output/server/chunks/build/useDcwParamApprovals-CYspRuDk.mjs +119 -0
  283. package/.output/server/chunks/build/useDcwParamApprovals-CYspRuDk.mjs.map +1 -0
  284. package/.output/server/chunks/build/useDcwProducts-CTbm_5S_.mjs +88 -0
  285. package/.output/server/chunks/build/useDcwProducts-CTbm_5S_.mjs.map +1 -0
  286. package/.output/server/chunks/build/useDcwQuery-E0yjZs7G.mjs +93 -0
  287. package/.output/server/chunks/build/useDcwQuery-E0yjZs7G.mjs.map +1 -0
  288. package/.output/server/chunks/build/useDcwQuickActions-BvT5VFOY.mjs +84 -0
  289. package/.output/server/chunks/build/useDcwQuickActions-BvT5VFOY.mjs.map +1 -0
  290. package/.output/server/chunks/build/useDcwRecipes-zngShyk0.mjs +263 -0
  291. package/.output/server/chunks/build/useDcwRecipes-zngShyk0.mjs.map +1 -0
  292. package/.output/server/chunks/build/useDcwStream-82IdjJKk.mjs +455 -0
  293. package/.output/server/chunks/build/useDcwStream-82IdjJKk.mjs.map +1 -0
  294. package/.output/server/chunks/build/useDcwTemplates-CpHrcnvJ.mjs +87 -0
  295. package/.output/server/chunks/build/useDcwTemplates-CpHrcnvJ.mjs.map +1 -0
  296. package/.output/server/chunks/build/useDcwWrites-BlOhljp9.mjs +136 -0
  297. package/.output/server/chunks/build/useDcwWrites-BlOhljp9.mjs.map +1 -0
  298. package/.output/server/chunks/build/useDeviceTwins-DL-VLFeX.mjs +118 -0
  299. package/.output/server/chunks/build/useDeviceTwins-DL-VLFeX.mjs.map +1 -0
  300. package/.output/server/chunks/build/useExpConfirmations-DgwqTb9O.mjs +104 -0
  301. package/.output/server/chunks/build/useExpConfirmations-DgwqTb9O.mjs.map +1 -0
  302. package/.output/server/chunks/build/useLocalTime-C__kwn8h.mjs +52 -0
  303. package/.output/server/chunks/build/useLocalTime-C__kwn8h.mjs.map +1 -0
  304. package/.output/server/chunks/build/useLogsFormat-B-o4MHy7.mjs +30 -33
  305. package/.output/server/chunks/build/useLogsFormat-B-o4MHy7.mjs.map +1 -1
  306. package/.output/server/chunks/build/useLogsManual-BcfanT0s.mjs +80 -0
  307. package/.output/server/chunks/build/useLogsManual-BcfanT0s.mjs.map +1 -0
  308. package/.output/server/chunks/build/useLogsQuery-BGlKVKpV.mjs +136 -0
  309. package/.output/server/chunks/build/useLogsQuery-BGlKVKpV.mjs.map +1 -0
  310. package/.output/server/chunks/build/useLogsScope-BRyy550Y.mjs +75 -0
  311. package/.output/server/chunks/build/useLogsScope-BRyy550Y.mjs.map +1 -0
  312. package/.output/server/chunks/build/useMonitorColumns-vVnt3r5Q.mjs +155 -166
  313. package/.output/server/chunks/build/useMonitorColumns-vVnt3r5Q.mjs.map +1 -1
  314. package/.output/server/chunks/build/useMonitorData-BUey2Xly.mjs +128 -0
  315. package/.output/server/chunks/build/useMonitorData-BUey2Xly.mjs.map +1 -0
  316. package/.output/server/chunks/build/useMonitorFormat-rhs7FlNo.mjs +77 -0
  317. package/.output/server/chunks/build/useMonitorFormat-rhs7FlNo.mjs.map +1 -0
  318. package/.output/server/chunks/build/useMonitorTerminal-Dj4QwRNW.mjs +20 -27
  319. package/.output/server/chunks/build/useMonitorTerminal-Dj4QwRNW.mjs.map +1 -1
  320. package/.output/server/chunks/build/useOperationsFeed-DWfCjP4l.mjs +182 -0
  321. package/.output/server/chunks/build/useOperationsFeed-DWfCjP4l.mjs.map +1 -0
  322. package/.output/server/chunks/build/useOpsLog--yf8erUi.mjs +139 -0
  323. package/.output/server/chunks/build/useOpsLog--yf8erUi.mjs.map +1 -0
  324. package/.output/server/chunks/build/useRecipeDispatchApprovals-CKF2sB9P.mjs +146 -0
  325. package/.output/server/chunks/build/useRecipeDispatchApprovals-CKF2sB9P.mjs.map +1 -0
  326. package/.output/server/chunks/build/useResponsive-BKDMGTHs.mjs +23 -39
  327. package/.output/server/chunks/build/useResponsive-BKDMGTHs.mjs.map +1 -1
  328. package/.output/server/chunks/build/useTeamActions-C08sAVqY.mjs +71 -0
  329. package/.output/server/chunks/build/useTeamActions-C08sAVqY.mjs.map +1 -0
  330. package/.output/server/chunks/build/useTeamAddMemberDialog-fzTmflr8.mjs +78 -0
  331. package/.output/server/chunks/build/useTeamAddMemberDialog-fzTmflr8.mjs.map +1 -0
  332. package/.output/server/chunks/build/useTeamCreateDialog-De63ep-X.mjs +91 -0
  333. package/.output/server/chunks/build/useTeamCreateDialog-De63ep-X.mjs.map +1 -0
  334. package/.output/server/chunks/build/useTeamDeployDialog-CpAtG5Jy.mjs +76 -0
  335. package/.output/server/chunks/build/useTeamDeployDialog-CpAtG5Jy.mjs.map +1 -0
  336. package/.output/server/chunks/build/useTeamDialogState-CFRUQxAf.mjs +31 -38
  337. package/.output/server/chunks/build/useTeamDialogState-CFRUQxAf.mjs.map +1 -1
  338. package/.output/server/chunks/build/useTeamPluginDialog-C1OOe1sL.mjs +99 -0
  339. package/.output/server/chunks/build/useTeamPluginDialog-C1OOe1sL.mjs.map +1 -0
  340. package/.output/server/chunks/build/useTeamsCatalog-DA41SMDu.mjs +124 -0
  341. package/.output/server/chunks/build/useTeamsCatalog-DA41SMDu.mjs.map +1 -0
  342. package/.output/server/chunks/build/useTokenClipboard-CwQpoFeP.mjs +21 -28
  343. package/.output/server/chunks/build/useTokenClipboard-CwQpoFeP.mjs.map +1 -1
  344. package/.output/server/chunks/build/useTokenCreate-XHTQExra.mjs +106 -0
  345. package/.output/server/chunks/build/useTokenCreate-XHTQExra.mjs.map +1 -0
  346. package/.output/server/chunks/build/useTokenRename-Cf1B0cRy.mjs +81 -0
  347. package/.output/server/chunks/build/useTokenRename-Cf1B0cRy.mjs.map +1 -0
  348. package/.output/server/chunks/build/useTokenReveal-C8n1Vt9t.mjs +108 -0
  349. package/.output/server/chunks/build/useTokenReveal-C8n1Vt9t.mjs.map +1 -0
  350. package/.output/server/chunks/build/useTokensList-MMIq24E-.mjs +86 -0
  351. package/.output/server/chunks/build/useTokensList-MMIq24E-.mjs.map +1 -0
  352. package/.output/server/chunks/build/useTownBus-D9SoIsAN.mjs +16 -17
  353. package/.output/server/chunks/build/useTownBus-D9SoIsAN.mjs.map +1 -1
  354. package/.output/server/chunks/build/useWorkbenchAuth-Dyc_czui.mjs +131 -0
  355. package/.output/server/chunks/build/useWorkbenchAuth-Dyc_czui.mjs.map +1 -0
  356. package/.output/server/chunks/build/useWorkbenchWorkspaces-DT33HbBD.mjs +128 -0
  357. package/.output/server/chunks/build/useWorkbenchWorkspaces-DT33HbBD.mjs.map +1 -0
  358. package/.output/server/chunks/build/useWorkshopApi-BkEgGBIM.mjs +118 -0
  359. package/.output/server/chunks/build/useWorkshopApi-BkEgGBIM.mjs.map +1 -0
  360. package/.output/server/chunks/build/useWorkshopWs-BWrVj4jL.mjs +1577 -0
  361. package/.output/server/chunks/build/useWorkshopWs-BWrVj4jL.mjs.map +1 -0
  362. package/.output/server/chunks/build/{useWorkspaceAuth-Dlvj9csD.mjs → useWorkspaceAuth-TahC9EC7.mjs} +4 -16
  363. package/.output/server/chunks/build/useWorkspaceAuth-TahC9EC7.mjs.map +1 -0
  364. package/.output/server/chunks/build/useWorkspaceChannels-BVAHmhN3.mjs +94 -0
  365. package/.output/server/chunks/build/useWorkspaceChannels-BVAHmhN3.mjs.map +1 -0
  366. package/.output/server/chunks/build/useWorkspacePanels-CTwREmq0.mjs +30 -33
  367. package/.output/server/chunks/build/useWorkspacePanels-CTwREmq0.mjs.map +1 -1
  368. package/.output/server/chunks/build/useWorkspaceShell-rQHWNNWJ.mjs +150 -0
  369. package/.output/server/chunks/build/useWorkspaceShell-rQHWNNWJ.mjs.map +1 -0
  370. package/.output/server/chunks/build/users-pVCK50z-.mjs +566 -0
  371. package/.output/server/chunks/build/users-pVCK50z-.mjs.map +1 -0
  372. package/.output/server/chunks/build/workshop-DAgsBgG4.mjs +499 -0
  373. package/.output/server/chunks/build/workshop-DAgsBgG4.mjs.map +1 -0
  374. package/.output/server/chunks/build/workspaces-CmW0cpOt.mjs +111 -121
  375. package/.output/server/chunks/build/workspaces-CmW0cpOt.mjs.map +1 -1
  376. package/.output/server/chunks/routes/api/plugins/_name/_...path_.mjs +4 -1
  377. package/.output/server/chunks/routes/api/plugins/_name/_...path_.mjs.map +1 -1
  378. package/.output/server/chunks/routes/renderer.mjs +1 -1
  379. package/.output/server/chunks/routes/renderer.mjs.map +1 -1
  380. package/.output/server/chunks/virtual/entry.mjs +9357 -10721
  381. package/.output/server/chunks/virtual/entry.mjs.map +1 -1
  382. package/.output/server/chunks/virtual/precomputed.mjs +1 -1
  383. package/.output/server/chunks/virtual/precomputed.mjs.map +1 -1
  384. package/.output/server/package.json +1 -1
  385. package/README-zh.md +2 -2
  386. package/README.md +3 -3
  387. package/app/components/AwLogo.vue +75 -75
  388. package/app/components/aml/AmlDatasetFormModal.vue +279 -279
  389. package/app/components/aml/AmlDatasetTable.vue +319 -319
  390. package/app/components/aml/AmlExperimentsTable.vue +142 -142
  391. package/app/components/aml/AmlInfraBanner.vue +23 -23
  392. package/app/components/aml/AmlJobsTable.vue +248 -248
  393. package/app/components/aml/AmlOverviewBar.vue +62 -62
  394. package/app/components/aml/AmlPageHeader.vue +47 -47
  395. package/app/components/aml/AmlPredictConsole.vue +201 -201
  396. package/app/components/app-header/HitlBell.vue +423 -423
  397. package/app/components/daq/DaqAddNodeModal.vue +209 -209
  398. package/app/components/daq/DaqAlarmBar.vue +46 -46
  399. package/app/components/daq/DaqControlCard.vue +159 -159
  400. package/app/components/daq/DaqInfraBanner.vue +31 -31
  401. package/app/components/daq/DaqLineBanner.vue +47 -47
  402. package/app/components/daq/DaqNodePanel.vue +396 -396
  403. package/app/components/daq/DaqOptPanel.vue +197 -197
  404. package/app/components/daq/DaqTemplateModal.vue +246 -246
  405. package/app/components/dashboard/DashboardGaugeBand.vue +78 -78
  406. package/app/components/dashboard/DashboardHero.vue +209 -209
  407. package/app/components/dashboard/DashboardLineStatePanel.vue +78 -78
  408. package/app/components/dashboard/DashboardNodeStatePanel.vue +46 -46
  409. package/app/components/dashboard/DashboardPipelinePanel.vue +46 -46
  410. package/app/components/dashboard/DashboardTrendPanel.vue +83 -83
  411. package/app/components/dashboard/DashboardWritePanel.vue +52 -52
  412. package/app/components/dcw/DcwCreateLineModal.vue +105 -105
  413. package/app/components/dcw/DcwDeleteLineModal.vue +73 -73
  414. package/app/components/dcw/DcwDetailTemplateModal.vue +238 -238
  415. package/app/components/dcw/DcwLedgerCard.vue +160 -160
  416. package/app/components/dcw/DcwMesArtifacts.vue +140 -140
  417. package/app/components/dcw/DcwProductCreateModal.vue +113 -113
  418. package/app/components/dcw/DcwRecipeDispatchHistoryModal.vue +244 -244
  419. package/app/components/dcw/DcwRecipeEditModal.vue +399 -399
  420. package/app/components/dcw/DcwRecipeHistoryModal.vue +165 -165
  421. package/app/components/dcw/DcwRunDataModal.vue +191 -191
  422. package/app/components/dcw/DcwTemplateModal.vue +227 -227
  423. package/app/components/dcw/DcwWriteHistoryCard.vue +96 -96
  424. package/app/components/dcw/ExpConfirmCard.vue +103 -103
  425. package/app/components/dcw/RecipeDispatchApprovalCard.vue +330 -330
  426. package/app/components/logs/LogsPageHead.vue +71 -71
  427. package/app/components/monitor/MonitorAgentTable.vue +143 -143
  428. package/app/components/monitor/MonitorChannelTable.vue +80 -80
  429. package/app/components/monitor/MonitorLoginGate.vue +24 -24
  430. package/app/components/monitor/MonitorPageHead.vue +92 -92
  431. package/app/components/monitor/MonitorProcessTable.vue +159 -159
  432. package/app/components/ontology/OntologyGraph.vue +356 -356
  433. package/app/components/operations/OperationsFilterCard.vue +164 -164
  434. package/app/components/operations/OperationsPageHead.vue +47 -47
  435. package/app/components/tokens/TokenCreateModal.vue +42 -42
  436. package/app/components/tokens/TokenOnceModal.vue +164 -164
  437. package/app/components/tokens/TokenRenameModal.vue +40 -40
  438. package/app/components/tokens/TokensPageHead.vue +76 -76
  439. package/app/components/workshop/A2aRpcDebugger.vue +237 -237
  440. package/app/components/workshop/AgentInspectorDrawer.vue +424 -424
  441. package/app/components/workshop/AgentLanesView.vue +278 -278
  442. package/app/components/workshop/ArtifactCard.vue +120 -120
  443. package/app/components/workshop/AssetLibrary.vue +452 -452
  444. package/app/components/workshop/ChatMemberPanel.vue +556 -556
  445. package/app/components/workshop/CommandPalette.vue +270 -270
  446. package/app/components/workshop/Composer.vue +540 -540
  447. package/app/components/workshop/DaqTemplateIcon.vue +33 -33
  448. package/app/components/workshop/DeviceTwinPanel.vue +167 -167
  449. package/app/components/workshop/FileSelectorModal.vue +188 -188
  450. package/app/components/workshop/InspectorPanel.vue +301 -301
  451. package/app/components/workshop/PluginSlot.vue +120 -120
  452. package/app/components/workshop/TranscriptTimeline.vue +223 -223
  453. package/app/components/workshop/agents/AgentTemplateEditModal.vue +139 -139
  454. package/app/components/workshop/blocks/ClusterArtifact.vue +61 -61
  455. package/app/components/workshop/blocks/ClusterError.vue +85 -85
  456. package/app/components/workshop/blocks/ClusterLife.vue +87 -87
  457. package/app/components/workshop/blocks/ClusterMember.vue +95 -95
  458. package/app/components/workshop/blocks/ClusterMemory.vue +84 -84
  459. package/app/components/workshop/blocks/ClusterOther.vue +67 -67
  460. package/app/components/workshop/blocks/ClusterStatus.vue +149 -149
  461. package/app/components/workshop/blocks/ClusterTool.vue +176 -176
  462. package/app/components/workshop/blocks/EventBlockAvatar.vue +114 -114
  463. package/app/components/workshop/blocks/EventBlockHead.vue +232 -232
  464. package/app/components/workshop/composer/ComposerToolbar.vue +278 -278
  465. package/app/components/workshop/composer/MentionMenu.vue +135 -135
  466. package/app/components/workshop/composer/ReplyChip.vue +65 -65
  467. package/app/components/workshop/composer/StatusChip.vue +171 -171
  468. package/app/components/workshop/console/Dock.vue +71 -71
  469. package/app/components/workshop/console/LeftPane.vue +84 -84
  470. package/app/components/workshop/device-twin/DeviceTwinCard.vue +265 -265
  471. package/app/components/workshop/device-twin/DeviceTwinDcwSection.vue +203 -203
  472. package/app/components/workshop/lanes/AddMemberModal.vue +270 -270
  473. package/app/components/workshop/lanes/EditMemberModal.vue +106 -106
  474. package/app/components/workshop/lanes/LanesToolbar.vue +97 -97
  475. package/app/components/workshop/session-list/ChannelSettingsModal.vue +3 -3
  476. package/app/components/workshop/session-list/MountChannelModal.vue +124 -124
  477. package/app/components/workshop/session-list/SaveTemplateModal.vue +93 -93
  478. package/app/components/workshop/task-board/Card.vue +172 -172
  479. package/app/components/workshop/task-board/Column.vue +151 -151
  480. package/app/components/workshop/task-board/List.vue +157 -157
  481. package/app/components/workshop/task-board/StatusMenu.vue +88 -88
  482. package/app/components/workshop/teams/TeamAddMemberModal.vue +53 -53
  483. package/app/components/workshop/teams/TeamCreateModal.vue +94 -94
  484. package/app/components/workshop/teams/TeamDeployModal.vue +40 -40
  485. package/app/components/workshop/teams/TeamPluginModal.vue +119 -119
  486. package/app/components/workshop/terminal/OmpTerminalPanel.vue +270 -270
  487. package/app/components/workshop/terminal/TerminalHitlCard.vue +170 -170
  488. package/app/components/workshop/town/TownScene.ts +466 -466
  489. package/app/components/workshop/town/TownView.vue +561 -561
  490. package/app/components/workshop/town/components/AutoModeConfirmModal.vue +94 -94
  491. package/app/components/workshop/town/components/TownAgentBindings.vue +405 -405
  492. package/app/components/workshop/town/components/TownAgentInspector.vue +554 -554
  493. package/app/components/workshop/town/components/TownAlarmList.vue +147 -147
  494. package/app/components/workshop/town/components/TownBoundaryPanel.vue +350 -350
  495. package/app/components/workshop/town/components/TownCalloutLayer.vue +147 -147
  496. package/app/components/workshop/town/components/TownChannelDock.vue +116 -116
  497. package/app/components/workshop/town/components/TownControlDock.vue +405 -405
  498. package/app/components/workshop/town/components/TownDaqNodeInspector.vue +345 -345
  499. package/app/components/workshop/town/components/TownDaqTree.vue +366 -366
  500. package/app/components/workshop/town/components/TownDcwBindSection.vue +473 -473
  501. package/app/components/workshop/town/components/TownDcwNodeInspector.vue +185 -185
  502. package/app/components/workshop/town/components/TownDcwTree.vue +280 -280
  503. package/app/components/workshop/town/components/TownDeviceBindings.vue +394 -394
  504. package/app/components/workshop/town/components/TownDeviceTransform.vue +248 -248
  505. package/app/components/workshop/town/components/TownEventList.vue +120 -120
  506. package/app/components/workshop/town/components/TownHealthBody.vue +100 -100
  507. package/app/components/workshop/town/components/TownKpiStrip.vue +207 -207
  508. package/app/components/workshop/town/components/TownLeftRail.vue +308 -308
  509. package/app/components/workshop/town/components/TownLoadingMask.vue +61 -61
  510. package/app/components/workshop/town/components/TownNavMap.vue +154 -154
  511. package/app/components/workshop/town/components/TownRightRail.vue +543 -543
  512. package/app/components/workshop/town/components/TownStage.vue +281 -281
  513. package/app/components/workshop/town/components/TownStageTop.vue +238 -238
  514. package/app/components/workshop/town/components/TownStatusBar.vue +108 -108
  515. package/app/components/workshop/town/components/TownTopNav.vue +367 -367
  516. package/app/components/workshop/town/components/TownTrendDock.vue +178 -178
  517. package/app/components/workshop/town/scene/town-scene-agents.ts +254 -254
  518. package/app/components/workshop/town/scene/town-scene-behavior.ts +194 -194
  519. package/app/components/workshop/town/scene/town-scene-bubbles.ts +96 -96
  520. package/app/components/workshop/town/scene/town-scene-core.ts +158 -158
  521. package/app/components/workshop/town/scene/town-scene-models.ts +109 -109
  522. package/app/components/workshop/town/scene/town-scene-visuals.ts +279 -279
  523. package/app/components/workshop/town/scene/town-scene3d-agents.ts +308 -308
  524. package/app/components/workshop/town/scene/town-scene3d-blocks.ts +297 -297
  525. package/app/components/workshop/town/scene/town-scene3d-bubbles.ts +281 -281
  526. package/app/components/workshop/town/scene/town-scene3d-camera.ts +282 -282
  527. package/app/components/workshop/town/scene/town-scene3d-devices.ts +433 -433
  528. package/app/components/workshop/town/scene/town-scene3d-editing.ts +490 -490
  529. package/app/components/workshop/town/scene/town-scene3d-events.ts +173 -173
  530. package/app/components/workshop/town/scene/town-scene3d-factory.ts +412 -412
  531. package/app/components/workshop/town/scene/town-scene3d-hud.ts +110 -110
  532. package/app/components/workshop/town/scene/town-scene3d-lifecycle.ts +144 -144
  533. package/app/components/workshop/town/scene/town-scene3d-links.ts +141 -141
  534. package/app/components/workshop/town/scene/town-scene3d-loop.ts +286 -286
  535. package/app/components/workshop/town/scene/town-scene3d-models.ts +154 -154
  536. package/app/components/workshop/town/scene/town-scene3d-nodes.ts +562 -562
  537. package/app/components/workshop/town/scene/town-scene3d-ranges.ts +273 -273
  538. package/app/components/workshop/town/scene/town-scene3d-renderer.ts +320 -320
  539. package/app/components/workshop/town/scene/town-scene3d-selection.ts +257 -257
  540. package/app/components/workshop/town/scene/town-scene3d-types.ts +264 -264
  541. package/app/components/workshop/transcript/TranscriptBlockList.vue +68 -68
  542. package/app/components/workshop/transcript/TranscriptEarlierPager.vue +81 -81
  543. package/app/components/workshop/transcript/TranscriptFilterBar.vue +126 -126
  544. package/app/components/workshop/workbench/CreateWorkspaceModal.vue +36 -36
  545. package/app/components/workshop/workbench/WorkspaceEmpty.vue +56 -56
  546. package/app/composables/useResponsive.ts +88 -88
  547. package/app/composables/workshop/device-twin-types.ts +29 -29
  548. package/app/composables/workshop/event-blocks/attention.ts +58 -58
  549. package/app/composables/workshop/event-blocks/classify.ts +44 -44
  550. package/app/composables/workshop/event-blocks/clusterer.ts +231 -231
  551. package/app/composables/workshop/event-blocks/fold-stream.ts +45 -45
  552. package/app/composables/workshop/event-blocks/markdown.ts +81 -81
  553. package/app/composables/workshop/event-blocks/mentions.ts +49 -49
  554. package/app/composables/workshop/event-blocks/text-utils.ts +100 -100
  555. package/app/composables/workshop/event-blocks/types.ts +40 -40
  556. package/app/composables/workshop/town/town-relay-props.ts +231 -231
  557. package/app/composables/workshop/town/town-view-types.ts +145 -145
  558. package/app/composables/workshop/town/useTownAgentBindings.ts +182 -182
  559. package/app/composables/workshop/town/useTownAgentChat.ts +203 -203
  560. package/app/composables/workshop/town/useTownAlarms.ts +36 -36
  561. package/app/composables/workshop/town/useTownCallouts.ts +174 -174
  562. package/app/composables/workshop/town/useTownChannels.ts +220 -220
  563. package/app/composables/workshop/town/useTownHealth.ts +66 -66
  564. package/app/composables/workshop/town/useTownHudTickers.ts +77 -77
  565. package/app/composables/workshop/town/useTownLayout.ts +277 -277
  566. package/app/composables/workshop/town/useTownNavMap.ts +301 -301
  567. package/app/composables/workshop/town/useTownNodeBindings.ts +345 -345
  568. package/app/composables/workshop/town/useTownPanelDrag.ts +91 -91
  569. package/app/composables/workshop/town/useTownRailData.ts +421 -421
  570. package/app/composables/workshop/town/useTownSceneControl.ts +92 -92
  571. package/app/composables/workshop/town/useTownSceneInput.ts +275 -275
  572. package/app/composables/workshop/town/useTownSceneRuntime.ts +390 -390
  573. package/app/composables/workshop/town/useTownSheets.ts +41 -41
  574. package/app/composables/workshop/town/useTownTrends.ts +93 -93
  575. package/app/composables/workshop/useChannelList.ts +88 -88
  576. package/app/composables/workshop/useChannelTerminals.ts +65 -65
  577. package/app/composables/workshop/useComposerMentions.ts +130 -130
  578. package/app/composables/workshop/useDcwStream.ts +374 -374
  579. package/app/composables/workshop/useDeviceTwinDcwWrite.ts +77 -77
  580. package/app/composables/workshop/useDeviceTwinPanel.ts +56 -56
  581. package/app/composables/workshop/useEscClose.ts +44 -44
  582. package/app/composables/workshop/useEventBlockView.ts +159 -159
  583. package/app/composables/workshop/useEventBlocks.ts +33 -33
  584. package/app/composables/workshop/useHitlAnswer.ts +184 -184
  585. package/app/composables/workshop/useLaneWidths.ts +27 -27
  586. package/app/composables/workshop/useOmpTerminalSession.ts +424 -424
  587. package/app/composables/workshop/usePluginAdmin.ts +152 -152
  588. package/app/composables/workshop/usePluginPanels.ts +72 -72
  589. package/app/composables/workshop/useRuntimeConfigDraft.ts +118 -118
  590. package/app/composables/workshop/useSettingsGroups.ts +243 -243
  591. package/app/composables/workshop/useTaskBoardColumns.ts +47 -47
  592. package/app/composables/workshop/useTerminalRenderer.ts +308 -308
  593. package/app/composables/workshop/useTranscriptEnterStage.ts +48 -48
  594. package/app/composables/workshop/useTranscriptHistory.ts +52 -52
  595. package/app/composables/workshop/useTranscriptScroll.ts +113 -113
  596. package/app/composables/workshop/useVisibleInterval.ts +42 -42
  597. package/app/composables/workshop/useWorkshopWs.ts +265 -265
  598. package/app/config/index.ts +1 -1
  599. package/app/middleware/locale-cookie.global.ts +22 -22
  600. package/app/pages/aml/api.ts +6 -6
  601. package/app/pages/aml/composables/useAmlDatasets.ts +38 -38
  602. package/app/pages/aml/composables/useAmlEntities.ts +57 -57
  603. package/app/pages/aml/composables/useAmlEnv.ts +191 -191
  604. package/app/pages/aml/composables/useAmlExperiments.ts +45 -45
  605. package/app/pages/aml/composables/useAmlFormat.ts +44 -44
  606. package/app/pages/aml/composables/useAmlJobs.ts +131 -131
  607. package/app/pages/aml/composables/useAmlModels.ts +56 -56
  608. package/app/pages/aml/composables/useAmlNotes.ts +47 -47
  609. package/app/pages/aml/composables/useAmlPredict.ts +93 -93
  610. package/app/pages/aml/constants.ts +63 -63
  611. package/app/pages/aml/index.vue +236 -236
  612. package/app/pages/composables/useDashboardCharts.ts +192 -192
  613. package/app/pages/composables/useDashboardData.ts +144 -144
  614. package/app/pages/daq/composables/useDaqAddNode.ts +126 -126
  615. package/app/pages/daq/composables/useDaqDetailBinding.ts +29 -29
  616. package/app/pages/daq/composables/useDaqDetailFrames.ts +42 -42
  617. package/app/pages/daq/composables/useDaqDetailNode.ts +53 -53
  618. package/app/pages/daq/composables/useDaqDetailParams.ts +138 -138
  619. package/app/pages/daq/composables/useDaqFilters.ts +187 -187
  620. package/app/pages/daq/composables/useDaqNodeWindow.ts +86 -86
  621. package/app/pages/daq/composables/useDaqOptimizations.ts +99 -99
  622. package/app/pages/daq/composables/useDaqTemplates.ts +152 -152
  623. package/app/pages/daq/index.vue +260 -260
  624. package/app/pages/dcw/composables/useDcwCards.ts +27 -27
  625. package/app/pages/dcw/composables/useDcwDetailScope.ts +145 -145
  626. package/app/pages/dcw/composables/useDcwDetailTemplates.ts +94 -94
  627. package/app/pages/dcw/composables/useDcwFilter.ts +29 -29
  628. package/app/pages/dcw/composables/useDcwLedger.ts +34 -34
  629. package/app/pages/dcw/composables/useDcwLineMutations.ts +115 -115
  630. package/app/pages/dcw/composables/useDcwLineRun.ts +60 -60
  631. package/app/pages/dcw/composables/useDcwProducts.ts +54 -54
  632. package/app/pages/dcw/composables/useDcwQuery.ts +68 -68
  633. package/app/pages/dcw/composables/useDcwQuickActions.ts +47 -47
  634. package/app/pages/dcw/composables/useDcwRecipes.ts +256 -256
  635. package/app/pages/dcw/composables/useDcwTemplates.ts +50 -50
  636. package/app/pages/dcw/index.vue +195 -195
  637. package/app/pages/dcw/types.ts +9 -9
  638. package/app/pages/index.vue +126 -126
  639. package/app/pages/logs/composables/useLogsFormat.ts +43 -43
  640. package/app/pages/logs/composables/useLogsScope.ts +39 -39
  641. package/app/pages/monitor/types.ts +61 -61
  642. package/app/pages/operations.vue +61 -61
  643. package/app/pages/permissions/index.vue +369 -369
  644. package/app/pages/tokens/composables/useTokenClipboard.ts +33 -33
  645. package/app/pages/tokens/composables/useTokenCreate.ts +93 -93
  646. package/app/pages/tokens/composables/useTokenRename.ts +54 -54
  647. package/app/pages/tokens/composables/useTokenReveal.ts +84 -84
  648. package/app/pages/tokens/composables/useTokensList.ts +60 -60
  649. package/app/pages/tokens.vue +111 -111
  650. package/app/pages/tools/index.vue +98 -98
  651. package/app/pages/workshop/agents.vue +130 -130
  652. package/app/pages/workshop/composables/useAgentHarnessOptions.ts +59 -59
  653. package/app/pages/workshop/composables/useAgentTemplateActions.ts +42 -42
  654. package/app/pages/workshop/composables/useAgentTemplateDialogState.ts +24 -24
  655. package/app/pages/workshop/composables/useAgentTemplateForm.ts +88 -88
  656. package/app/pages/workshop/composables/useAgentTemplatesCatalog.ts +92 -92
  657. package/app/pages/workshop/composables/useTeamActions.ts +44 -44
  658. package/app/pages/workshop/composables/useTeamAddMemberDialog.ts +49 -49
  659. package/app/pages/workshop/composables/useTeamCreateDialog.ts +67 -67
  660. package/app/pages/workshop/composables/useTeamDeployDialog.ts +49 -49
  661. package/app/pages/workshop/composables/useTeamDialogState.ts +46 -46
  662. package/app/pages/workshop/composables/useTeamPluginDialog.ts +72 -72
  663. package/app/pages/workshop/composables/useTeamsCatalog.ts +100 -100
  664. package/app/pages/workshop/composables/useWorkbenchWorkspaces.ts +123 -123
  665. package/app/pages/workshop/composables/useWorkspaceAuth.ts +31 -31
  666. package/app/pages/workshop/composables/useWorkspaceChannels.ts +62 -62
  667. package/app/pages/workshop/composables/useWorkspaceShell.ts +136 -136
  668. package/app/pages/workshop/schedules.vue +553 -553
  669. package/app/pages/workshop/w/[wsId].vue +221 -221
  670. package/app/plugins/aw-plugins.client.ts +213 -213
  671. package/app/plugins/esc-close.client.ts +31 -31
  672. package/app/stores/workshop/hitl.ts +183 -183
  673. package/app/stores/workshop/narrow-fetch.ts +23 -23
  674. package/app/utils/api-error.ts +75 -75
  675. package/app/utils/builtin-catalog.ts +104 -104
  676. package/app/utils/chart-trend.ts +97 -97
  677. package/app/utils/dcw-driver-badge.ts +16 -16
  678. package/app/utils/dcw-recipe-form.ts +26 -26
  679. package/cli/commands/tui.mjs +28 -28
  680. package/cli/commands/update.mjs +124 -124
  681. package/cli/core/child-lifecycle.mjs +136 -136
  682. package/cli/core/meta.mjs +38 -38
  683. package/cli/core/post-build.mjs +96 -96
  684. package/config.yml +1 -1
  685. package/docs/cli.en.md +2 -2
  686. package/docs/cli.md +2 -2
  687. package/docs/mcp.en.md +27 -27
  688. package/docs/multi-harness-architecture.md +248 -248
  689. package/docs/plugins.en.md +1 -1
  690. package/docs/plugins.md +1 -1
  691. package/docs/sdk.en.md +1 -1
  692. package/docs/sdk.md +1 -1
  693. package/docs/tui.md +43 -43
  694. package/i18n/dicts/_en.json +1551 -1551
  695. package/i18n/dicts/_en2.json +300 -300
  696. package/i18n/dicts/_en4.json +114 -114
  697. package/i18n/dicts/agentLanesView.json +61 -61
  698. package/i18n/dicts/appHeader.json +17 -17
  699. package/i18n/dicts/channelSessionList.json +51 -51
  700. package/i18n/dicts/chat.json +79 -79
  701. package/i18n/dicts/clusterTool.json +4 -4
  702. package/i18n/dicts/composer.json +38 -38
  703. package/i18n/dicts/ctpl.json +37 -37
  704. package/i18n/dicts/dcwDetail.json +219 -219
  705. package/i18n/dicts/lineOps.json +14 -14
  706. package/i18n/dicts/multiChannelView.json +13 -13
  707. package/i18n/dicts/notifications.json +13 -13
  708. package/i18n/dicts/taskInspectorDrawer.json +25 -25
  709. package/i18n/dicts/teamPlugins.json +10 -10
  710. package/i18n/dicts/townView.json +209 -209
  711. package/mcp/discovery.mjs +227 -227
  712. package/package.json +1 -1
  713. package/public/favicon.svg +14 -14
  714. package/public/robots.txt +3 -3
  715. package/scripts/_audit/audit-harness-adapters.md +664 -664
  716. package/scripts/_audit/aw-mcp-live-e2e.mjs +293 -293
  717. package/scripts/_audit/bump-version.mjs +51 -51
  718. package/scripts/_audit/detached-instance.mjs +112 -112
  719. package/scripts/_audit/detached-start.mjs +103 -103
  720. package/scripts/_audit/eda-ui-fix-acceptance.mjs +212 -212
  721. package/scripts/_audit/guard-upstream-liveness.mjs +104 -104
  722. package/scripts/_audit/http-api-authz-audit.md +657 -657
  723. package/scripts/_audit/kb-team-mock-e2e.mjs +146 -146
  724. package/scripts/_audit/kb-team-omp-e2e.mjs +229 -229
  725. package/scripts/_audit/run.mjs +21 -21
  726. package/scripts/_audit/runtime-audit.md +716 -716
  727. package/scripts/_audit/skills-guided-e2e.mjs +316 -316
  728. package/scripts/_audit/stability-soak.mjs +252 -252
  729. package/scripts/_audit/stubs/nuxt-imports.mjs +67 -67
  730. package/scripts/_audit/ts-register-hook.mjs +12 -12
  731. package/scripts/_audit/ts-resolve-hook.mjs +96 -96
  732. package/scripts/_aw-packaged-start.cjs +22 -22
  733. package/scripts/_aw0746-stage12.mjs +94 -94
  734. package/scripts/_aw0746-stage34.mjs +136 -136
  735. package/scripts/_aw0746-stage6b-train-sweep.mjs +145 -145
  736. package/scripts/_aw0746-stage6c-jobsmoke.mjs +69 -69
  737. package/scripts/_dbg-configroot-audit.mjs +86 -86
  738. package/scripts/_dbg-daq-intervals-func.mjs +115 -115
  739. package/scripts/_dbg-perms-e2e.mjs +142 -142
  740. package/scripts/_dbg-protocol-matrix.mjs +462 -462
  741. package/scripts/_dbg-render-regression.mjs +193 -193
  742. package/scripts/_dbg-schedule-e2e.mjs +262 -262
  743. package/scripts/_e2e-ui-functional.mjs +371 -371
  744. package/scripts/_i18n-en-cjk-scan.mjs +28 -28
  745. package/scripts/_i18n-en-verify.mjs +107 -107
  746. package/scripts/_i18n-extra-checks.mjs +53 -53
  747. package/scripts/_i18n-scan-hardcoded.mjs +180 -180
  748. package/scripts/_lib-aml-python-run.mjs +17 -17
  749. package/scripts/_lint-reflow.mjs +105 -105
  750. package/scripts/_loop-biax-campaign.mjs +130 -130
  751. package/scripts/_plc-sim-detached.cjs +22 -22
  752. package/scripts/_probe-daq-omp-task.mjs +100 -100
  753. package/scripts/_probe-daq-scope-default.mjs +123 -123
  754. package/scripts/_probe-model-channel-link.cjs +25 -25
  755. package/scripts/_probe-recipe-switch.mjs +92 -92
  756. package/scripts/_provision-injection-line.mjs +39 -39
  757. package/scripts/_run-matrix.ps1 +53 -53
  758. package/scripts/_sweep-button-contrast.mjs +87 -87
  759. package/scripts/acceptance-aml-hybrid-e2e.ts +396 -396
  760. package/scripts/acceptance-aml-hybrid-live.mjs +93 -93
  761. package/scripts/acceptance-aml-model-identity.ts +137 -137
  762. package/scripts/agent-daq-isolation-e2e.mjs +91 -91
  763. package/scripts/api-contract-smoke.mjs +126 -126
  764. package/scripts/ask-hitl-e2e.mjs +96 -96
  765. package/scripts/aw-expose.mjs +159 -159
  766. package/scripts/channel-interaction-smoke.mjs +80 -80
  767. package/scripts/data-studio-ui-e2e.mjs +163 -163
  768. package/scripts/demo-group-chat-all-real.ts +279 -279
  769. package/scripts/demo-group-chat-omp-cases.ts +210 -210
  770. package/scripts/demo-group-chat-omp.ts +184 -184
  771. package/scripts/demo-group-chat-order.ts +197 -197
  772. package/scripts/dev-modbus-simulator.mjs +55 -55
  773. package/scripts/docs-shots.mjs +36 -36
  774. package/scripts/e2e-agentteam-chat.mjs +473 -473
  775. package/scripts/e2e-agentteam-real-triage.mjs +421 -421
  776. package/scripts/e2e-aml-decoupled.mjs +162 -162
  777. package/scripts/e2e-aw-tui-global.mjs +277 -277
  778. package/scripts/e2e-closedloop/cleanup.mjs +27 -27
  779. package/scripts/e2e-closedloop/lib.mjs +109 -109
  780. package/scripts/e2e-closedloop/main.mjs +59 -59
  781. package/scripts/e2e-closedloop/scenarios-accounts.mjs +210 -210
  782. package/scripts/e2e-closedloop/scenarios-authz.mjs +196 -196
  783. package/scripts/e2e-closedloop/scenarios-daq-dcw.mjs +222 -222
  784. package/scripts/e2e-closedloop/scenarios-plugins.mjs +169 -169
  785. package/scripts/e2e-closedloop/state.mjs +10 -10
  786. package/scripts/e2e-config-groups.mjs +238 -238
  787. package/scripts/e2e-crash-cycle.mjs +108 -108
  788. package/scripts/e2e-full-closedloop.mjs +16 -16
  789. package/scripts/e2e-hil-multi-user.mjs +307 -307
  790. package/scripts/e2e-hil-restart.mjs +339 -339
  791. package/scripts/e2e-idd-results-ui.mjs +175 -0
  792. package/scripts/e2e-idd-results.mjs +48 -16
  793. package/scripts/e2e-injection-recipe-closedloop.mjs +203 -203
  794. package/scripts/e2e-line-governance.mjs +352 -352
  795. package/scripts/e2e-ontology.mjs +393 -393
  796. package/scripts/e2e-plc-plugin-closedloop.mjs +549 -549
  797. package/scripts/e2e-timezone-settings.mjs +57 -57
  798. package/scripts/full-stack-shots.mjs +145 -145
  799. package/scripts/full-tool-injection-harness-e2e.mjs +214 -214
  800. package/scripts/hitl-reject-e2e.mjs +131 -131
  801. package/scripts/line-log-smoke.mjs +260 -260
  802. package/scripts/live-aml-mockomp.mjs +304 -304
  803. package/scripts/live-aml-optloop-resume.mjs +322 -322
  804. package/scripts/live-aml-optloop.mjs +588 -588
  805. package/scripts/live-aml-stage9.mjs +169 -169
  806. package/scripts/live-aml-two-goals.mjs +315 -315
  807. package/scripts/live-optloop-two-modes.mjs +857 -857
  808. package/scripts/mes-agent-integration-e2e.mjs +361 -361
  809. package/scripts/ops-plugins-e2e.mjs +85 -85
  810. package/scripts/proof-omp-real.ts +189 -189
  811. package/scripts/scenario-suite-setup.mjs +337 -337
  812. package/scripts/scenario-suite-stability.mjs +144 -144
  813. package/scripts/smoke-optimization-verify.ts +72 -72
  814. package/scripts/team-coordination-e2e.mjs +96 -96
  815. package/scripts/test-agentteam-task-chat-flow.ts +420 -420
  816. package/scripts/test-agentteam-workflow.ts +472 -472
  817. package/scripts/test-aw-skills.mjs +102 -102
  818. package/scripts/test-cli-exit.mjs +343 -343
  819. package/scripts/test-daq-frame-race.mjs +358 -358
  820. package/scripts/test-data-root.mjs +208 -208
  821. package/scripts/test-events-index.mjs +176 -176
  822. package/scripts/test-group-chat-hardening.ts +265 -265
  823. package/scripts/test-group-chat-unit/lib.ts +186 -186
  824. package/scripts/test-group-chat-unit/main.ts +45 -45
  825. package/scripts/test-group-chat-unit/section-a-migration.ts +75 -75
  826. package/scripts/test-group-chat-unit/section-b-permission-matrix.ts +88 -88
  827. package/scripts/test-group-chat-unit/section-c-member-lifecycle.ts +64 -64
  828. package/scripts/test-group-chat-unit/section-d-mention-resolution.ts +36 -36
  829. package/scripts/test-group-chat-unit/section-e-chat-facts.ts +97 -97
  830. package/scripts/test-group-chat-unit/section-f-user-notifications.ts +52 -52
  831. package/scripts/test-group-chat-unit/section-g-member-projection.ts +44 -44
  832. package/scripts/test-group-chat-unit/section-h-outbox-consistency.ts +30 -30
  833. package/scripts/test-group-chat-unit/section-i-read-idempotency.ts +24 -24
  834. package/scripts/test-group-chat-unit/section-j-permission-scope.ts +150 -150
  835. package/scripts/test-group-chat-unit.ts +35 -35
  836. package/scripts/test-hitl-decision.ts +526 -526
  837. package/scripts/test-hitl-legacy-channel-auth.ts +143 -143
  838. package/scripts/test-hitl-registry.ts +112 -112
  839. package/scripts/test-log-flooding.mjs +160 -160
  840. package/scripts/test-lru.mjs +101 -101
  841. package/scripts/test-memory-month-query.mjs +70 -70
  842. package/scripts/test-plugin-hardening.mjs +90 -90
  843. package/scripts/test-plugin-lifecycle.mjs +173 -173
  844. package/scripts/test-rollback-index.mjs +137 -137
  845. package/scripts/test-schedule-runtime.ts +309 -309
  846. package/scripts/test-scheduler-loop/scenarios-supervise.ts +25 -25
  847. package/scripts/test-sdk-surface.mjs +158 -158
  848. package/scripts/test-serial-bridge.mjs +418 -418
  849. package/scripts/test-tui-commands.mjs +148 -148
  850. package/scripts/test-tui-reducers.mjs +72 -72
  851. package/scripts/three-system-e2e/lib.mjs +79 -79
  852. package/scripts/three-system-e2e/main.mjs +40 -40
  853. package/scripts/three-system-e2e/phases/phase-0-user-token.mjs +42 -42
  854. package/scripts/three-system-e2e/phases/phase-0a2-line-autoselect.mjs +35 -35
  855. package/scripts/three-system-e2e/phases/phase-0b-fixture-grants.mjs +39 -39
  856. package/scripts/three-system-e2e/phases/phase-0c-plugin-outbound-auth.mjs +95 -95
  857. package/scripts/three-system-e2e/phases/stage-1-health.mjs +47 -47
  858. package/scripts/three-system-e2e/phases/stage-2-5-team-plugins.mjs +84 -84
  859. package/scripts/three-system-e2e/phases/stage-2-teams-tools-hitl.mjs +184 -184
  860. package/scripts/three-system-e2e/phases/stage-3-diag.mjs +73 -73
  861. package/scripts/three-system-e2e/phases/stage-4-plugin-toggle.mjs +53 -53
  862. package/scripts/three-system-e2e/state.mjs +87 -87
  863. package/scripts/three-system-e2e.mjs +40 -40
  864. package/scripts/tool-face-batch-identity-e2e.mjs +222 -222
  865. package/scripts/tsconfig.json +14 -14
  866. package/scripts/tui-smoke.mjs +100 -100
  867. package/scripts/typecheck.mjs +75 -75
  868. package/scripts/ui/admin-shots.mjs +46 -46
  869. package/scripts/ui/bump-microfont.mjs +39 -39
  870. package/scripts/ui/linkcheck2.mjs +37 -37
  871. package/scripts/ui/live-render-check.mjs +72 -72
  872. package/scripts/ui/md-lint.mjs +80 -80
  873. package/scripts/ui/perf-audit.mjs +132 -132
  874. package/scripts/ui/readme-assets.mjs +30 -30
  875. package/scripts/ui/readme-shots.mjs +42 -42
  876. package/scripts/ui/record-demo.mjs +557 -557
  877. package/scripts/ui/record.mjs +225 -225
  878. package/scripts/ui/seed-admin.mjs +68 -68
  879. package/scripts/ui/seed-demo.mjs +83 -83
  880. package/scripts/ui/seed-industrial-demo.mjs +171 -171
  881. package/scripts/ui/shot-hero.mjs +25 -25
  882. package/scripts/ui/shots.mjs +75 -75
  883. package/scripts/ui/sim-ui-shot.mjs +16 -16
  884. package/scripts/ui/smoke-refactor.mjs +258 -258
  885. package/scripts/ui/verify-nav.mjs +51 -51
  886. package/scripts/ui/verify-responsive.mjs +285 -285
  887. package/sdk/client.d.mts +110 -110
  888. package/sdk/examples/line-sentinel/index.mjs +105 -105
  889. package/sdk/examples/ops-notifier/index.mjs +34 -34
  890. package/sdk/examples/sample-insight/index.mjs +39 -39
  891. package/server/api/plugins/[name]/[...path].ts +5 -1
  892. package/server/api/plugins/client/[name].get.ts +18 -18
  893. package/server/api/plugins/i18n.get.ts +12 -12
  894. package/server/api/plugins/manifest.get.ts +10 -10
  895. package/server/api/system/backup/list.get.ts +32 -32
  896. package/server/api/system/backup/run.post.ts +21 -21
  897. package/server/api/system/config-groups/[id].delete.ts +21 -21
  898. package/server/api/system/config-groups/[id].patch.ts +26 -26
  899. package/server/api/system/config-groups/index.get.ts +21 -21
  900. package/server/api/system/config-groups/index.post.ts +33 -33
  901. package/server/api/system/timezone.get.ts +20 -20
  902. package/server/api/users/tokens/[id]/token.get.ts +11 -11
  903. package/server/api/workshop/[...path].ts +13 -13
  904. package/server/api/workshop/agent-tools/approvals/index.get.ts +43 -43
  905. package/server/api/workshop/agent-tools/bindings/[id].delete.ts +26 -26
  906. package/server/api/workshop/agent-tools/bindings/grant.post.ts +45 -45
  907. package/server/api/workshop/agent-tools/bindings/index.get.ts +41 -41
  908. package/server/api/workshop/agent-tools/bindings/revoke.post.ts +42 -42
  909. package/server/api/workshop/aml/datasets/[id]/preview.get.ts +68 -68
  910. package/server/api/workshop/aml/datasets/[id].delete.ts +39 -39
  911. package/server/api/workshop/aml/datasets/[id].get.ts +53 -53
  912. package/server/api/workshop/aml/datasets/[id].patch.ts +30 -30
  913. package/server/api/workshop/aml/datasets/index.get.ts +20 -20
  914. package/server/api/workshop/aml/datasets/index.post.ts +27 -27
  915. package/server/api/workshop/aml/entities/index.get.ts +13 -13
  916. package/server/api/workshop/aml/entities/prune.post.ts +28 -28
  917. package/server/api/workshop/aml/env/index.get.ts +13 -13
  918. package/server/api/workshop/aml/env/recheck.post.ts +14 -14
  919. package/server/api/workshop/aml/env/uv.post.ts +21 -21
  920. package/server/api/workshop/aml/env/venv.post.ts +24 -24
  921. package/server/api/workshop/aml/experiments/index.get.ts +35 -35
  922. package/server/api/workshop/aml/index.get.ts +37 -37
  923. package/server/api/workshop/aml/jobs/[id]/cancel.post.ts +21 -21
  924. package/server/api/workshop/aml/jobs/[id]/logs.get.ts +23 -23
  925. package/server/api/workshop/aml/jobs/[id]/retry.post.ts +20 -20
  926. package/server/api/workshop/aml/jobs/[id].delete.ts +44 -44
  927. package/server/api/workshop/aml/jobs/[id].get.ts +23 -23
  928. package/server/api/workshop/aml/jobs/index.get.ts +26 -26
  929. package/server/api/workshop/aml/models/[id]/predict.post.ts +24 -24
  930. package/server/api/workshop/aml/models/[id]/promote.post.ts +30 -30
  931. package/server/api/workshop/aml/models/index.get.ts +48 -48
  932. package/server/api/workshop/aml/training-plans/[id]/train.post.ts +18 -18
  933. package/server/api/workshop/aml/training-plans/[id].delete.ts +18 -18
  934. package/server/api/workshop/aml/training-plans/[id].patch.ts +30 -30
  935. package/server/api/workshop/aml/training-plans/index.get.ts +9 -9
  936. package/server/api/workshop/aml/training-plans/index.post.ts +43 -43
  937. package/server/api/workshop/approvals/[id]/decide.post.ts +30 -30
  938. package/server/api/workshop/approvals/index.get.ts +22 -22
  939. package/server/api/workshop/audit.get.ts +43 -43
  940. package/server/api/workshop/channels/[id]/chat/messages/[messageId]/read.post.ts +22 -22
  941. package/server/api/workshop/channels/[id]/chat/messages/index.get.ts +29 -29
  942. package/server/api/workshop/channels/[id]/chat/messages/index.post.ts +51 -51
  943. package/server/api/workshop/channels/[id]/chat/permissions.get.ts +35 -35
  944. package/server/api/workshop/channels/[id]/index.patch.ts +64 -64
  945. package/server/api/workshop/channels/[id]/members/[userId]/approve.post.ts +20 -20
  946. package/server/api/workshop/channels/[id]/members/[userId].delete.ts +21 -21
  947. package/server/api/workshop/channels/[id]/members/index.get.ts +23 -23
  948. package/server/api/workshop/channels/[id]/members/leave.post.ts +20 -20
  949. package/server/api/workshop/channels/[id]/twin-profile.get.ts +45 -45
  950. package/server/api/workshop/channels/[id]/twin-profile.patch.ts +72 -72
  951. package/server/api/workshop/daq/[id]/test.post.ts +1 -1
  952. package/server/api/workshop/daq/alarms.get.ts +16 -16
  953. package/server/api/workshop/dcw/[id]/write.post.ts +4 -4
  954. package/server/api/workshop/dcw/[id].delete.ts +41 -41
  955. package/server/api/workshop/dcw/[id].patch.ts +40 -40
  956. package/server/api/workshop/dcw/mes-test-read.post.ts +24 -24
  957. package/server/api/workshop/dcw/params/[id]/read.post.ts +17 -17
  958. package/server/api/workshop/dcw/params/[id]/write.post.ts +21 -21
  959. package/server/api/workshop/dcw/params/[id].delete.ts +19 -19
  960. package/server/api/workshop/dcw/params/[id].patch.ts +23 -23
  961. package/server/api/workshop/dcw/params/index.get.ts +27 -27
  962. package/server/api/workshop/dcw/params/index.post.ts +25 -25
  963. package/server/api/workshop/dcw/products/[id].delete.ts +16 -16
  964. package/server/api/workshop/dcw/products/[id].patch.ts +17 -17
  965. package/server/api/workshop/dcw/recipes/[id]/index.patch.ts +22 -22
  966. package/server/api/workshop/dcw/recipes/[id]/versions.get.ts +14 -14
  967. package/server/api/workshop/dcw/recipes/[id].delete.ts +25 -25
  968. package/server/api/workshop/dcw/recipes/index.get.ts +12 -12
  969. package/server/api/workshop/dcw/runs/[id]/close.post.ts +15 -15
  970. package/server/api/workshop/dcw/templates/[key].delete.ts +14 -14
  971. package/server/api/workshop/dcw/templates/[key].patch.ts +16 -16
  972. package/server/api/workshop/dcw/templates/index.post.ts +15 -15
  973. package/server/api/workshop/dcw/test-driver.post.ts +16 -16
  974. package/server/api/workshop/device-twins/[id].delete.ts +25 -25
  975. package/server/api/workshop/eda/runs/[id]/labels.patch.ts +25 -25
  976. package/server/api/workshop/exp/confirmations/[id]/decide.post.ts +41 -41
  977. package/server/api/workshop/exp/confirmations/index.get.ts +25 -25
  978. package/server/api/workshop/harnesses/[id]/providers.get.ts +16 -16
  979. package/server/api/workshop/hitl/respond.post.ts +94 -94
  980. package/server/api/workshop/notifications/index.get.ts +60 -60
  981. package/server/api/workshop/notifications/read.post.ts +31 -31
  982. package/server/api/workshop/ontology/drafts/[draftId]/subgraph.ts +24 -24
  983. package/server/api/workshop/plugins/[name]/disable.post.ts +21 -21
  984. package/server/api/workshop/plugins/[name]/enable.post.ts +21 -21
  985. package/server/api/workshop/plugins/[name]/index.get.ts +14 -14
  986. package/server/api/workshop/schedules/[id]/run.post.ts +15 -15
  987. package/server/api/workshop/schedules/[id]/runs.get.ts +15 -15
  988. package/server/api/workshop/schedules/[id].delete.ts +14 -14
  989. package/server/api/workshop/schedules/[id].get.ts +13 -13
  990. package/server/api/workshop/schedules/[id].patch.ts +29 -29
  991. package/server/api/workshop/schedules/index.get.ts +12 -12
  992. package/server/api/workshop/schedules/index.post.ts +32 -32
  993. package/server/api/workshop/tasks/[id]/reassign.post.ts +32 -32
  994. package/server/api/workshop/tasks/[id]/update.post.ts +35 -35
  995. package/server/api/workshop/teams/[id]/plugins/index.get.ts +36 -36
  996. package/server/api/workshop/teams/[id]/plugins/index.put.ts +42 -42
  997. package/server/api/workshop/ws/audience.ts +56 -56
  998. package/server/api/workshop/ws/db-buffer.ts +68 -68
  999. package/server/api/workshop/ws/event-mapping.ts +47 -47
  1000. package/server/api/workshop/ws/handlers.ts +132 -132
  1001. package/server/api/workshop/ws/hub.ts +133 -133
  1002. package/server/api/workshop/ws/index.ts +23 -23
  1003. package/server/api/workshop/ws/notification-uplink.ts +77 -77
  1004. package/server/api/workshop/ws/shared.ts +94 -94
  1005. package/server/api/workshop/ws/streams.ts +146 -146
  1006. package/server/middleware/00-security-headers.ts +38 -38
  1007. package/server/middleware/01-rate-guard.ts +101 -101
  1008. package/server/plugins/aml-twin-worker.ts +32 -32
  1009. package/server/plugins/dev-stability-guard.ts +42 -42
  1010. package/server/plugins-builtin/diag-bridge/client.mjs +32 -12
  1011. package/server/plugins-builtin/diag-bridge/host/constants.mjs +25 -25
  1012. package/server/plugins-builtin/diag-bridge/host/exports.mjs +104 -104
  1013. package/server/plugins-builtin/diag-bridge/host/helpers.mjs +39 -9
  1014. package/server/plugins-builtin/diag-bridge/host/index.mjs +15 -15
  1015. package/server/plugins-builtin/diag-bridge/host/intents.mjs +62 -62
  1016. package/server/plugins-builtin/diag-bridge/host/plugin.mjs +60 -26
  1017. package/server/plugins-builtin/diag-bridge/host/snapshot.mjs +93 -93
  1018. package/server/plugins-builtin/diag-bridge/index.mjs +9 -9
  1019. package/server/plugins-builtin/serial-bridge/client.mjs +211 -211
  1020. package/server/plugins-builtin/serial-bridge/drivers.mjs +409 -409
  1021. package/server/plugins-builtin/serial-bridge/i18n.json +62 -62
  1022. package/server/plugins-builtin/serial-bridge/index.mjs +247 -247
  1023. package/server/plugins-builtin/serial-bridge/lib.mjs +208 -208
  1024. package/server/plugins-builtin/serial-bridge/rtu.mjs +168 -168
  1025. package/server/services/system-config/contracts.ts +29 -29
  1026. package/server/services/system-config/dispose.ts +19 -19
  1027. package/server/services/system-config/facade.ts +26 -26
  1028. package/server/services/system-config/groups.ts +108 -108
  1029. package/server/services/system-config/index.ts +21 -21
  1030. package/server/services/system-config/init.ts +26 -26
  1031. package/server/services/system-config/mutate.ts +103 -103
  1032. package/server/services/system-config/plugins.ts +104 -104
  1033. package/server/services/system-config/snapshot.ts +59 -59
  1034. package/server/services/system-config/state.ts +79 -79
  1035. package/server/services/system-config/types.ts +58 -58
  1036. package/server/services/workshop/agents/adapters/omp-rpc-client/api.ts +111 -111
  1037. package/server/services/workshop/agents/adapters/omp-rpc-client/contracts.ts +22 -22
  1038. package/server/services/workshop/agents/adapters/omp-rpc-client/facade.ts +7 -7
  1039. package/server/services/workshop/agents/adapters/omp-rpc-client/frames.ts +0 -18
  1040. package/server/services/workshop/agents/adapters/omp-rpc-client/helpers.ts +38 -38
  1041. package/server/services/workshop/agents/adapters/omp-rpc-client/index.ts +25 -25
  1042. package/server/services/workshop/agents/adapters/omp-rpc-client/start.ts +70 -70
  1043. package/server/services/workshop/agents/adapters/omp-rpc-client/state.ts +65 -65
  1044. package/server/services/workshop/agents/adapters/omp-rpc-client/stdout.ts +92 -92
  1045. package/server/services/workshop/agents/adapters/omp-rpc-client/usage.ts +47 -47
  1046. package/server/services/workshop/agents/agent-badge.ts +38 -38
  1047. package/server/services/workshop/agents/binding-authz.ts +60 -60
  1048. package/server/services/workshop/agents/binding-mode.ts +51 -51
  1049. package/server/services/workshop/agents/codex-agent/client.ts +170 -170
  1050. package/server/services/workshop/agents/codex-agent/core.ts +119 -119
  1051. package/server/services/workshop/agents/codex-agent/facade.ts +8 -8
  1052. package/server/services/workshop/agents/codex-agent/helpers.ts +13 -13
  1053. package/server/services/workshop/agents/codex-agent/hitl.ts +138 -138
  1054. package/server/services/workshop/agents/codex-agent/index.ts +14 -14
  1055. package/server/services/workshop/agents/codex-agent/turn.ts +367 -367
  1056. package/server/services/workshop/agents/codex-agent/types.ts +42 -42
  1057. package/server/services/workshop/agents/harness-process.ts +3 -3
  1058. package/server/services/workshop/agents/harness-terminal/api.ts +197 -197
  1059. package/server/services/workshop/agents/harness-terminal/index.ts +17 -17
  1060. package/server/services/workshop/agents/harness-terminal/io.ts +120 -120
  1061. package/server/services/workshop/agents/harness-terminal/park.ts +55 -55
  1062. package/server/services/workshop/agents/harness-terminal/sanitize.ts +98 -98
  1063. package/server/services/workshop/agents/harness-terminal/session.ts +124 -124
  1064. package/server/services/workshop/agents/harness-terminal/shared.ts +74 -74
  1065. package/server/services/workshop/agents/hitl-capabilities.ts +312 -312
  1066. package/server/services/workshop/agents/hitl-decision/answers.ts +32 -32
  1067. package/server/services/workshop/agents/hitl-decision/decide.ts +268 -268
  1068. package/server/services/workshop/agents/hitl-decision/payload.ts +45 -45
  1069. package/server/services/workshop/agents/hitl-decision/shared.ts +108 -108
  1070. package/server/services/workshop/agents/hitl-decision/visibility.ts +94 -94
  1071. package/server/services/workshop/agents/host-tool-bridge/tools/progress.ts +84 -84
  1072. package/server/services/workshop/agents/host-tool-bridge/tools/team-delegation.ts +104 -104
  1073. package/server/services/workshop/agents/host-tool-bridge/tools/team.ts +70 -70
  1074. package/server/services/workshop/agents/industrial/aml-activity.ts +131 -131
  1075. package/server/services/workshop/agents/industrial/audit-query.ts +66 -66
  1076. package/server/services/workshop/agents/industrial/daq-tools.ts +352 -352
  1077. package/server/services/workshop/agents/industrial/exp-tools.ts +104 -104
  1078. package/server/services/workshop/agents/industrial/ops-tools.ts +16 -54
  1079. package/server/services/workshop/agents/industrial/param-tools.ts +69 -69
  1080. package/server/services/workshop/agents/industrial/recipe-gate.ts +6 -19
  1081. package/server/services/workshop/agents/industrial/recipe-propose-tools.ts +1 -1
  1082. package/server/services/workshop/agents/node-bindings.repo.ts +207 -207
  1083. package/server/services/workshop/agents/node-delegation.ts +159 -159
  1084. package/server/services/workshop/agents/omp-agent/core.ts +146 -146
  1085. package/server/services/workshop/agents/omp-agent/facade.ts +8 -8
  1086. package/server/services/workshop/agents/omp-agent/helpers.ts +37 -37
  1087. package/server/services/workshop/agents/omp-agent/index.ts +16 -16
  1088. package/server/services/workshop/agents/omp-agent/tools-steer.ts +1 -18
  1089. package/server/services/workshop/agents/omp-agent/types.ts +45 -45
  1090. package/server/services/workshop/agents/opencode-agent/core.ts +77 -77
  1091. package/server/services/workshop/agents/opencode-agent/facade.ts +8 -8
  1092. package/server/services/workshop/agents/opencode-agent/helpers.ts +29 -29
  1093. package/server/services/workshop/agents/opencode-agent/hitl.ts +113 -113
  1094. package/server/services/workshop/agents/opencode-agent/index.ts +16 -16
  1095. package/server/services/workshop/agents/opencode-agent/lifecycle.ts +44 -44
  1096. package/server/services/workshop/agents/opencode-agent/server.ts +244 -244
  1097. package/server/services/workshop/agents/opencode-agent/turn.ts +278 -278
  1098. package/server/services/workshop/agents/opencode-agent/types.ts +54 -54
  1099. package/server/services/workshop/agents/tool-classes.ts +44 -44
  1100. package/server/services/workshop/aml/clean.ts +120 -120
  1101. package/server/services/workshop/aml/entity.ts +367 -367
  1102. package/server/services/workshop/aml/job-orchestrator/broadcast.ts +37 -37
  1103. package/server/services/workshop/aml/job-orchestrator/control.ts +94 -94
  1104. package/server/services/workshop/aml/job-orchestrator/failure.ts +96 -96
  1105. package/server/services/workshop/aml/job-orchestrator/index.ts +22 -22
  1106. package/server/services/workshop/aml/job-orchestrator/process.ts +101 -101
  1107. package/server/services/workshop/aml/job-orchestrator/shared.ts +53 -53
  1108. package/server/services/workshop/aml/job-orchestrator/status.ts +20 -20
  1109. package/server/services/workshop/aml/job-orchestrator/tick.ts +37 -37
  1110. package/server/services/workshop/aml/python/train-example.py +92 -92
  1111. package/server/services/workshop/aml/runtime.ts +137 -137
  1112. package/server/services/workshop/aml/stats.ts +140 -140
  1113. package/server/services/workshop/aml/twin/calibration-worker.ts +150 -150
  1114. package/server/services/workshop/aml/twin/model-backed-provider.ts +332 -332
  1115. package/server/services/workshop/aml/twin/physics-spec-draft.ts +185 -185
  1116. package/server/services/workshop/aml/twin/prompt-composer.ts +143 -143
  1117. package/server/services/workshop/aml/twin/training-plans.ts +260 -260
  1118. package/server/services/workshop/aml/twin/write-guard.ts +19 -19
  1119. package/server/services/workshop/assets/character-asset.repo.ts +1 -1
  1120. package/server/services/workshop/assets/device-twin.repo.ts +1 -1
  1121. package/server/services/workshop/daq/bus/index.ts +5 -12
  1122. package/server/services/workshop/daq/daq-controller/contracts.ts +39 -39
  1123. package/server/services/workshop/daq/daq-controller/facade.ts +28 -28
  1124. package/server/services/workshop/daq/daq-controller/frames.ts +137 -137
  1125. package/server/services/workshop/daq/daq-controller/helpers.ts +52 -52
  1126. package/server/services/workshop/daq/daq-controller/index.ts +22 -22
  1127. package/server/services/workshop/daq/daq-controller/runtime-control.ts +72 -72
  1128. package/server/services/workshop/daq/daq-controller/sweep-alarms.ts +176 -176
  1129. package/server/services/workshop/daq/daq-controller/tsdb-twin.ts +138 -138
  1130. package/server/services/workshop/daq/drivers/http.ts +95 -95
  1131. package/server/services/workshop/daq/drivers/mock.ts +130 -130
  1132. package/server/services/workshop/daq/drivers/modbus-rtu.ts +67 -67
  1133. package/server/services/workshop/daq/drivers/modbus-tcp.ts +307 -307
  1134. package/server/services/workshop/daq/drivers/opcua.ts +227 -227
  1135. package/server/services/workshop/daq/drivers/s7-stub.ts +29 -29
  1136. package/server/services/workshop/daq/host-bindings.ts +71 -71
  1137. package/server/services/workshop/daq/host-ports.ts +65 -65
  1138. package/server/services/workshop/db/aml-team-seeds.ts +118 -118
  1139. package/server/services/workshop/db/backup-registry.ts +33 -33
  1140. package/server/services/workshop/db/channel-member.repo.ts +122 -122
  1141. package/server/services/workshop/db/channel.repo.ts +203 -203
  1142. package/server/services/workshop/db/chat-message.repo.ts +233 -233
  1143. package/server/services/workshop/db/database/index.ts +18 -18
  1144. package/server/services/workshop/db/database/json.ts +14 -14
  1145. package/server/services/workshop/db/database/open.ts +97 -97
  1146. package/server/services/workshop/db/database/seed-data.ts +60 -60
  1147. package/server/services/workshop/db/hitl-request.repo.ts +221 -221
  1148. package/server/services/workshop/db/notification.repo.ts +199 -199
  1149. package/server/services/workshop/db/readonly.ts +30 -30
  1150. package/server/services/workshop/db/scheduled-task.repo.ts +235 -235
  1151. package/server/services/workshop/db/transaction.ts +72 -72
  1152. package/server/services/workshop/dcw/dcw-controller/contracts.ts +16 -16
  1153. package/server/services/workshop/dcw/dcw-controller/control.ts +78 -78
  1154. package/server/services/workshop/dcw/dcw-controller/facade.ts +19 -19
  1155. package/server/services/workshop/dcw/dcw-controller/index.ts +22 -22
  1156. package/server/services/workshop/dcw/dcw-controller/params.ts +97 -97
  1157. package/server/services/workshop/dcw/dcw-controller/products.ts +103 -103
  1158. package/server/services/workshop/dcw/dcw-controller/write-audit.ts +49 -49
  1159. package/server/services/workshop/dcw/dcw-templates.ts +136 -136
  1160. package/server/services/workshop/dcw/param-conversion.ts +78 -78
  1161. package/server/services/workshop/dcw/param-map.repo.ts +349 -349
  1162. package/server/services/workshop/dcw/plugin-bridge.ts +45 -45
  1163. package/server/services/workshop/dcw/recipe-rollback-manager/contracts.ts +26 -26
  1164. package/server/services/workshop/dcw/recipe-rollback-manager/facade.ts +13 -13
  1165. package/server/services/workshop/dcw/recipe-rollback-manager/helpers.ts +30 -30
  1166. package/server/services/workshop/dcw/recipe-rollback-manager/index.ts +17 -17
  1167. package/server/services/workshop/dcw/recipe-rollback-manager/internal.ts +33 -33
  1168. package/server/services/workshop/dcw/recipe-rollback-manager/judge.ts +52 -52
  1169. package/server/services/workshop/dcw/recipe-rollback-manager/lock.ts +137 -137
  1170. package/server/services/workshop/dcw/recipe-rollback-manager/rollback.ts +190 -190
  1171. package/server/services/workshop/dcw/recipe-rollback-manager/state.ts +21 -21
  1172. package/server/services/workshop/dcw/recipe-rollback-manager/sweep.ts +77 -77
  1173. package/server/services/workshop/dcw/recipe-rollback-manager/types.ts +3 -3
  1174. package/server/services/workshop/dcw/recipe-rollback-manager/views.ts +214 -214
  1175. package/server/services/workshop/exp/exp-collector.ts +275 -275
  1176. package/server/services/workshop/exp/exp-state.repo.ts +339 -339
  1177. package/server/services/workshop/mes/mes-controller.ts +1155 -1155
  1178. package/server/services/workshop/mes/mes-hook.ts +567 -567
  1179. package/server/services/workshop/ontology/subgraph.core.ts +300 -300
  1180. package/server/services/workshop/ontology/subgraph.service.ts +113 -113
  1181. package/server/services/workshop/plugins/host/api.mjs +90 -90
  1182. package/server/services/workshop/plugins/host/config.mjs +135 -135
  1183. package/server/services/workshop/plugins/host/index.mjs +23 -23
  1184. package/server/services/workshop/plugins/host/init.mjs +109 -109
  1185. package/server/services/workshop/plugins/host/load.mjs +321 -321
  1186. package/server/services/workshop/plugins/host/reload.mjs +94 -94
  1187. package/server/services/workshop/plugins/host/rollback.mjs +72 -72
  1188. package/server/services/workshop/plugins/host/state.mjs +54 -54
  1189. package/server/services/workshop/plugins/host/toggle.mjs +64 -64
  1190. package/server/services/workshop/plugins/host.mjs +9 -9
  1191. package/server/services/workshop/runtime/agent-runtime/facade.ts +7 -7
  1192. package/server/services/workshop/runtime/agent-runtime/helpers.ts +18 -18
  1193. package/server/services/workshop/runtime/agent-runtime/index.ts +19 -19
  1194. package/server/services/workshop/runtime/agent-runtime/lifecycle.ts +137 -137
  1195. package/server/services/workshop/runtime/chat-mention.ts +164 -164
  1196. package/server/services/workshop/runtime/chat-projection.ts +246 -246
  1197. package/server/services/workshop/runtime/manager/admin-agents.ts +268 -268
  1198. package/server/services/workshop/runtime/manager/bus.ts +182 -182
  1199. package/server/services/workshop/runtime/manager/channel-template-constants.ts +20 -20
  1200. package/server/services/workshop/runtime/manager/chat-reply.ts +181 -181
  1201. package/server/services/workshop/runtime/manager/chat.ts +384 -384
  1202. package/server/services/workshop/runtime/manager/facade.ts +24 -24
  1203. package/server/services/workshop/runtime/manager/helpers.ts +119 -119
  1204. package/server/services/workshop/runtime/manager/index.ts +42 -42
  1205. package/server/services/workshop/runtime/manager/internal.ts +73 -73
  1206. package/server/services/workshop/runtime/manager/notifications.ts +108 -108
  1207. package/server/services/workshop/runtime/manager/teams.ts +148 -148
  1208. package/server/services/workshop/runtime/memory/contracts.ts +18 -18
  1209. package/server/services/workshop/runtime/memory/facade.ts +10 -10
  1210. package/server/services/workshop/runtime/memory/helpers.ts +196 -196
  1211. package/server/services/workshop/runtime/memory/index.ts +27 -27
  1212. package/server/services/workshop/runtime/memory/score.ts +33 -33
  1213. package/server/services/workshop/runtime/memory/state.ts +40 -40
  1214. package/server/services/workshop/runtime/monitor.ts +3 -3
  1215. package/server/services/workshop/runtime/platform-notice.ts +113 -113
  1216. package/server/services/workshop/runtime/schedule-runtime.ts +347 -347
  1217. package/server/services/workshop/runtime/scheduler-loop/contracts.ts +29 -29
  1218. package/server/services/workshop/runtime/scheduler-loop/facade.ts +7 -7
  1219. package/server/services/workshop/runtime/scheduler-loop/helpers.ts +14 -14
  1220. package/server/services/workshop/runtime/scheduler-loop/index.ts +16 -16
  1221. package/server/services/workshop/runtime/task-engine/facade.ts +7 -7
  1222. package/server/services/workshop/runtime/task-engine/index.ts +15 -15
  1223. package/server/services/workshop/runtime/task-engine/types.ts +3 -3
  1224. package/server/services/workshop/runtime/user-notification-hub.ts +192 -192
  1225. package/server/types/pg.d.ts +49 -49
  1226. package/server/utils/approval-gate.ts +67 -67
  1227. package/server/utils/mojibake-guard.ts +29 -29
  1228. package/server/utils/stability-severity.ts +77 -77
  1229. package/shared/config/groups.mjs +241 -241
  1230. package/shared/dcw-protocol/catalog.ts +232 -232
  1231. package/shared/dcw-protocol/closed-loop.ts +137 -137
  1232. package/shared/lru.mjs +97 -97
  1233. package/tui/README.md +74 -74
  1234. package/tui/aw-tui.mjs +445 -445
  1235. package/tui/commands/index.mjs +287 -287
  1236. package/tui/components/chat-log.mjs +42 -42
  1237. package/tui/components/monitor-pane.mjs +39 -39
  1238. package/tui/components/root.mjs +53 -53
  1239. package/tui/components/status-bar.mjs +33 -33
  1240. package/tui/lib/api.mjs +82 -82
  1241. package/tui/lib/pickers.mjs +121 -121
  1242. package/tui/lib/reducers.mjs +218 -218
  1243. package/tui/lib/state.mjs +86 -86
  1244. package/tui/lib/virtual-terminal.mjs +48 -48
  1245. package/tui/lib/ws.mjs +125 -125
  1246. package/tui/theme.mjs +38 -38
  1247. package/.output/.AgentWorkShop/aml-python/__pycache__/aml_eval.cpython-312.pyc +0 -0
  1248. package/.output/.AgentWorkShop/aml-python/__pycache__/amlkit.cpython-312.pyc +0 -0
  1249. package/.output/.AgentWorkShop/aml-python/__pycache__/train-example.cpython-312.pyc +0 -0
  1250. package/.output/.AgentWorkShop/aml-python/__pycache__/train-hybrid-example.cpython-312.pyc +0 -0
  1251. package/.output/public/_nuxt/BRYBzVMJ.js +0 -1
  1252. package/.output/public/_nuxt/BW2uTUx52.js +0 -2
  1253. package/.output/public/_nuxt/BtZKe9ZV.js +0 -1
  1254. package/.output/public/_nuxt/CfFUK6932.js +0 -2
  1255. package/.output/public/_nuxt/DhW7cFOa.js +0 -1
  1256. package/.output/public/_nuxt/OmpTerminalPanel.ComMDrA8.css +0 -1
  1257. package/.output/public/_nuxt/PluginSlot.CGH0vb95.css +0 -1
  1258. package/.output/public/_nuxt/TownView.CC3t-Dte.css +0 -1
  1259. package/.output/public/_nuxt/aml.PalMp-5n.css +0 -1
  1260. package/.output/public/_nuxt/builds/meta/fa0af8b5-3929-428d-a6de-3b5cc6b8248f.json +0 -1
  1261. package/.output/public/_nuxt/permissions.DxuOOIqQ.css +0 -1
  1262. package/.output/public/_nuxt/schedules.BXNJ9q_I.css +0 -1
  1263. package/.output/public/_nuxt/tools.BwXFAb-X.css +0 -1
  1264. package/.output/server/chunks/build/AuthGate-nF1evO4v.mjs +0 -716
  1265. package/.output/server/chunks/build/AuthGate-nF1evO4v.mjs.map +0 -1
  1266. package/.output/server/chunks/build/FormItemContext-BlyzocS0.mjs +0 -72
  1267. package/.output/server/chunks/build/FormItemContext-BlyzocS0.mjs.map +0 -1
  1268. package/.output/server/chunks/build/OmpTerminalPanel-BhvhQ1gG.mjs +0 -942
  1269. package/.output/server/chunks/build/OmpTerminalPanel-BhvhQ1gG.mjs.map +0 -1
  1270. package/.output/server/chunks/build/PluginSlot-BUKXwV2X.mjs +0 -141
  1271. package/.output/server/chunks/build/PluginSlot-BUKXwV2X.mjs.map +0 -1
  1272. package/.output/server/chunks/build/TownView-BWMDbosY.mjs +0 -6489
  1273. package/.output/server/chunks/build/TownView-BWMDbosY.mjs.map +0 -1
  1274. package/.output/server/chunks/build/_id_-BK-t8nRG.mjs +0 -392
  1275. package/.output/server/chunks/build/_id_-BK-t8nRG.mjs.map +0 -1
  1276. package/.output/server/chunks/build/_id_-CZPlPDm4.mjs +0 -2045
  1277. package/.output/server/chunks/build/_id_-CZPlPDm4.mjs.map +0 -1
  1278. package/.output/server/chunks/build/_wsId_-BPy-Aj9L.mjs +0 -14297
  1279. package/.output/server/chunks/build/_wsId_-BPy-Aj9L.mjs.map +0 -1
  1280. package/.output/server/chunks/build/agents-CpNLdI8E.mjs +0 -1078
  1281. package/.output/server/chunks/build/agents-CpNLdI8E.mjs.map +0 -1
  1282. package/.output/server/chunks/build/alert-D0ivtTGy.mjs +0 -263
  1283. package/.output/server/chunks/build/alert-D0ivtTGy.mjs.map +0 -1
  1284. package/.output/server/chunks/build/aml-DRAFRcGU.mjs +0 -814
  1285. package/.output/server/chunks/build/aml-DRAFRcGU.mjs.map +0 -1
  1286. package/.output/server/chunks/build/analysis-p-dBkjoK.mjs +0 -533
  1287. package/.output/server/chunks/build/analysis-p-dBkjoK.mjs.map +0 -1
  1288. package/.output/server/chunks/build/api-B4Om0mEc.mjs.map +0 -1
  1289. package/.output/server/chunks/build/api-BEW_ebY_.mjs.map +0 -1
  1290. package/.output/server/chunks/build/api-BsAgXWxi.mjs.map +0 -1
  1291. package/.output/server/chunks/build/api-error-BwAQLw44.mjs +0 -47
  1292. package/.output/server/chunks/build/api-error-BwAQLw44.mjs.map +0 -1
  1293. package/.output/server/chunks/build/apiClient-BvXtNzC8.mjs +0 -81
  1294. package/.output/server/chunks/build/apiClient-BvXtNzC8.mjs.map +0 -1
  1295. package/.output/server/chunks/build/board-Dl2Ar22r.mjs +0 -178
  1296. package/.output/server/chunks/build/board-Dl2Ar22r.mjs.map +0 -1
  1297. package/.output/server/chunks/build/card-Cqk0Ur-L.mjs +0 -953
  1298. package/.output/server/chunks/build/card-Cqk0Ur-L.mjs.map +0 -1
  1299. package/.output/server/chunks/build/channel-templates-ByHOQQkO.mjs +0 -942
  1300. package/.output/server/chunks/build/channel-templates-ByHOQQkO.mjs.map +0 -1
  1301. package/.output/server/chunks/build/checkbox-CrT4cnfu.mjs +0 -439
  1302. package/.output/server/chunks/build/checkbox-CrT4cnfu.mjs.map +0 -1
  1303. package/.output/server/chunks/build/client-only-qNA2OVV_.mjs +0 -43
  1304. package/.output/server/chunks/build/client-only-qNA2OVV_.mjs.map +0 -1
  1305. package/.output/server/chunks/build/core-CgTOPS4t.mjs +0 -294
  1306. package/.output/server/chunks/build/core-CgTOPS4t.mjs.map +0 -1
  1307. package/.output/server/chunks/build/daq-CdxcfY_G.mjs +0 -1266
  1308. package/.output/server/chunks/build/daq-CdxcfY_G.mjs.map +0 -1
  1309. package/.output/server/chunks/build/data-D8uX1dnm.mjs +0 -481
  1310. package/.output/server/chunks/build/data-D8uX1dnm.mjs.map +0 -1
  1311. package/.output/server/chunks/build/dcw-BlDQtS4q.mjs +0 -505
  1312. package/.output/server/chunks/build/dcw-BlDQtS4q.mjs.map +0 -1
  1313. package/.output/server/chunks/build/default-CNWS6NUw.mjs +0 -2353
  1314. package/.output/server/chunks/build/default-CNWS6NUw.mjs.map +0 -1
  1315. package/.output/server/chunks/build/descriptions-BNlfKG9y.mjs +0 -406
  1316. package/.output/server/chunks/build/descriptions-BNlfKG9y.mjs.map +0 -1
  1317. package/.output/server/chunks/build/drawer-Caji0PLs.mjs +0 -834
  1318. package/.output/server/chunks/build/drawer-Caji0PLs.mjs.map +0 -1
  1319. package/.output/server/chunks/build/dropdown-BNwTVGde.mjs +0 -14
  1320. package/.output/server/chunks/build/dropdown-BNwTVGde.mjs.map +0 -1
  1321. package/.output/server/chunks/build/dropdown-Cd-xPhR6.mjs +0 -540
  1322. package/.output/server/chunks/build/dropdown-Cd-xPhR6.mjs.map +0 -1
  1323. package/.output/server/chunks/build/es-Bxu10NJ2.mjs.map +0 -1
  1324. package/.output/server/chunks/build/firstNotUndefined-8H5_qHUu.mjs +0 -2448
  1325. package/.output/server/chunks/build/firstNotUndefined-8H5_qHUu.mjs.map +0 -1
  1326. package/.output/server/chunks/build/form-D_UpWPN4.mjs +0 -4712
  1327. package/.output/server/chunks/build/form-D_UpWPN4.mjs.map +0 -1
  1328. package/.output/server/chunks/build/hasIn-DBdElbjM.mjs +0 -553
  1329. package/.output/server/chunks/build/hasIn-DBdElbjM.mjs.map +0 -1
  1330. package/.output/server/chunks/build/hitl-Bd30yr1J.mjs +0 -132
  1331. package/.output/server/chunks/build/hitl-Bd30yr1J.mjs.map +0 -1
  1332. package/.output/server/chunks/build/input-GtPuSEgt.mjs +0 -2181
  1333. package/.output/server/chunks/build/input-GtPuSEgt.mjs.map +0 -1
  1334. package/.output/server/chunks/build/input-number-BNlNDK7H.mjs +0 -1120
  1335. package/.output/server/chunks/build/input-number-BNlNDK7H.mjs.map +0 -1
  1336. package/.output/server/chunks/build/interval-DvHBIIZh.mjs +0 -9
  1337. package/.output/server/chunks/build/interval-DvHBIIZh.mjs.map +0 -1
  1338. package/.output/server/chunks/build/isNumeric-CP7q_yhz.mjs +0 -7
  1339. package/.output/server/chunks/build/isNumeric-CP7q_yhz.mjs.map +0 -1
  1340. package/.output/server/chunks/build/logs-pRb-TMWa.mjs +0 -427
  1341. package/.output/server/chunks/build/logs-pRb-TMWa.mjs.map +0 -1
  1342. package/.output/server/chunks/build/menu-BXt-X0dt.mjs +0 -1952
  1343. package/.output/server/chunks/build/menu-BXt-X0dt.mjs.map +0 -1
  1344. package/.output/server/chunks/build/monitor-Cq6hRFeQ.mjs +0 -2253
  1345. package/.output/server/chunks/build/monitor-Cq6hRFeQ.mjs.map +0 -1
  1346. package/.output/server/chunks/build/ontology-DK0Mf0zT.mjs +0 -1406
  1347. package/.output/server/chunks/build/ontology-DK0Mf0zT.mjs.map +0 -1
  1348. package/.output/server/chunks/build/operations-SMQrRAcr.mjs +0 -311
  1349. package/.output/server/chunks/build/operations-SMQrRAcr.mjs.map +0 -1
  1350. package/.output/server/chunks/build/optimizer-BlWTsM-W.mjs +0 -202
  1351. package/.output/server/chunks/build/optimizer-BlWTsM-W.mjs.map +0 -1
  1352. package/.output/server/chunks/build/pages-AFRP4-EL.mjs +0 -542
  1353. package/.output/server/chunks/build/pages-AFRP4-EL.mjs.map +0 -1
  1354. package/.output/server/chunks/build/pagination-DTAconUo.mjs +0 -1346
  1355. package/.output/server/chunks/build/pagination-DTAconUo.mjs.map +0 -1
  1356. package/.output/server/chunks/build/permissions-DgXQZSyx.mjs +0 -637
  1357. package/.output/server/chunks/build/permissions-DgXQZSyx.mjs.map +0 -1
  1358. package/.output/server/chunks/build/plugins-LRjaSEZy.mjs +0 -272
  1359. package/.output/server/chunks/build/plugins-LRjaSEZy.mjs.map +0 -1
  1360. package/.output/server/chunks/build/popconfirm-DxYPGRgS.mjs +0 -340
  1361. package/.output/server/chunks/build/popconfirm-DxYPGRgS.mjs.map +0 -1
  1362. package/.output/server/chunks/build/responsiveObserve-DM3hpzhU.mjs +0 -78
  1363. package/.output/server/chunks/build/responsiveObserve-DM3hpzhU.mjs.map +0 -1
  1364. package/.output/server/chunks/build/schedules-dSnr8url.mjs +0 -7172
  1365. package/.output/server/chunks/build/schedules-dSnr8url.mjs.map +0 -1
  1366. package/.output/server/chunks/build/segmented-D3HWtHPw.mjs +0 -341
  1367. package/.output/server/chunks/build/segmented-D3HWtHPw.mjs.map +0 -1
  1368. package/.output/server/chunks/build/select-B3Dsb9yq.mjs +0 -3923
  1369. package/.output/server/chunks/build/select-B3Dsb9yq.mjs.map +0 -1
  1370. package/.output/server/chunks/build/settings-BrIhnS2Z.mjs +0 -1014
  1371. package/.output/server/chunks/build/settings-BrIhnS2Z.mjs.map +0 -1
  1372. package/.output/server/chunks/build/space-Dwu2Skt8.mjs +0 -110
  1373. package/.output/server/chunks/build/space-Dwu2Skt8.mjs.map +0 -1
  1374. package/.output/server/chunks/build/spin-C2cuvGth.mjs +0 -357
  1375. package/.output/server/chunks/build/spin-C2cuvGth.mjs.map +0 -1
  1376. package/.output/server/chunks/build/studio-cdoNCfyy.mjs +0 -332
  1377. package/.output/server/chunks/build/studio-cdoNCfyy.mjs.map +0 -1
  1378. package/.output/server/chunks/build/switch-CyR-H6Fb.mjs +0 -377
  1379. package/.output/server/chunks/build/switch-CyR-H6Fb.mjs.map +0 -1
  1380. package/.output/server/chunks/build/table-CmVD-cA9.mjs +0 -7546
  1381. package/.output/server/chunks/build/table-CmVD-cA9.mjs.map +0 -1
  1382. package/.output/server/chunks/build/tabs-Vg0e7cZE.mjs +0 -1924
  1383. package/.output/server/chunks/build/tabs-Vg0e7cZE.mjs.map +0 -1
  1384. package/.output/server/chunks/build/tag-y0sn-xv9.mjs +0 -1156
  1385. package/.output/server/chunks/build/tag-y0sn-xv9.mjs.map +0 -1
  1386. package/.output/server/chunks/build/teams-B1d32eHK.mjs +0 -1203
  1387. package/.output/server/chunks/build/teams-B1d32eHK.mjs.map +0 -1
  1388. package/.output/server/chunks/build/tokens-GYaGJ35Z.mjs +0 -1062
  1389. package/.output/server/chunks/build/tokens-GYaGJ35Z.mjs.map +0 -1
  1390. package/.output/server/chunks/build/tools-s_9U1Djj.mjs +0 -487
  1391. package/.output/server/chunks/build/tools-s_9U1Djj.mjs.map +0 -1
  1392. package/.output/server/chunks/build/tooltip-C2n2nNiQ.mjs +0 -920
  1393. package/.output/server/chunks/build/tooltip-C2n2nNiQ.mjs.map +0 -1
  1394. package/.output/server/chunks/build/town-B5aoiG98.mjs +0 -133
  1395. package/.output/server/chunks/build/town-B5aoiG98.mjs.map +0 -1
  1396. package/.output/server/chunks/build/useAgentHarnessOptions-DOrQHeBh.mjs +0 -124
  1397. package/.output/server/chunks/build/useAgentHarnessOptions-DOrQHeBh.mjs.map +0 -1
  1398. package/.output/server/chunks/build/useAgentTemplateActions-CzlplRWh.mjs +0 -77
  1399. package/.output/server/chunks/build/useAgentTemplateActions-CzlplRWh.mjs.map +0 -1
  1400. package/.output/server/chunks/build/useAgentTemplateForm-DQo1enf2.mjs +0 -117
  1401. package/.output/server/chunks/build/useAgentTemplateForm-DQo1enf2.mjs.map +0 -1
  1402. package/.output/server/chunks/build/useAgentTemplatesCatalog-DP-iMmqz.mjs +0 -133
  1403. package/.output/server/chunks/build/useAgentTemplatesCatalog-DP-iMmqz.mjs.map +0 -1
  1404. package/.output/server/chunks/build/useAmlDatasets-DeoE1idn.mjs +0 -92
  1405. package/.output/server/chunks/build/useAmlDatasets-DeoE1idn.mjs.map +0 -1
  1406. package/.output/server/chunks/build/useAmlEntities-BJhvdqHJ.mjs +0 -86
  1407. package/.output/server/chunks/build/useAmlEntities-BJhvdqHJ.mjs.map +0 -1
  1408. package/.output/server/chunks/build/useAmlEnv-CDIZ6xTe.mjs +0 -194
  1409. package/.output/server/chunks/build/useAmlEnv-CDIZ6xTe.mjs.map +0 -1
  1410. package/.output/server/chunks/build/useAmlExperiments-Dloi834i.mjs +0 -89
  1411. package/.output/server/chunks/build/useAmlExperiments-Dloi834i.mjs.map +0 -1
  1412. package/.output/server/chunks/build/useAmlJobs-BF9LpwXz.mjs +0 -267
  1413. package/.output/server/chunks/build/useAmlJobs-BF9LpwXz.mjs.map +0 -1
  1414. package/.output/server/chunks/build/useAmlModels-_bweOr3R.mjs +0 -93
  1415. package/.output/server/chunks/build/useAmlModels-_bweOr3R.mjs.map +0 -1
  1416. package/.output/server/chunks/build/useAmlNotes-DQj980iX.mjs +0 -86
  1417. package/.output/server/chunks/build/useAmlNotes-DQj980iX.mjs.map +0 -1
  1418. package/.output/server/chunks/build/useAmlPredict-DHNgDSJn.mjs +0 -130
  1419. package/.output/server/chunks/build/useAmlPredict-DHNgDSJn.mjs.map +0 -1
  1420. package/.output/server/chunks/build/useAnalysisFeed-BrEGV_9x.mjs +0 -129
  1421. package/.output/server/chunks/build/useAnalysisFeed-BrEGV_9x.mjs.map +0 -1
  1422. package/.output/server/chunks/build/useDaqAddNode-D_Rkju0f.mjs +0 -142
  1423. package/.output/server/chunks/build/useDaqAddNode-D_Rkju0f.mjs.map +0 -1
  1424. package/.output/server/chunks/build/useDaqDetailBinding-DCWaLKXT.mjs +0 -70
  1425. package/.output/server/chunks/build/useDaqDetailBinding-DCWaLKXT.mjs.map +0 -1
  1426. package/.output/server/chunks/build/useDaqDetailFrames-BOIcOJRB.mjs +0 -79
  1427. package/.output/server/chunks/build/useDaqDetailFrames-BOIcOJRB.mjs.map +0 -1
  1428. package/.output/server/chunks/build/useDaqDetailHistory-D6WulPVs.mjs +0 -176
  1429. package/.output/server/chunks/build/useDaqDetailHistory-D6WulPVs.mjs.map +0 -1
  1430. package/.output/server/chunks/build/useDaqDetailNode-DeOsDxK5.mjs +0 -99
  1431. package/.output/server/chunks/build/useDaqDetailNode-DeOsDxK5.mjs.map +0 -1
  1432. package/.output/server/chunks/build/useDaqDetailParams-Cm9a9r5G.mjs +0 -159
  1433. package/.output/server/chunks/build/useDaqDetailParams-Cm9a9r5G.mjs.map +0 -1
  1434. package/.output/server/chunks/build/useDaqFilters-CctmO03p.mjs +0 -222
  1435. package/.output/server/chunks/build/useDaqFilters-CctmO03p.mjs.map +0 -1
  1436. package/.output/server/chunks/build/useDaqOptimizations-CmX_dpBc.mjs +0 -136
  1437. package/.output/server/chunks/build/useDaqOptimizations-CmX_dpBc.mjs.map +0 -1
  1438. package/.output/server/chunks/build/useDaqStream-B9ZBVQrI.mjs +0 -395
  1439. package/.output/server/chunks/build/useDaqStream-B9ZBVQrI.mjs.map +0 -1
  1440. package/.output/server/chunks/build/useDaqTemplates-CK37sMfi.mjs +0 -187
  1441. package/.output/server/chunks/build/useDaqTemplates-CK37sMfi.mjs.map +0 -1
  1442. package/.output/server/chunks/build/useDashboardData-B36wVWo2.mjs +0 -153
  1443. package/.output/server/chunks/build/useDashboardData-B36wVWo2.mjs.map +0 -1
  1444. package/.output/server/chunks/build/useDcwAddNode-DACVcEHs.mjs +0 -219
  1445. package/.output/server/chunks/build/useDcwAddNode-DACVcEHs.mjs.map +0 -1
  1446. package/.output/server/chunks/build/useDcwCards-SaiImIYQ.mjs.map +0 -1
  1447. package/.output/server/chunks/build/useDcwDetailScope-DLOklSMO.mjs +0 -184
  1448. package/.output/server/chunks/build/useDcwDetailScope-DLOklSMO.mjs.map +0 -1
  1449. package/.output/server/chunks/build/useDcwDetailTemplates-ClmIdZ40.mjs +0 -148
  1450. package/.output/server/chunks/build/useDcwDetailTemplates-ClmIdZ40.mjs.map +0 -1
  1451. package/.output/server/chunks/build/useDcwFilter-CPMyCltx.mjs +0 -71
  1452. package/.output/server/chunks/build/useDcwFilter-CPMyCltx.mjs.map +0 -1
  1453. package/.output/server/chunks/build/useDcwLedger-0ie-0WTc.mjs.map +0 -1
  1454. package/.output/server/chunks/build/useDcwLineMutations-DNxo66yM.mjs +0 -137
  1455. package/.output/server/chunks/build/useDcwLineMutations-DNxo66yM.mjs.map +0 -1
  1456. package/.output/server/chunks/build/useDcwLineRun-CHskwscT.mjs +0 -104
  1457. package/.output/server/chunks/build/useDcwLineRun-CHskwscT.mjs.map +0 -1
  1458. package/.output/server/chunks/build/useDcwParamApprovals-DtScUc-W.mjs +0 -121
  1459. package/.output/server/chunks/build/useDcwParamApprovals-DtScUc-W.mjs.map +0 -1
  1460. package/.output/server/chunks/build/useDcwProducts-BMaxzLu6.mjs +0 -93
  1461. package/.output/server/chunks/build/useDcwProducts-BMaxzLu6.mjs.map +0 -1
  1462. package/.output/server/chunks/build/useDcwQuery-TVU3Eo0M.mjs +0 -98
  1463. package/.output/server/chunks/build/useDcwQuery-TVU3Eo0M.mjs.map +0 -1
  1464. package/.output/server/chunks/build/useDcwQuickActions-BREFmR9T.mjs +0 -88
  1465. package/.output/server/chunks/build/useDcwQuickActions-BREFmR9T.mjs.map +0 -1
  1466. package/.output/server/chunks/build/useDcwRecipes-Bc9urA1N.mjs +0 -258
  1467. package/.output/server/chunks/build/useDcwRecipes-Bc9urA1N.mjs.map +0 -1
  1468. package/.output/server/chunks/build/useDcwStream-Dir5ufAU.mjs +0 -452
  1469. package/.output/server/chunks/build/useDcwStream-Dir5ufAU.mjs.map +0 -1
  1470. package/.output/server/chunks/build/useDcwTemplates-BzagZztS.mjs +0 -91
  1471. package/.output/server/chunks/build/useDcwTemplates-BzagZztS.mjs.map +0 -1
  1472. package/.output/server/chunks/build/useDcwWrites-BROwTLCn.mjs +0 -140
  1473. package/.output/server/chunks/build/useDcwWrites-BROwTLCn.mjs.map +0 -1
  1474. package/.output/server/chunks/build/useDeviceTwins-BqwVJaZg.mjs +0 -128
  1475. package/.output/server/chunks/build/useDeviceTwins-BqwVJaZg.mjs.map +0 -1
  1476. package/.output/server/chunks/build/useExpConfirmations-BM626N4p.mjs +0 -107
  1477. package/.output/server/chunks/build/useExpConfirmations-BM626N4p.mjs.map +0 -1
  1478. package/.output/server/chunks/build/useLocalTime-uVSM44Um.mjs +0 -55
  1479. package/.output/server/chunks/build/useLocalTime-uVSM44Um.mjs.map +0 -1
  1480. package/.output/server/chunks/build/useLogsManual-cVBZQ_Mt.mjs +0 -88
  1481. package/.output/server/chunks/build/useLogsManual-cVBZQ_Mt.mjs.map +0 -1
  1482. package/.output/server/chunks/build/useLogsQuery-D7hrJ3yn.mjs +0 -150
  1483. package/.output/server/chunks/build/useLogsQuery-D7hrJ3yn.mjs.map +0 -1
  1484. package/.output/server/chunks/build/useLogsScope-aaPQeTRm.mjs +0 -83
  1485. package/.output/server/chunks/build/useLogsScope-aaPQeTRm.mjs.map +0 -1
  1486. package/.output/server/chunks/build/useMonitorData-DIkiLr_h.mjs +0 -135
  1487. package/.output/server/chunks/build/useMonitorData-DIkiLr_h.mjs.map +0 -1
  1488. package/.output/server/chunks/build/useMonitorFormat-CyURtH8N.mjs +0 -91
  1489. package/.output/server/chunks/build/useMonitorFormat-CyURtH8N.mjs.map +0 -1
  1490. package/.output/server/chunks/build/useOperationsFeed-Ci4mZAn_.mjs +0 -195
  1491. package/.output/server/chunks/build/useOperationsFeed-Ci4mZAn_.mjs.map +0 -1
  1492. package/.output/server/chunks/build/useOpsLog-C-M6Eace.mjs +0 -149
  1493. package/.output/server/chunks/build/useOpsLog-C-M6Eace.mjs.map +0 -1
  1494. package/.output/server/chunks/build/useRecipeDispatchApprovals-BYtiqfeb.mjs +0 -156
  1495. package/.output/server/chunks/build/useRecipeDispatchApprovals-BYtiqfeb.mjs.map +0 -1
  1496. package/.output/server/chunks/build/useTeamActions-I_8QWp9w.mjs +0 -79
  1497. package/.output/server/chunks/build/useTeamActions-I_8QWp9w.mjs.map +0 -1
  1498. package/.output/server/chunks/build/useTeamAddMemberDialog-BLn4nTuy.mjs +0 -84
  1499. package/.output/server/chunks/build/useTeamAddMemberDialog-BLn4nTuy.mjs.map +0 -1
  1500. package/.output/server/chunks/build/useTeamCreateDialog-Bp5qKtpI.mjs +0 -97
  1501. package/.output/server/chunks/build/useTeamCreateDialog-Bp5qKtpI.mjs.map +0 -1
  1502. package/.output/server/chunks/build/useTeamDeployDialog-DwIaz6Cx.mjs +0 -80
  1503. package/.output/server/chunks/build/useTeamDeployDialog-DwIaz6Cx.mjs.map +0 -1
  1504. package/.output/server/chunks/build/useTeamPluginDialog-B932gZOI.mjs +0 -103
  1505. package/.output/server/chunks/build/useTeamPluginDialog-B932gZOI.mjs.map +0 -1
  1506. package/.output/server/chunks/build/useTeamsCatalog-DBwaLQBw.mjs +0 -123
  1507. package/.output/server/chunks/build/useTeamsCatalog-DBwaLQBw.mjs.map +0 -1
  1508. package/.output/server/chunks/build/useTokenCreate-Ctl0YGhL.mjs +0 -115
  1509. package/.output/server/chunks/build/useTokenCreate-Ctl0YGhL.mjs.map +0 -1
  1510. package/.output/server/chunks/build/useTokenRename-Cm3ypSfN.mjs +0 -87
  1511. package/.output/server/chunks/build/useTokenRename-Cm3ypSfN.mjs.map +0 -1
  1512. package/.output/server/chunks/build/useTokenReveal-CeoWL5Mt.mjs +0 -118
  1513. package/.output/server/chunks/build/useTokenReveal-CeoWL5Mt.mjs.map +0 -1
  1514. package/.output/server/chunks/build/useTokensList-CNIzON3u.mjs +0 -92
  1515. package/.output/server/chunks/build/useTokensList-CNIzON3u.mjs.map +0 -1
  1516. package/.output/server/chunks/build/useWorkbenchAuth-CY-bVFMu.mjs +0 -141
  1517. package/.output/server/chunks/build/useWorkbenchAuth-CY-bVFMu.mjs.map +0 -1
  1518. package/.output/server/chunks/build/useWorkbenchWorkspaces-DhZQFss9.mjs +0 -138
  1519. package/.output/server/chunks/build/useWorkbenchWorkspaces-DhZQFss9.mjs.map +0 -1
  1520. package/.output/server/chunks/build/useWorkshopApi-CaSItJVq.mjs +0 -119
  1521. package/.output/server/chunks/build/useWorkshopApi-CaSItJVq.mjs.map +0 -1
  1522. package/.output/server/chunks/build/useWorkshopWs-YQ5URrbt.mjs +0 -1659
  1523. package/.output/server/chunks/build/useWorkshopWs-YQ5URrbt.mjs.map +0 -1
  1524. package/.output/server/chunks/build/useWorkspaceAuth-Dlvj9csD.mjs.map +0 -1
  1525. package/.output/server/chunks/build/useWorkspaceChannels-CPFepxTN.mjs +0 -92
  1526. package/.output/server/chunks/build/useWorkspaceChannels-CPFepxTN.mjs.map +0 -1
  1527. package/.output/server/chunks/build/useWorkspaceShell-BCypjjjE.mjs +0 -168
  1528. package/.output/server/chunks/build/useWorkspaceShell-BCypjjjE.mjs.map +0 -1
  1529. package/.output/server/chunks/build/users-DjiVC_tS.mjs +0 -569
  1530. package/.output/server/chunks/build/users-DjiVC_tS.mjs.map +0 -1
  1531. package/.output/server/chunks/build/workshop-1gKeDASV.mjs +0 -546
  1532. package/.output/server/chunks/build/workshop-1gKeDASV.mjs.map +0 -1
  1533. package/app/.mimosa/hook-state/sess_05189059-e42d-4188-8911-4f7baabe009b.json +0 -1
  1534. package/app/.mimosa/hook-state/sess_05189059-e42d-4188-8911-4f7baabe009b.mtg0vz68-49792-75b0709555.baseline/1459e6269990a5d229b9228c8b2f62ffaa7d350068380ae8b875fee0db45cca6.source +0 -180
  1535. package/app/.mimosa/hook-state/sess_05189059-e42d-4188-8911-4f7baabe009b.mtg0vz68-49792-75b0709555.baseline/c2991e909c70c5c12b90a407c7adcf63384c51668a2b334e6e047fa675c268fe.source +0 -305
  1536. package/app/.mimosa/hook-state/sess_05189059-e42d-4188-8911-4f7baabe009b.mtg0vz68-49792-75b0709555.baseline/e09129039d1e27e3fac24becc9bdafd2d1a7c8049bff24173df007be865f0165.source +0 -264
  1537. package/app/.mimosa/hook-status/sess_05189059-e42d-4188-8911-4f7baabe009b-28ef7c75ea.json +0 -14
  1538. package/scripts/e2e-direct-rest-simulator-paper.mjs +0 -624
  1539. package/scripts/e2e-pi-simulator-paper.mjs +0 -2316
  1540. package/scripts/e2e-registered-harness-simulator-paper.mjs +0 -1926
  1541. package/scripts/e2e-simulator-optimizer-paper.mjs +0 -264
  1542. package/scripts/fixtures/omp-paper-harness.mjs +0 -163
  1543. package/server/.mimosa/hook-state/sess_869e5bfd-07f4-4b6e-a991-6221fcf6b7d2.json +0 -1
  1544. package/server/.mimosa/hook-state/sess_869e5bfd-07f4-4b6e-a991-6221fcf6b7d2.mvhn1irp-99488-e3fdc1cbfc.baseline/942d2679b87b96c612b4f2a425c3ccc5b6f3234f0cf589a8441602f866fbe277.source +0 -41
  1545. package/server/.mimosa/hook-state/sess_869e5bfd-07f4-4b6e-a991-6221fcf6b7d2.mvhn1irp-99488-e3fdc1cbfc.baseline/dd617a82339d2c61e49e28e416aabeb2fc100fb3cb1beca18d02dfb833214af6.source +0 -51
  1546. package/server/.mimosa/hook-status/sess_869e5bfd-07f4-4b6e-a991-6221fcf6b7d2-e67b6b91bf.json +0 -14
  1547. package/server/services/workshop/.mimosa/hook-state/sess_fed429fb-c8b7-4a50-bbd6-45afc580893f.json +0 -1
  1548. package/server/services/workshop/.mimosa/hook-status/sess_fed429fb-c8b7-4a50-bbd6-45afc580893f-e6b75bbfe6.json +0 -14
  1549. package/server/services/workshop/agents/omp-agent/supervision-history.ts +0 -38
  1550. package/server/services/workshop/aml/python/__pycache__/aml_eval.cpython-312.pyc +0 -0
  1551. package/server/services/workshop/aml/python/__pycache__/amlkit.cpython-312.pyc +0 -0
  1552. package/server/services/workshop/aml/python/__pycache__/train-example.cpython-312.pyc +0 -0
  1553. package/server/services/workshop/aml/python/__pycache__/train-hybrid-example.cpython-312.pyc +0 -0
  1554. package/server/services/workshop/optimization/python/.mimosa/hook-state/session_187ec97f45d4bd02369bbe94da527cf1.json +0 -1
  1555. package/server/services/workshop/optimization/python/.mimosa/hook-state/session_187ec97f45d4bd02369bbe94da527cf1.mvjqkcs6-68688-fb7131a89c.baseline/190a6772a4e43801737b4ba6072eb9d53d3099b5d8a9e6f57bc5e8592a26a6c4.source +0 -274
  1556. package/server/services/workshop/optimization/python/.mimosa/hook-status/session_187ec97f45d4bd02369bbe94da527cf1-01ed7f04fa.json +0 -14
  1557. package/server/services/workshop/optimization/python/__pycache__/problems.cpython-312.pyc +0 -0
  1558. /package/.output/public/_nuxt/{9j2J4k4w.js → 9j2J4k4w2.js} +0 -0
  1559. /package/.output/public/_nuxt/{BY3Lbz3h2.js → BY3Lbz3h.js} +0 -0
  1560. /package/.output/public/_nuxt/{Iub61dX92.js → Iub61dX9.js} +0 -0
  1561. /package/.output/public/_nuxt/{Q-JpBT032.js → Q-JpBT03.js} +0 -0
  1562. /package/.output/public/_nuxt/{dVw8IHY62.js → dVw8IHY6.js} +0 -0
  1563. /package/.output/public/_nuxt/{k9b520K-.js → k9b520K-2.js} +0 -0
@@ -1,1155 +1,1155 @@
1
- /**
2
- * MES 取数控制器(Agent 工具后端)—— mes-rest 点位目录 + 历史取数编排。
3
- *
4
- * 护栏全部**代码级**(不是提示词):绑线授权过滤、时间窗 ≤7 天、maxRows ≤5000、
5
- * 每 agent 每 60s ≤6 次 fetch;数据原文不进 prompt —— 文本只给 stats + ≤3 行采样,
6
- * 行级原文只落 CSV 数据集(mes-datasets)。
7
- *
8
- * 取数三模式:
9
- * 无 from/to → 当前值快照(driver.read 内联直读);
10
- * from/to 且 maxRows ≤ 2000 → 同步 fetchHistory 内联返回(缓冲截断保护);
11
- * 其余(maxRows > 2000) → createFetchJob 异步落 CSV,回 job_id/dataset_id。
12
- */
13
- import { randomUUID } from 'node:crypto'
14
- import { closeSync, mkdirSync, openSync, readFileSync, writeFileSync, writeSync } from 'node:fs'
15
- import { join, resolve, sep } from 'node:path'
16
- import { ensureDataDir } from '@/shared/config/home.mjs'
17
- import { getActiveLineRun } from '../dcw/line-run'
18
- import { resolveDcwDriver } from '../dcw/drivers'
19
- import type { DcwFieldDef, DcwHistoryFormat as MesHistoryFormat } from '../dcw/drivers/shared'
20
- import { historyFormatOf, normalizeMesDictionary } from '../dcw/drivers/mes-rest'
21
- import type { MesHistoryDriver, MesDatasetStatsView, MesDatasetStore } from './mes-datasets'
22
- import { getMesDatasets } from './mes-datasets'
23
- import { mesDataHookCode, mesRequestHookCode, runMesDataHook, runMesRequestHook, saveMesImageArtifact } from './mes-hook'
24
- import type { MesHookArtifact, MesHookData } from './mes-hook'
25
-
26
- /** mes-rest 驱动 kind(并行工作流收编进 DcwDriverKind 联合;此处按字符串经注册表解析,不 import 驱动实现) */
27
- export const MES_REST_DRIVER_KIND = 'mes-rest'
28
-
29
- // ============================================================
30
- // 护栏常量(单一事实源;测试直接引用)
31
- // ============================================================
32
-
33
- /** 历史窗口上限:7 天 */
34
- export const MES_WINDOW_MAX_MS = 7 * 24 * 3_600_000
35
- /** 单次取数行数硬上限 */
36
- export const MES_MAX_ROWS_CAP = 5000
37
- /** 同步内联返回的行数上限(超过走异步数据集) */
38
- export const MES_SYNC_INLINE_MAX_ROWS = 2000
39
- /** 频次限流:窗口与次数(每 agent) */
40
- export const MES_RATE_WINDOW_MS = 60_000
41
- export const MES_RATE_MAX_CALLS = 6
42
- /** max_rows 缺省值 */
43
- export const MES_DEFAULT_MAX_ROWS = 500
44
- /** 离线导出单次行数上限(CSV/JSONL 流式写盘;比在线取数宽,仍防磁盘失控) */
45
- export const MES_EXPORT_MAX_ROWS = 200_000
46
- /** 离线导出图像帧上限(单次) */
47
- export const MES_EXPORT_MAX_FRAMES = 500
48
-
49
- // ============================================================
50
- // 频次限流(进程内内存计数;Map<agentId, 时间戳[]>)
51
- // ============================================================
52
-
53
- const fetchCallStamps = new Map<string, number[]>()
54
-
55
- /** 记一次 fetch 并判定是否放行(滑动 60s 窗 ≤6 次;超限不记账) */
56
- export function mesFetchRateCheck(agentId: string, nowMs = Date.now()): boolean {
57
- const stamps = (fetchCallStamps.get(agentId) ?? []).filter(t => nowMs - t < MES_RATE_WINDOW_MS)
58
- if (stamps.length >= MES_RATE_MAX_CALLS) {
59
- fetchCallStamps.set(agentId, stamps)
60
- return false
61
- }
62
- stamps.push(nowMs)
63
- fetchCallStamps.set(agentId, stamps)
64
- return true
65
- }
66
-
67
- /** 清空限流账(测试用) */
68
- export function mesFetchRateReset(): void {
69
- fetchCallStamps.clear()
70
- }
71
-
72
- // ============================================================
73
- // 节点/依赖(结构化注入;缺省接真实服务,测试注入假件不联网)
74
- // ============================================================
75
-
76
- export interface MesNodeLike {
77
- id: string
78
- name: string
79
- driver: string
80
- lineId: string
81
- unit: string
82
- min: number
83
- max: number
84
- enabled: boolean
85
- driverConfig: Record<string, string | number | boolean>
86
- }
87
-
88
- export interface MesControllerDeps {
89
- /** 数据集服务(异步取数账本;缺省 getMesDatasets()) */
90
- store: Pick<MesDatasetStore, 'createFetchJob'>
91
- /** 全量 dcw 节点(缺省 dcw-node.repo) */
92
- nodes: () => MesNodeLike[] | Promise<MesNodeLike[]>
93
- /** 调用者可见节点(绑线过滤:dcw 绑定集;缺省 node-bindings.repo) */
94
- boundNodeIds: (agentId: string) => Set<string> | Promise<Set<string>>
95
- /** 驱动解析(缺省 dcw 注册表) */
96
- resolveDriver: (kind: string) => MesHistoryDriver
97
- nowMs: () => number
98
- }
99
-
100
- /** 缺省依赖:重模块(dcw 仓储/绑线仓储)经动态 import 引入,保持本模块可被 tsx 测试轻量直跑 */
101
- function defaultDeps(): MesControllerDeps {
102
- return {
103
- store: new Proxy({} as Pick<MesDatasetStore, 'createFetchJob'>, {
104
- get: (_t, prop) => {
105
- const store = getMesDatasets() as unknown as Record<string | symbol, unknown>
106
- const v = store[prop]
107
- return typeof v === 'function' ? (v as (...a: unknown[]) => unknown).bind(store) : v
108
- },
109
- }),
110
- nodes: async () => {
111
- const { getDcwNodeRepo } = await import('../dcw/dcw-node.repo')
112
- return getDcwNodeRepo().all()
113
- },
114
- boundNodeIds: async (agentId) => {
115
- // 权限模型 v2:dcw 绑定(存量)∪ 绑定配方内的参数节点(kind='recipe' 的配方可见节点)
116
- const { getAgentNodeBindingRepo } = await import('../agents/node-bindings.repo')
117
- const { getDcwController } = await import('../dcw/dcw-controller')
118
- const bindings = getAgentNodeBindingRepo().byAgent(agentId)
119
- const ids = new Set(bindings.filter(b => b.kind === 'dcw').map(b => b.nodeId))
120
- const recipeIds = new Set(bindings.filter(b => b.kind === 'recipe').map(b => b.nodeId))
121
- if (recipeIds.size > 0) {
122
- for (const r of getDcwController().listRecipes()) {
123
- if (!recipeIds.has(r.id)) continue
124
- for (const p of r.params) ids.add(p.nodeId)
125
- }
126
- }
127
- return ids
128
- },
129
- resolveDriver: kind => resolveDcwDriver(kind as Parameters<typeof resolveDcwDriver>[0]),
130
- nowMs: () => Date.now(),
131
- }
132
- }
133
-
134
- export type MesCatalogEntry = {
135
- id: string
136
- name: string
137
- lineId: string
138
- unit: string
139
- min: number
140
- max: number
141
- desc: string
142
- readable: boolean
143
- writable: boolean
144
- historyable: boolean
145
- /** 历史格式(scalar/vector/image/table/event;historyMap 未配置时 scalar) */
146
- format: MesHistoryFormat
147
- /** 已配置数据下沉 hook(dataHook) */
148
- hooked: boolean
149
- enabled: boolean
150
- /** 字段级数据字典(响应缓存 ∪ 节点静态配置;无则空数组) */
151
- fields: DcwFieldDef[]
152
- }
153
-
154
- // ============================================================
155
- // 字段字典缓存(响应返回 → 后续 catalog/导出复用)
156
- // ============================================================
157
-
158
- const dictionaryCache = new Map<string, DcwFieldDef[]>()
159
- const DICTIONARY_CACHE_MAX = 200
160
-
161
- function cacheDictionary(nodeId: string, fields: DcwFieldDef[] | undefined): void {
162
- if (!fields || fields.length === 0) return
163
- dictionaryCache.delete(nodeId)
164
- dictionaryCache.set(nodeId, fields)
165
- while (dictionaryCache.size > DICTIONARY_CACHE_MAX) {
166
- const oldest = dictionaryCache.keys().next().value
167
- if (oldest === undefined) break
168
- dictionaryCache.delete(oldest)
169
- }
170
- }
171
-
172
- /** 节点静态字典(driverConfig.dictionary / fieldDictionary 的 JSON 文本) */
173
- function configuredDictionary(cfg: Record<string, unknown>): DcwFieldDef[] {
174
- for (const key of ['dictionary', 'fieldDictionary', 'fields']) {
175
- const raw = cfg[key]
176
- if (raw === undefined || raw === null || String(raw).trim() === '') continue
177
- try {
178
- const parsed = typeof raw === 'string' ? JSON.parse(raw) as unknown : raw
179
- const fields = normalizeMesDictionary(parsed)
180
- if (fields.length > 0) return fields
181
- }
182
- catch { /* 坏配置不击穿目录;由驱动测试报错 */ }
183
- }
184
- return []
185
- }
186
-
187
- /** 节点有效字典:响应缓存优先(实时真相),否则静态配置 */
188
- export function mesDictionaryOfNode(nodeId: string, cfg: Record<string, unknown>): DcwFieldDef[] {
189
- return dictionaryCache.get(nodeId) ?? configuredDictionary(cfg)
190
- }
191
-
192
- /** 字典一行摘要(字段名(标签,单位;量程;点数)) */
193
- export function fieldSummaryOf(fields: DcwFieldDef[]): string {
194
- return fields.slice(0, 8).map((f) => {
195
- const bits = [f.label, f.unit, f.min != null || f.max != null ? `${f.min ?? '-∞'}~${f.max ?? '+∞'}` : '', f.points?.length ? `${f.points.length} 点` : '']
196
- .filter(Boolean)
197
- return bits.length > 0 ? `${f.field}(${bits.join(',')})` : f.field
198
- }).join('; ')
199
- }
200
-
201
- /** 字段字典 → 多行可读文本(Agent 直接引用;含单位/量程/物理意义/逐点语义) */
202
- export function formatDictionary(fields: DcwFieldDef[], indent = ' '): string {
203
- if (fields.length === 0) return ''
204
- const pointLine = (f: DcwFieldDef): string => {
205
- const pts = f.points ?? []
206
- if (pts.length === 0) return ''
207
- const head = pts.slice(0, 6).map(p => `${p.index ?? '?'}=${p.label ?? p.field}${p.unit ? `(${p.unit})` : ''}`).join(', ')
208
- return `; 点位 ${pts.length} 个: ${head}${pts.length > 6 ? ', …' : ''}`
209
- }
210
- const lines = fields.slice(0, 24).map((f) => {
211
- const meta = [
212
- f.label && f.label !== f.field ? `标签 ${f.label}` : '',
213
- f.unit ? `单位 ${f.unit}` : '',
214
- f.min != null || f.max != null ? `量程 ${f.min ?? '-∞'}~${f.max ?? '+∞'}` : '',
215
- f.kind ? `形态 ${f.kind}` : '',
216
- ].filter(Boolean).join(' | ')
217
- const desc = f.description ? ` — ${f.description.slice(0, 160)}` : ''
218
- return `${indent}- ${f.field}${meta ? ` [${meta}]` : ''}${desc}${pointLine(f)}`
219
- })
220
- return `字段字典(${fields.length} 个字段,来自 MES 响应/节点配置):\n${lines.join('\n')}${fields.length > 24 ? `\n${indent}(仅显示前 24 个字段)` : ''}`
221
- }
222
-
223
- /** 目录条目合成:desc/readMap/writeMap/historyMap 均来自 driverConfig(数据驱动,零硬编码) */
224
- export function mesCatalogEntryOf(n: MesNodeLike): MesCatalogEntry {
225
- const cfg = n.driverConfig ?? {}
226
- return {
227
- id: n.id,
228
- name: n.name,
229
- lineId: n.lineId ?? '',
230
- unit: n.unit ?? '',
231
- min: n.min,
232
- max: n.max,
233
- desc: String(cfg.desc ?? ''),
234
- readable: Boolean(cfg.readMap),
235
- writable: Boolean(cfg.writeMap),
236
- historyable: Boolean(cfg.historyMap),
237
- format: historyFormatOf(cfg as Record<string, unknown>),
238
- hooked: Boolean(cfg.dataHook),
239
- enabled: Boolean(n.enabled),
240
- fields: mesDictionaryOfNode(n.id, cfg as Record<string, unknown>),
241
- }
242
- }
243
-
244
- // ============================================================
245
- // 控制器
246
- // ============================================================
247
-
248
- export type MesToolResult = { text: string, isError?: boolean }
249
-
250
- export type MesFetchOutcome = MesToolResult & {
251
- mode?: 'snapshot' | 'inline' | 'async'
252
- data?: {
253
- job_ids?: string[]
254
- dataset_ids?: string[]
255
- stats?: Array<{ nodeId: string, stats: MesDatasetStatsView, truncated: boolean }>
256
- }
257
- }
258
-
259
- export interface MesFetchArgs {
260
- ids?: unknown
261
- from?: string
262
- to?: string
263
- max_rows?: number | string
264
- /** 透传给 requestHook/dataHook 的参数对象(Agent 只传 param,其余交给配置) */
265
- param?: unknown
266
- /** 内联/快照回包是否附带采样行的实际数组/数值内容(默认 false=只给统计与均值) */
267
- include_data?: boolean | string
268
- }
269
-
270
- export interface MesCatalogArgs {
271
- q?: string
272
- line_id?: string
273
- /** 按产品 id 收窄到该产品产线(可选;与 line_id 冲突时拒绝) */
274
- product_id?: string
275
- /** 按配方 id 收窄到该配方产线(可选;与 line_id 冲突时拒绝) */
276
- recipe_id?: string
277
- limit?: number | string
278
- /** 调用者可读产线集(绑线授权口径);提供时严格过滤(孤儿/越线点位不可见,空集=空目录 fail-closed) */
279
- scope_line_ids?: string[]
280
- }
281
-
282
- export interface MesExportArgs {
283
- ids?: unknown
284
- from?: string
285
- to?: string
286
- max_rows?: number | string
287
- /** 透传给 requestHook 的调用参数 */
288
- param?: unknown
289
- /** 导出子目录(相对 <数据根>/mes-exports;绝对路径须落在 AW_MES_EXPORT_ROOT 内) */
290
- folder?: string
291
- title?: string
292
- note?: string
293
- /** 标量节点是否生成按时间对齐的 merged.csv(缺省 true) */
294
- merge?: boolean | string
295
- }
296
-
297
- export function createMesController(deps: Partial<MesControllerDeps> = {}) {
298
- const d: MesControllerDeps = { ...defaultDeps(), ...deps }
299
-
300
- // ---------- 目录 ----------
301
-
302
- /** mes-rest 点位目录(q 对 name/desc 子串过滤;line_id 精确过滤;limit 缺省 20;
303
- * scope_line_ids 提供时按调用者可读产线严格过滤——跨产线点位与孤儿(未分配)点位不可见) */
304
- async function catalog(args: MesCatalogArgs = {}): Promise<MesToolResult & { entries: MesCatalogEntry[], total: number }> {
305
- const all = await d.nodes()
306
- let mes = all.filter(n => n.driver === MES_REST_DRIVER_KIND).map(mesCatalogEntryOf)
307
- if (Array.isArray(args.scope_line_ids)) {
308
- const scope = new Set(args.scope_line_ids)
309
- mes = mes.filter(e => e.lineId !== '' && scope.has(e.lineId))
310
- }
311
- const total = mes.length
312
- let lineId = String(args.line_id ?? '').trim()
313
- const productId = String(args.product_id ?? '').trim()
314
- if (productId) {
315
- const { getDcwProductRepo } = await import('../dcw/dcw-product.repo')
316
- const product = getDcwProductRepo().byId(productId)
317
- if (!product) return { text: `产品 ${productId} 不存在。`, isError: true, entries: [], total: 0 }
318
- if (lineId && product.lineId !== lineId) return { text: `产品 ${productId} 归属产线 ${product.lineId},与 line_id=${lineId} 不一致。`, isError: true, entries: [], total: 0 }
319
- lineId = product.lineId
320
- }
321
- const recipeId = String(args.recipe_id ?? '').trim()
322
- if (recipeId) {
323
- const { getDcwController } = await import('../dcw/dcw-controller')
324
- const recipe = getDcwController().listRecipes().find(r => r.id === recipeId)
325
- if (!recipe) return { text: `配方 ${recipeId} 不存在。`, isError: true, entries: [], total: 0 }
326
- if (lineId && recipe.lineId !== lineId) return { text: `配方 ${recipeId} 归属产线 ${recipe.lineId},与 line_id=${lineId} 不一致。`, isError: true, entries: [], total: 0 }
327
- lineId = recipe.lineId
328
- }
329
- if (lineId) mes = mes.filter(e => e.lineId === lineId)
330
- const q = String(args.q ?? '').trim().toLowerCase()
331
- if (q) mes = mes.filter(e => e.name.toLowerCase().includes(q) || e.desc.toLowerCase().includes(q))
332
- const limit = Math.min(Math.max(Math.round(Number(args.limit)) || 20, 1), 100)
333
- const shown = mes.slice(0, limit)
334
-
335
- const cap = (e: MesCatalogEntry): string => {
336
- const hist = e.historyable ? (e.format !== 'scalar' ? `史·${e.format}` : '史') : null
337
- const ab = [e.readable ? '读' : null, e.writable ? '写' : null, hist, e.hooked ? '钩子' : null].filter(Boolean)
338
- return ab.length > 0 ? ab.join('/') : '无能力位'
339
- }
340
- const body = shown.map((e) => {
341
- const fields = e.fields.length > 0 ? ` | 字段: ${fieldSummaryOf(e.fields)}` : ''
342
- return `- ${e.name}(id=${e.id}) | 产线 ${e.lineId || '未分配'} | 单位 ${e.unit || '-'} | 量程 ${e.min}~${e.max} | 能力 ${cap(e)}${e.enabled ? '' : ' [停用]'}${e.desc ? ` | ${e.desc.slice(0, 80)}` : ''}${fields}`
343
- })
344
- const more = mes.length - shown.length
345
- const text = `MES REST 点位目录(共 ${total} 个${lineId ? `,产线 ${lineId}` : ''}${q ? `,关键字「${args.q}」` : ''};显示 ${shown.length} 条):\n${body.join('\n') || '(无匹配点位)'}${more > 0 ? `\n(另有 ${more} 条未显示,可收紧 q/line_id 或调大 limit≤100)` : ''}\n\n说明:能力 读=可读当前值,写=可写设定值,史=可取历史(史·vector=每时间点检测向量,史·image=图像帧,史·table/event=记录流),钩子=已配 dataHook(取数后自动做下沉处理并回传摘要与产物)。字段级语义来自 MES 响应 dictionaryPath 或节点 driverConfig.dictionary;首次 mes_fetch 后缓存,后续目录可直接看到字段标签/单位/点位。历史取数用 mes_fetch(ids=[点位id], from, to, max_rows, param?);需要落盘到目录做离线分析用 mes_export。`
346
- return { text, entries: shown, total }
347
- }
348
-
349
- // ---------- 取数 ----------
350
-
351
- /** 归一 ids + 授权过滤(绑线路径:仅调用者 dcw 绑定的 mes-rest 节点) */
352
- async function resolveVisibleIds(agentId: string, rawIds: unknown): Promise<{ ok: true, nodes: MesNodeLike[] } | { ok: false, text: string, isError: true }> {
353
- const ids = Array.isArray(rawIds) ? [...new Set(rawIds.map(x => String(x ?? '').trim()).filter(Boolean))] : []
354
- if (ids.length === 0) return { ok: false, text: 'ids 必填:目标 mes-rest 点位 id 数组(catalog 输出的 id;至少 1 个)。', isError: true }
355
- const all = await d.nodes()
356
- const bound = await d.boundNodeIds(agentId)
357
- const mesById = new Map(all.filter(n => n.driver === MES_REST_DRIVER_KIND).map(n => [n.id, n]))
358
- const picked: MesNodeLike[] = []
359
- const missing: string[] = []
360
- const notAllowed: string[] = []
361
- for (const id of ids) {
362
- const n = mesById.get(id)
363
- if (!n) {
364
- missing.push(id)
365
- continue
366
- }
367
- if (!bound.has(id)) {
368
- notAllowed.push(id)
369
- continue
370
- }
371
- picked.push(n)
372
- }
373
- if (missing.length > 0 || notAllowed.length > 0) {
374
- const allowed = [...bound]
375
- .map(id => mesById.get(id))
376
- .filter((n): n is MesNodeLike => !!n && n.driver === MES_REST_DRIVER_KIND)
377
- const parts: string[] = []
378
- if (missing.length > 0) parts.push(`不存在或不是 mes-rest 点位:${missing.join(', ')}`)
379
- if (notAllowed.length > 0) parts.push(`无权访问(须为你绑定的数控节点):${notAllowed.join(', ')}`)
380
- return {
381
- ok: false,
382
- text: `取数被拒:${parts.join(';')}。你有权取数的 mes-rest 点位:${allowed.map(n => `${n.name}(${n.id})`).join(', ') || '(无)'}。`,
383
- isError: true,
384
- }
385
- }
386
- return { ok: true, nodes: picked }
387
- }
388
-
389
- /** 时间窗/行数护栏归一(代码级;返回错误文本或归一值) */
390
- function normalizeWindow(args: MesFetchArgs): { ok: true, from?: string, to?: string, maxRows: number } | { ok: false, text: string, isError?: true } {
391
- const from = String(args.from ?? '').trim()
392
- const to = String(args.to ?? '').trim()
393
- if ((from && !to) || (!from && to)) {
394
- return { ok: false, text: 'from/to 必须成对提供(历史取数),或都不传(当前值快照模式)。' }
395
- }
396
- if (from && to) {
397
- const fromMs = Date.parse(from)
398
- const toMs = Date.parse(to)
399
- if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) return { ok: false, text: 'from/to 必须是合法 ISO 时间戳。' }
400
- if (fromMs >= toMs) return { ok: false, text: `时间窗无效:from(${from}) 必须早于 to(${to})。` }
401
- if (toMs - fromMs > MES_WINDOW_MAX_MS) {
402
- return { ok: false, text: `时间窗被拒:窗口 ${(toMs - fromMs) / 3_600_000 / 24} 天超过上限 7 天。请拆成 ≤7 天的分段分批取数。`, isError: true }
403
- }
404
- }
405
- const maxRows = args.max_rows == null || args.max_rows === '' ? MES_DEFAULT_MAX_ROWS : Math.round(Number(args.max_rows))
406
- if (!Number.isFinite(maxRows) || maxRows < 1) return { ok: false, text: 'max_rows 必须为 ≥1 的整数。' }
407
- if (maxRows > MES_MAX_ROWS_CAP) {
408
- return { ok: false, text: `max_rows=${maxRows} 被拒:单次取数上限 ${MES_MAX_ROWS_CAP} 行。请缩小时间窗或分批取数。`, isError: true }
409
- }
410
- return { ok: true, from: from || undefined, to: to || undefined, maxRows }
411
- }
412
-
413
- /** 统计摘要(数值列;均值/采样标准差) */
414
- function statsOf(values: number[], firstTs: string | null, lastTs: string | null): MesDatasetStatsView {
415
- const n = values.length
416
- if (n === 0) return { count: 0, min: null, max: null, mean: null, stddev: null, firstTs: null, lastTs: null }
417
- const min = Math.min(...values)
418
- const max = Math.max(...values)
419
- const mean = values.reduce((a, b) => a + b, 0) / n
420
- const stddev = n > 1 ? Math.sqrt(values.reduce((a, b) => a + (b - mean) ** 2, 0) / (n - 1)) : 0
421
- return { count: n, min, max, mean, stddev, firstTs, lastTs }
422
- }
423
-
424
- const fmtN = (v: number | null | undefined, digits = 3): string =>
425
- v == null || !Number.isFinite(v) ? '-' : String(Number(v.toFixed(digits)))
426
- const shortTs = (iso: string | null): string => iso && iso.length >= 19 ? iso.slice(5, 19).replace('T', ' ') : (iso ?? '-')
427
- const clip = (v: unknown, max: number): string => {
428
- const s = typeof v === 'string' ? v : JSON.stringify(v) ?? String(v)
429
- return s.length > max ? `${s.slice(0, max)}…` : s
430
- }
431
-
432
- // -------- 格式感知取数(行形态全谱;内存硬顶防大payload 拖垮进程) --------
433
-
434
- /** 泛化历史行缓冲的硬顶 */
435
- const VECTOR_ELEMENT_CAP = 2_000_000
436
- const IMAGE_BASE64_CAP = 16_000_000
437
- const RECORD_JSON_CAP = 8_000_000
438
- /** image 格式自动落盘帧数上限(其余帧不落盘,回包注明) */
439
- const IMAGE_AUTOSAVE_MAX = 20
440
-
441
- interface GenRow { ts: string, value?: number, values?: number[], data?: string, mime?: string, record?: unknown }
442
-
443
- interface GenStats extends MesDatasetStatsView {
444
- /** vector:维度(首行长度)与维度不齐行数 */
445
- dim?: number
446
- dimMismatch?: number
447
- /** vector:全体元素均值(比行均值更细) */
448
- elementMean?: number
449
- }
450
-
451
- /** requestHook 覆盖合并:克隆 driverConfig,把 {path,query,headers} 合入 historyMap JSON */
452
- async function configWithRequestHook(node: MesNodeLike, param: unknown): Promise<Record<string, unknown>> {
453
- const cfg = { ...(node.driverConfig as Record<string, unknown>) }
454
- const hookCode = mesRequestHookCode(cfg as Record<string, unknown>)
455
- if (!hookCode) return cfg
456
- const overrides = await runMesRequestHook(hookCode, param, { nodeId: node.id })
457
- if (overrides.path === undefined && overrides.query === undefined && overrides.headers === undefined) return cfg
458
- try {
459
- const map = JSON.parse(String(cfg.historyMap ?? '{}')) as Record<string, unknown>
460
- if (overrides.path !== undefined) map.path = overrides.path
461
- const baseQuery = (map.query !== null && typeof map.query === 'object' && !Array.isArray(map.query) ? map.query : {}) as Record<string, unknown>
462
- map.query = { ...baseQuery, ...(overrides.query ?? {}) }
463
- const baseHeaders = (map.headers !== null && typeof map.headers === 'object' && !Array.isArray(map.headers) ? map.headers : {}) as Record<string, unknown>
464
- if (overrides.headers !== undefined) map.headers = { ...baseHeaders, ...overrides.headers }
465
- cfg.historyMap = JSON.stringify(map)
466
- }
467
- catch (err) {
468
- throw new AppError(422, 'MES_HOOK_FAILED', `requestHook 覆盖合并失败(historyMap 非法 JSON):${err instanceof Error ? err.message : String(err)}`)
469
- }
470
- return cfg
471
- }
472
-
473
- /** 向量行统计摘要(行均值序列 stats + 维度 + 全体元素均值) */
474
- function vectorStats(rows: GenRow[]): GenStats {
475
- const rowMeans = rows.map((r) => {
476
- const vs = r.values ?? []
477
- return vs.length > 0 ? vs.reduce((a, b) => a + b, 0) / vs.length : NaN
478
- }).filter(v => Number.isFinite(v))
479
- const all: number[] = []
480
- for (const r of rows) if (Array.isArray(r.values)) all.push(...r.values)
481
- const base = statsOf(rowMeans, rows[0]?.ts ?? null, rows[rows.length - 1]?.ts ?? null) as GenStats
482
- base.dim = Array.isArray(rows[0]?.values) ? rows[0]!.values!.length : undefined
483
- base.dimMismatch = base.dim === undefined ? undefined : rows.filter(r => Array.isArray(r.values) && r.values!.length !== base.dim).length
484
- base.elementMean = all.length > 0 ? all.reduce((a, b) => a + b, 0) / all.length : undefined
485
- return base
486
- }
487
-
488
- /** 同步取单节点历史(格式感知:统计+采样+图像落盘+dataHook 下沉处理;原文不回传) */
489
- async function inlineFetchNode(node: MesNodeLike, from: string, to: string, maxRows: number, param: unknown, includeData = false): Promise<{
490
- text: string
491
- stats: MesDatasetStatsView
492
- truncated: boolean
493
- sample: string[]
494
- hookText?: string
495
- artifacts: MesHookArtifact[]
496
- }> {
497
- const cfg = node.driverConfig as Record<string, unknown>
498
- const format = historyFormatOf(cfg)
499
- const driver = d.resolveDriver(node.driver)
500
- if (typeof driver.fetchHistory !== 'function') {
501
- return { text: `驱动 ${node.driver} 未提供历史原语(fetchHistory)`, stats: statsOf([], null, null), truncated: true, sample: [], artifacts: [] }
502
- }
503
- const effCfg = await configWithRequestHook(node, param)
504
- const buf: GenRow[] = []
505
- let truncated = false
506
- let vecElems = 0
507
- let imgChars = 0
508
- let recChars = 0
509
- let memoryHit = ''
510
- let dictionary: DcwFieldDef[]
511
- const result = await driver.fetchHistory({
512
- driverConfig: effCfg,
513
- fromIso: from,
514
- toIso: to,
515
- maxRows,
516
- onRows: (batch) => {
517
- for (const r of batch ?? []) {
518
- if (buf.length >= maxRows) {
519
- truncated = true
520
- break
521
- }
522
- const row: GenRow = { ts: String(r?.ts ?? '') }
523
- if (typeof r?.value === 'number') row.value = r.value
524
- if (Array.isArray(r?.values)) {
525
- vecElems += r.values.length
526
- if (vecElems > VECTOR_ELEMENT_CAP) {
527
- memoryHit = `向量元素总量超过 ${VECTOR_ELEMENT_CAP} 上限`
528
- truncated = true
529
- break
530
- }
531
- row.values = r.values as number[]
532
- }
533
- if (typeof r?.data === 'string') {
534
- imgChars += r.data.length
535
- if (imgChars > IMAGE_BASE64_CAP) {
536
- memoryHit = `图像载荷总量超过 ${Math.round(IMAGE_BASE64_CAP / 1024 / 1024)}MB 上限`
537
- truncated = true
538
- break
539
- }
540
- row.data = r.data
541
- row.mime = typeof r?.mime === 'string' ? r.mime : 'image/png'
542
- }
543
- if (r?.record !== undefined && r.record !== null) {
544
- let json: string
545
- try {
546
- json = JSON.stringify(r.record)
547
- }
548
- catch {
549
- continue
550
- }
551
- recChars += json.length
552
- if (recChars > RECORD_JSON_CAP) {
553
- memoryHit = `记录载荷总量超过 ${Math.round(RECORD_JSON_CAP / 1024 / 1024)}MB 上限`
554
- truncated = true
555
- break
556
- }
557
- row.record = r.record
558
- }
559
- buf.push(row)
560
- }
561
- },
562
- })
563
- if (result?.dictionary && result.dictionary.length > 0) {
564
- dictionary = result.dictionary
565
- cacheDictionary(node.id, dictionary)
566
- }
567
- else {
568
- dictionary = mesDictionaryOfNode(node.id, cfg)
569
- }
570
- if (result && result.complete === false) truncated = true
571
- if (!truncated && memoryHit) truncated = true
572
-
573
- // 统计与采样(按格式)
574
- let stats: GenStats
575
- let autosaved: MesHookArtifact[] = []
576
- const sample: string[] = []
577
- let tableFieldStats = ''
578
- if (format === 'vector') {
579
- stats = vectorStats(buf)
580
- // 空窗口不得生成采样下标(否则 buf[0] undefined → 取数崩溃)
581
- const idx = buf.length > 0 ? [...new Set([0, Math.floor((buf.length - 1) / 2), buf.length - 1])].slice(0, 3) : []
582
- const vecField = dictionary.find(f => f.kind === 'vector' || (f.points?.length ?? 0) > 0)
583
- const pointLabel = (i: number): string => {
584
- const p = vecField?.points?.[i]
585
- return p?.label ?? p?.field ?? `v${i}`
586
- }
587
- for (const i of idx) {
588
- const r = buf[i]!
589
- const vs = r.values ?? []
590
- const m = vs.length > 0 ? vs.reduce((a, b) => a + b, 0) / vs.length : NaN
591
- const valuesTxt = includeData && vs.length > 0
592
- ? `,values=[${vs.slice(0, 64).map((v, j) => `${pointLabel(j)}=${Number(v.toFixed(4))}`).join(',')}${vs.length > 64 ? ',…' : ''}]`
593
- : ''
594
- sample.push(`${shortTs(r.ts)},dim=${vs.length},mean=${fmtN(m)},min=${fmtN(vs.length ? Math.min(...vs) : NaN)},max=${fmtN(vs.length ? Math.max(...vs) : NaN)}${valuesTxt}`)
595
- }
596
- }
597
- else if (format === 'image') {
598
- stats = { count: buf.length, min: null, max: null, mean: null, stddev: null, firstTs: buf[0]?.ts ?? null, lastTs: buf[buf.length - 1]?.ts ?? null }
599
- // 图像 base64 永不进 prompt:自动落盘(≤20 帧),采样给文件名
600
- const saved: MesHookArtifact[] = []
601
- for (const [i, r] of buf.entries()) {
602
- if (typeof r.data !== 'string') continue
603
- if (saved.length >= IMAGE_AUTOSAVE_MAX) break
604
- const a = saveMesImageArtifact(node.id, `frame-${String(i).padStart(4, '0')}`, r.data, r.mime ?? 'image/png')
605
- if (a) saved.push(a)
606
- }
607
- const idx = buf.length > 0 ? [...new Set([0, Math.floor((buf.length - 1) / 2), buf.length - 1])].slice(0, 3) : []
608
- for (const i of idx) {
609
- const r = buf[i]!
610
- const kb = r.data ? Math.round(r.data.length * 3 / 4 / 1024) : 0
611
- const f = saved.find(x => x.name.includes(`frame-${String(i).padStart(4, '0')}`))
612
- sample.push(`${shortTs(r.ts)},${r.mime ?? 'image/png'},~${kb}KB${f ? ` → ${f.name}` : ''}`)
613
- }
614
- autosaved = saved
615
- }
616
- else if (format === 'table' || format === 'event') {
617
- stats = { count: buf.length, min: null, max: null, mean: null, stddev: null, firstTs: buf[0]?.ts ?? null, lastTs: buf[buf.length - 1]?.ts ?? null }
618
- const idx = buf.length > 0 ? [...new Set([0, Math.floor((buf.length - 1) / 2), buf.length - 1])].slice(0, 3) : []
619
- for (const i of idx) {
620
- const r = buf[i]!
621
- let body: string
622
- try {
623
- body = JSON.stringify(r.record)
624
- }
625
- catch {
626
- body = '(不可序列化)'
627
- }
628
- sample.push(`${shortTs(r.ts)},${clip(body ?? '', 120)}`)
629
- }
630
- // map/多参数行:逐数值字段统计(最多 12 个字段),让 Agent 不必只看 3 行采样
631
- const cols = new Map<string, number[]>()
632
- for (const r of buf) {
633
- if (r.record === null || typeof r.record !== 'object' || Array.isArray(r.record)) continue
634
- for (const [k, v] of Object.entries(r.record as Record<string, unknown>)) {
635
- if (v === null || v === '' || typeof v === 'boolean') continue
636
- const n = Number(v)
637
- if (!Number.isFinite(n)) continue
638
- const arr = cols.get(k) ?? []
639
- arr.push(n)
640
- cols.set(k, arr)
641
- }
642
- }
643
- const fieldLines = [...cols.entries()].slice(0, 12).map(([k, vs]) => {
644
- const mean = vs.reduce((a, b) => a + b, 0) / vs.length
645
- const def = dictionary.find(f => f.field === k)
646
- const label = def?.label ? `${def.label}(${k})` : k
647
- const unit = def?.unit ? ` ${def.unit}` : ''
648
- return `${label}: n=${vs.length} min=${fmtN(Math.min(...vs))} max=${fmtN(Math.max(...vs))} mean=${fmtN(mean)}${unit}`
649
- })
650
- if (fieldLines.length > 0) {
651
- tableFieldStats = ` 数值字段统计(${cols.size} 个字段${cols.size > 12 ? ',显示前12' : ''}): ${fieldLines.join(' | ')}`
652
- }
653
- }
654
- else {
655
- const values = buf.map(r => r.value).filter((v): v is number => Number.isFinite(v))
656
- stats = statsOf(values, buf[0]?.ts ?? null, buf[buf.length - 1]?.ts ?? null)
657
- const idx = buf.length > 0 ? [...new Set([0, Math.floor((buf.length - 1) / 2), buf.length - 1])].slice(0, 3) : []
658
- for (const i of idx) sample.push(`${shortTs(buf[i]!.ts)},${fmtN(buf[i]!.value ?? NaN)}${includeData ? ` (value=${buf[i]!.value ?? '-'})` : ''}`)
659
- }
660
-
661
- const fmtLabel = format === 'scalar' ? `标量` : format === 'vector' ? `向量(dim=${stats.dim ?? '?'})` : format === 'image' ? `图像(${(buf[0]?.mime as string) ?? 'image/png'})` : format === 'table' ? `表格记录` : `事件记录`
662
- const statLine = format === 'scalar'
663
- ? ` 统计:min ${fmtN(stats.min)} / max ${fmtN(stats.max)} / mean ${fmtN(stats.mean)} / stddev ${fmtN(stats.stddev)} ${node.unit}`
664
- : format === 'vector'
665
- ? ` 统计(按行均值):min ${fmtN(stats.min)} / max ${fmtN(stats.max)} / mean ${fmtN(stats.mean)} / stddev ${fmtN(stats.stddev)} ${node.unit};全体元素均值 ${fmtN(stats.elementMean ?? NaN)}${stats.dimMismatch ? `;维度漂移 ${stats.dimMismatch} 行` : ''}`
666
- : ` 统计:${stats.count} 条记录(非数值格式不做均值)`
667
- const dictText = formatDictionary(dictionary)
668
- const text = [
669
- `■ ${node.name}(id=${node.id})[格式 ${fmtLabel};节点单位 ${node.unit || '-'};量程 ${node.min}~${node.max}]`,
670
- ` 行数 ${stats.count}${truncated ? `(截断:${memoryHit || '达到 maxRows 上限'})` : '(完整)'} | 首 ${shortTs(stats.firstTs)} ~ 末 ${shortTs(stats.lastTs)}`,
671
- statLine,
672
- sample.length > 0 ? ` 采样(≤3 行): ${sample.join(' | ')}` : ' 采样:无有效行',
673
- ...(tableFieldStats ? [tableFieldStats] : []),
674
- ...(dictText ? [dictText] : []),
675
- ].join('\n')
676
-
677
- // dataHook 下沉处理(用户配置的 (param, data, ctx) => {...})
678
- let hookText: string | undefined
679
- const artifacts: MesHookArtifact[] = [...(autosaved as MesHookArtifact[])]
680
- const hookCode = mesDataHookCode(cfg)
681
- if (hookCode) {
682
- const hookData: MesHookData = {
683
- node: { id: node.id, name: node.name, lineId: node.lineId, unit: node.unit },
684
- format,
685
- rows: buf,
686
- window: { from, to },
687
- }
688
- try {
689
- const outcome = await runMesDataHook(hookCode, param, hookData, { nodeId: node.id })
690
- if (outcome.ok) {
691
- artifacts.push(...outcome.artifacts)
692
- const parts = [` 钩子(dataHook):已执行,产物 ${outcome.artifacts.length} 个`]
693
- if (outcome.summary) parts.push(` 处理摘要: ${outcome.summary}`)
694
- if (outcome.context) parts.push(` 处理说明: ${outcome.context}`)
695
- if (outcome.logs.length > 0) parts.push(` hook 日志(≤3): ${outcome.logs.slice(0, 3).join(' / ')}`)
696
- hookText = parts.join('\n')
697
- }
698
- else {
699
- hookText = ` 钩子(dataHook)执行失败:${outcome.error ?? '未知原因'}(统计仍基于原始数据)`
700
- }
701
- }
702
- catch (err) {
703
- hookText = ` 钩子(dataHook)执行失败:${err instanceof Error ? err.message : String(err)}`
704
- }
705
- }
706
-
707
- // 产物行(hook 之外含自动落盘图像)
708
- if (artifacts.length > 0) {
709
- const shown = artifacts.slice(0, 8).map(a => `${a.name}(${Math.max(1, Math.round(a.bytes / 1024))}KB)`)
710
- hookText = `${hookText ?? ''}\n 产物(${artifacts.length}${artifacts.length > 8 ? ',显示前8' : ''}): ${shown.join(' | ')}`
711
- }
712
- return { text, stats, truncated, sample, hookText, artifacts }
713
- }
714
-
715
- /**
716
- * 取数编排(护栏全代码级):
717
- * 授权过滤 → 窗口/行数归一 → 频次限流 → 快照 / 内联 / 异步三模式。
718
- */
719
- async function fetch(agentId: string, args: MesFetchArgs): Promise<MesFetchOutcome> {
720
- // ① 授权:ids 必须是调用者可见(绑线)的 mes-rest 节点
721
- const vis = await resolveVisibleIds(agentId, args.ids)
722
- if (!vis.ok) return { text: vis.text, isError: true }
723
- // ② 窗口/行数护栏
724
- const win = normalizeWindow(args)
725
- if (!win.ok) return { text: win.text, isError: true }
726
- // ③ 频次限流(每 agent 每 60s ≤6 次)
727
- if (!mesFetchRateCheck(agentId, d.nowMs())) {
728
- return { text: `取数过于频繁:每 60 秒最多 ${MES_RATE_MAX_CALLS} 次。请先消化已有结果,稍后再取。`, isError: true }
729
- }
730
- // ④ 格式门控:image/table/event 的原文(帧/记录)不进 prompt 也不落 CSV 数据集,
731
- // 只支持内联行数(≤MES_SYNC_INLINE_MAX_ROWS);大窗口请拆小分批
732
- if (win.maxRows > MES_SYNC_INLINE_MAX_ROWS) {
733
- const INLINE_ONLY = new Set(['image', 'table', 'event'])
734
- const hits = vis.nodes.filter(n => INLINE_ONLY.has(historyFormatOf(n.driverConfig as Record<string, unknown>)))
735
- if (hits.length > 0) {
736
- return {
737
- text: `行数上限冲突:${hits.map(n => `${n.name}(${n.id})`).join(', ')} 是 图像/表格/事件 格式点位,只在 max_rows ≤ ${MES_SYNC_INLINE_MAX_ROWS} 的内联模式支持(原文不落 CSV 数据集)。请缩小时间窗或调低 max_rows 后重取。`,
738
- isError: true,
739
- }
740
- }
741
- }
742
-
743
- // 模式一:当前值快照(无 from/to)
744
- if (!win.from || !win.to) {
745
- const lines: string[] = []
746
- for (const node of vis.nodes) {
747
- const driver = d.resolveDriver(node.driver)
748
- try {
749
- if (typeof driver.read !== 'function') {
750
- lines.push(`- ${node.name}(${node.id}):驱动 ${node.driver} 不支持读取`)
751
- continue
752
- }
753
- const r = await driver.read({ domain: { min: node.min, max: node.max }, driverConfig: node.driverConfig })
754
- const at = new Date(d.nowMs()).toISOString()
755
- if (r.dictionary && r.dictionary.length > 0) cacheDictionary(node.id, r.dictionary)
756
- const dict = r.dictionary && r.dictionary.length > 0 ? r.dictionary : mesDictionaryOfNode(node.id, node.driverConfig as Record<string, unknown>)
757
- lines.push(r.ok && r.eng != null
758
- ? `- ${node.name}(${node.id}):${fmtN(r.eng)}${node.unit} @ ${shortTs(at)}${dict.length > 0 ? `\n${formatDictionary(dict, ' ')}` : ''}`
759
- : `- ${node.name}(${node.id}):读取失败(${r.message.slice(0, 80)})`)
760
- }
761
- catch (err) {
762
- lines.push(`- ${node.name}(${node.id}):读取异常(${(err instanceof Error ? err.message : String(err)).slice(0, 80)})`)
763
- }
764
- }
765
- return {
766
- mode: 'snapshot',
767
- text: `MES 当前值快照(${vis.nodes.length} 个点位,内联直读):\n${lines.join('\n')}\n\n说明:当前值为直读快照;历史窗口用 mes_fetch 带 from/to(≤7 天,max_rows≤${MES_MAX_ROWS_CAP})。`,
768
- }
769
- }
770
-
771
- // 模式二:同步内联(行数 ≤ MES_SYNC_INLINE_MAX_ROWS;格式感知+dataHook 下沉)
772
- if (win.maxRows <= MES_SYNC_INLINE_MAX_ROWS) {
773
- const sections: string[] = []
774
- const statsOut: NonNullable<MesFetchOutcome['data']>['stats'] = []
775
- for (const node of vis.nodes) {
776
- try {
777
- const one = await inlineFetchNode(node, win.from, win.to, win.maxRows, args.param, args.include_data === true || args.include_data === 'true')
778
- sections.push(one.hookText ? `${one.text}\n${one.hookText}` : one.text)
779
- statsOut.push({ nodeId: node.id, stats: one.stats, truncated: one.truncated })
780
- }
781
- catch (err) {
782
- sections.push(`■ ${node.name}(id=${node.id})\n 取数失败:${err instanceof Error ? err.message : String(err)}`)
783
- }
784
- }
785
- return {
786
- mode: 'inline',
787
- text: `MES 历史取数(内联同步,${vis.nodes.length} 个点位,窗口 ${shortTs(win.from)} ~ ${shortTs(win.to)}):\n${sections.join('\n')}\n\n说明:以上为统计摘要与 ≤3 行采样;MES 原文不进入对话。向量/图像/记录点位按各自格式呈现,已配置数据钩子(dataHook)的点位会附处理摘要与产物清单(文件落 <数据根>/mes-artifacts/<点位id>/)。需要标量/向量全量行请用更大 max_rows(> ${MES_SYNC_INLINE_MAX_ROWS})走异步数据集,再用 mes_dataset_read 读。`,
788
- data: { stats: statsOut },
789
- }
790
- }
791
-
792
- // 模式三:异步数据集(行数 > MES_SYNC_INLINE_MAX_ROWS;进程内异步,绝不进调度循环;
793
- // requestHook 覆盖在此同样生效——合并进作业用的 driverConfig)
794
- const jobIds: string[] = []
795
- const datasetIds: string[] = []
796
- const lines: string[] = []
797
- for (const node of vis.nodes) {
798
- let effCfg: Record<string, unknown>
799
- try {
800
- effCfg = await configWithRequestHook(node, args.param)
801
- }
802
- catch (err) {
803
- lines.push(`- ${node.name}(${node.id}):requestHook 失败,作业未创建(${err instanceof Error ? err.message : String(err)})`)
804
- continue
805
- }
806
- const run = node.lineId ? getActiveLineRun(node.lineId) : null
807
- const { jobId, datasetId } = d.store.createFetchJob({
808
- nodeId: node.id,
809
- fromIso: win.from,
810
- toIso: win.to,
811
- maxRows: win.maxRows,
812
- agentId,
813
- lineId: node.lineId,
814
- nodeName: node.name,
815
- driverConfig: effCfg,
816
- dictionary: mesDictionaryOfNode(node.id, node.driverConfig as Record<string, unknown>),
817
- nodeMeta: {
818
- unit: node.unit,
819
- min: node.min,
820
- max: node.max,
821
- description: String(node.driverConfig.desc ?? ''),
822
- semantics: String(node.driverConfig.semantics ?? ''),
823
- format: historyFormatOf(node.driverConfig as Record<string, unknown>),
824
- },
825
- context: run
826
- ? { lineId: run.lineId, productId: run.productId, recipeId: run.recipeId, runId: run.runId }
827
- : { lineId: node.lineId },
828
- })
829
- jobIds.push(jobId)
830
- datasetIds.push(datasetId)
831
- lines.push(`- ${node.name}(${node.id}):job_id=${jobId} dataset_id=${datasetId} status=running`)
832
- }
833
- return {
834
- mode: 'async',
835
- text: `已创建 ${lines.length} 个异步取数作业(窗口 ${shortTs(win.from)} ~ ${shortTs(win.to)},max_rows=${win.maxRows}):\n${lines.join('\n')}\n\n勿轮询;未完成先做别的,用 mes_datasets 查状态,完成后 mes_dataset_read(dataset_id, mode=stats/rows) 读内容。`,
836
- data: { job_ids: jobIds, dataset_ids: datasetIds },
837
- }
838
- }
839
-
840
- // ---------- 离线导出(指定目录 + manifest/README 语义清单) ----------
841
-
842
- /** 安全子路径:只允许落在 root 内(拒绝 ../、绝对路径逃逸、盘符切换) */
843
- function resolveUnderRoot(root: string, folder: string, fallback: string): { ok: true, dir: string } | { ok: false, text: string } {
844
- const base = resolve(root)
845
- const raw = String(folder ?? '').trim()
846
- if (!raw) return { ok: true, dir: join(base, fallback) }
847
- const target = resolve(base, raw)
848
- if (target !== base && !target.startsWith(`${base}${sep}`)) {
849
- return {
850
- ok: false,
851
- text: `导出目录被拒:folder=${raw} 越出允许根目录 ${base}(只接受相对路径;如需自定义根目录,请由管理员设置环境变量 AW_MES_EXPORT_ROOT)。`,
852
- }
853
- }
854
- return { ok: true, dir: target }
855
- }
856
-
857
- function safeSeg(value: string): string {
858
- return value.replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 80) || 'node'
859
- }
860
-
861
- function writeChunk(fd: number, text: string): void {
862
- const buf = Buffer.from(text, 'utf8')
863
- let off = 0
864
- while (off < buf.length) off += writeSync(fd, buf, off, buf.length - off)
865
- }
866
-
867
- /**
868
- * 把可见 MES 点位的历史原样导出到目录(流式写盘):
869
- * scalar → data.csv(ts,value)
870
- * vector → data.csv(宽表 ts,v0..vN)+ manifest 里的逐点语义
871
- * image → frames.jsonl(元数据)+ frames/*.png
872
- * table/event → records.jsonl
873
- * 每个导出目录都写 manifest.json + README.md(字段含义/单位/量程/产线批次上下文),
874
- * Agent 与离线分析器都能直接读懂,不需要回读平台。
875
- */
876
- async function exportData(agentId: string, args: MesExportArgs): Promise<MesToolResult & { dir?: string, manifestPath?: string, rows?: number }> {
877
- const vis = await resolveVisibleIds(agentId, args.ids)
878
- if (!vis.ok) return { text: vis.text, isError: true }
879
- const from = String(args.from ?? '').trim()
880
- const to = String(args.to ?? '').trim()
881
- if (!from || !to) return { text: 'mes_export 需要 from/to(ISO)历史窗口;当前值快照请用 mes_fetch。', isError: true }
882
- const fromMs = Date.parse(from)
883
- const toMs = Date.parse(to)
884
- if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) return { text: 'from/to 必须是合法 ISO 时间戳。', isError: true }
885
- if (fromMs >= toMs) return { text: `时间窗无效:from(${from}) 必须早于 to(${to})。`, isError: true }
886
- if (toMs - fromMs > MES_WINDOW_MAX_MS) {
887
- return { text: `时间窗被拒:超过 7 天上限。请拆成 ≤7 天的分段导出。`, isError: true }
888
- }
889
- const rawMax = args.max_rows == null || args.max_rows === '' ? MES_MAX_ROWS_CAP : Math.round(Number(args.max_rows))
890
- if (!Number.isFinite(rawMax) || rawMax < 1) return { text: 'max_rows 必须为 ≥1 的整数。', isError: true }
891
- const maxRows = Math.min(rawMax, MES_EXPORT_MAX_ROWS)
892
- if (!mesFetchRateCheck(agentId, d.nowMs())) {
893
- return { text: `导出过于频繁:每 60 秒最多 ${MES_RATE_MAX_CALLS} 次。请稍后再试。`, isError: true }
894
- }
895
-
896
- const root = process.env.AW_MES_EXPORT_ROOT
897
- ? resolve(process.env.AW_MES_EXPORT_ROOT)
898
- : join(ensureDataDir(), 'mes-exports')
899
- const exportId = `mesexp-${new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14)}-${randomUUID().slice(0, 6)}`
900
- const where = resolveUnderRoot(root, String(args.folder ?? ''), exportId)
901
- if (!where.ok) return { text: where.text, isError: true }
902
- const dir = where.dir
903
- mkdirSync(dir, { recursive: true })
904
-
905
- const title = String(args.title ?? '').trim() || `MES 数据导出 ${exportId}`
906
- const note = String(args.note ?? '').trim()
907
- const manifestNodes: Array<Record<string, unknown>> = []
908
- const failures: string[] = []
909
- const scalarFiles: Array<{ nodeName: string, nodeId: string, file: string }> = []
910
- let totalRows = 0
911
-
912
- for (const node of vis.nodes) {
913
- const cfg = node.driverConfig as Record<string, unknown>
914
- const format = historyFormatOf(cfg)
915
- const nodeDir = join(dir, safeSeg(node.id))
916
- try {
917
- mkdirSync(nodeDir, { recursive: true })
918
- const driver = d.resolveDriver(node.driver)
919
- if (typeof driver.fetchHistory !== 'function') {
920
- failures.push(`${node.name}(${node.id}):驱动 ${node.driver} 无历史原语`)
921
- continue
922
- }
923
- const effCfg = await configWithRequestHook(node, args.param)
924
- const run = node.lineId ? getActiveLineRun(node.lineId) : null
925
- let dictionary = mesDictionaryOfNode(node.id, cfg)
926
- let rows = 0
927
- let truncated = false
928
- let dim = 0
929
- let dimDrift = 0
930
- let skipped = 0
931
- let frameSaved = 0
932
- let frameSkipped = 0
933
- let fd: number | null = null
934
- let headerWritten = false
935
- let columns: string[] = []
936
- let fileRel = ''
937
- const jsonl: string[] = []
938
-
939
- if (format === 'image') {
940
- mkdirSync(join(nodeDir, 'frames'), { recursive: true })
941
- }
942
- else {
943
- fd = openSync(join(nodeDir, format === 'table' || format === 'event' ? 'records.jsonl' : 'data.csv'), 'w')
944
- }
945
-
946
- const result = await driver.fetchHistory({
947
- driverConfig: effCfg,
948
- fromIso: from,
949
- toIso: to,
950
- maxRows,
951
- onRows: (batch) => {
952
- if (!Array.isArray(batch)) return
953
- for (const r of batch) {
954
- if (rows >= maxRows) {
955
- truncated = true
956
- break
957
- }
958
- const ts = String(r?.ts ?? '')
959
- if (format === 'vector') {
960
- if (!Array.isArray(r?.values) || r.values.length === 0) {
961
- skipped++
962
- continue
963
- }
964
- if (!headerWritten) {
965
- dim = r.values.length
966
- columns = ['ts', ...Array.from({ length: dim }, (_, i) => `v${i}`)]
967
- writeChunk(fd!, `${columns.join(',')}\r\n`)
968
- headerWritten = true
969
- }
970
- if (r.values.length !== dim) dimDrift++
971
- const cells = [ts]
972
- for (let i = 0; i < dim; i++) {
973
- const v = r.values[i]
974
- cells.push(Number.isFinite(v) ? String(v) : '')
975
- }
976
- writeChunk(fd!, `${cells.join(',')}\r\n`)
977
- rows++
978
- continue
979
- }
980
- if (format === 'image') {
981
- if (typeof r?.data !== 'string' || r.data.trim() === '') {
982
- skipped++
983
- continue
984
- }
985
- if (frameSaved >= MES_EXPORT_MAX_FRAMES) {
986
- frameSkipped++
987
- truncated = true
988
- continue
989
- }
990
- const mime = typeof r.mime === 'string' && r.mime.includes('/') ? r.mime : 'image/png'
991
- const ext = mime.includes('jpeg') ? 'jpg' : mime.includes('webp') ? 'webp' : 'png'
992
- const name = `frames/${String(frameSaved).padStart(5, '0')}-${ts.replace(/[:.]/g, '-')}.${ext}`
993
- try {
994
- writeFileSync(join(nodeDir, name), Buffer.from(r.data, 'base64'))
995
- jsonl.push(JSON.stringify({ ts, mime, file: name, ...(r.record !== null && typeof r.record === 'object' ? { record: r.record } : {}) }))
996
- frameSaved++
997
- rows++
998
- }
999
- catch (imgErr) {
1000
- skipped++
1001
- jsonl.push(JSON.stringify({ ts, mime, error: imgErr instanceof Error ? imgErr.message : String(imgErr) }))
1002
- }
1003
- continue
1004
- }
1005
- if (format === 'table' || format === 'event') {
1006
- if (r?.record === null || r?.record === undefined) {
1007
- skipped++
1008
- continue
1009
- }
1010
- jsonl.push(JSON.stringify({ ts, record: r.record }))
1011
- rows++
1012
- continue
1013
- }
1014
- if (typeof r?.value !== 'number' || !Number.isFinite(r.value)) {
1015
- skipped++
1016
- continue
1017
- }
1018
- if (!headerWritten) {
1019
- columns = ['ts', 'value']
1020
- writeChunk(fd!, `${columns.join(',')}\r\n`)
1021
- headerWritten = true
1022
- }
1023
- writeChunk(fd!, `${ts},${r.value}\r\n`)
1024
- rows++
1025
- }
1026
- },
1027
- })
1028
- if (result?.dictionary && result.dictionary.length > 0) {
1029
- dictionary = result.dictionary
1030
- cacheDictionary(node.id, dictionary)
1031
- }
1032
- if (result && result.complete === false) truncated = true
1033
- if (format === 'image' || format === 'table' || format === 'event') {
1034
- writeFileSync(join(nodeDir, 'records.jsonl'), `${jsonl.join('\n')}${jsonl.length > 0 ? '\n' : ''}`, 'utf8')
1035
- fileRel = `${safeSeg(node.id)}/records.jsonl`
1036
- }
1037
- else {
1038
- if (!headerWritten) {
1039
- columns = format === 'vector' ? ['ts'] : ['ts', 'value']
1040
- writeChunk(fd!, `${columns.join(',')}\r\n`)
1041
- headerWritten = true
1042
- }
1043
- fileRel = `${safeSeg(node.id)}/data.csv`
1044
- }
1045
- if (fd != null) {
1046
- closeSync(fd)
1047
- fd = null
1048
- }
1049
- if (format === 'scalar') scalarFiles.push({ nodeName: node.name, nodeId: node.id, file: fileRel })
1050
- totalRows += rows
1051
- manifestNodes.push({
1052
- id: node.id,
1053
- name: node.name,
1054
- line_id: node.lineId,
1055
- format,
1056
- unit: node.unit,
1057
- range: { min: node.min, max: node.max },
1058
- description: String(cfg.desc ?? ''),
1059
- semantics: String(cfg.semantics ?? ''),
1060
- file: fileRel,
1061
- columns,
1062
- rows,
1063
- ...(format === 'vector' ? { vector: { dim, dimension_drift_rows: dimDrift } } : {}),
1064
- ...(format === 'image' ? { frames: { saved: frameSaved, skipped: frameSkipped } } : {}),
1065
- skipped_rows: skipped,
1066
- truncated,
1067
- fields: dictionary,
1068
- context: run ? { line_id: run.lineId, product_id: run.productId, recipe_id: run.recipeId, run_id: run.runId } : { line_id: node.lineId },
1069
- })
1070
- }
1071
- catch (err) {
1072
- failures.push(`${node.name}(${node.id}):${err instanceof Error ? err.message : String(err)}`)
1073
- }
1074
- }
1075
-
1076
- // 多标量节点按时间对齐的宽表(默认生成;纯时间戳交集,不做插值)
1077
- let mergedFile: string | null = null
1078
- const mergeEnabled = !(args.merge === false || args.merge === 'false')
1079
- if (mergeEnabled && scalarFiles.length > 1) {
1080
- try {
1081
- const series = scalarFiles.map((s) => {
1082
- const map = new Map<string, number>()
1083
- const raw = readFileSync(join(dir, s.file), 'utf8')
1084
- for (const line of raw.split(/\r?\n/).slice(1)) {
1085
- const [ts, v] = line.split(',')
1086
- if (ts && v !== undefined && Number.isFinite(Number(v))) map.set(ts, Number(v))
1087
- }
1088
- return { ...s, map }
1089
- })
1090
- const times = [...new Set(series.flatMap(s => [...s.map.keys()]))].sort()
1091
- const header = ['time', ...series.map(s => `${s.nodeName}(${s.nodeId})`)]
1092
- const lines = [header.join(',')]
1093
- for (const ts of times) lines.push([ts, ...series.map(s => s.map.get(ts) ?? '')].join(','))
1094
- writeFileSync(join(dir, 'merged.csv'), `${lines.join('\n')}\n`, 'utf8')
1095
- mergedFile = join(dir, 'merged.csv')
1096
- }
1097
- catch { /* merge 失败不影响单节点导出 */ }
1098
- }
1099
-
1100
- const manifest = {
1101
- schema: 'aw.mes-export/1',
1102
- export_id: exportId,
1103
- created_at: new Date().toISOString(),
1104
- title,
1105
- note,
1106
- window: { from, to, from_ms: fromMs, to_ms: toMs },
1107
- directory: dir,
1108
- nodes: manifestNodes,
1109
- merged_file: mergedFile,
1110
- totals: { nodes: manifestNodes.length, rows: totalRows, failed_nodes: failures.length },
1111
- usage: 'data.csv 首行为列名(ts=时间,v0..vN=向量点位);records.jsonl 每行一条记录;image 格式的像素在 frames/ 下,records.jsonl 是对应元数据。字段含义/单位/量程见 nodes[].fields(向量逐点语义在 fields[].points);批次归属见 nodes[].context。',
1112
- }
1113
- const manifestPath = join(dir, 'manifest.json')
1114
- writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8')
1115
-
1116
- const readme: string[] = [
1117
- `# ${title}`,
1118
- '',
1119
- `- 导出时间: ${new Date().toISOString()}`,
1120
- `- 时间窗: ${from} ~ ${to}`,
1121
- `- 导出目录: ${dir}`,
1122
- `- 说明: ${note || '(无)'}`,
1123
- '',
1124
- '## 文件与字段',
1125
- '',
1126
- ]
1127
- for (const n of manifestNodes) {
1128
- readme.push(`### ${String(n.name)} (${String(n.id)})`)
1129
- readme.push(`- 格式: ${String(n.format)};文件: ${String(n.file)};行数: ${String(n.rows)}`)
1130
- readme.push(`- 单位: ${String(n.unit || '-')};量程: ${JSON.stringify(n.range)}`)
1131
- if (n.semantics) readme.push(`- 物理意义: ${String(n.semantics)}`)
1132
- const fields = Array.isArray(n.fields) ? n.fields as DcwFieldDef[] : []
1133
- const dict = formatDictionary(fields, ' ')
1134
- if (dict) readme.push(dict)
1135
- readme.push('')
1136
- }
1137
- if (mergedFile) readme.push(`多参数对齐宽表: ${mergedFile}(列名=节点名(节点id);仅对齐相同时间戳,不插值)`, '')
1138
- if (failures.length > 0) readme.push('## 失败节点', '', ...failures.map(f => `- ${f}`), '')
1139
- writeFileSync(join(dir, 'README.md'), `${readme.join('\n')}\n`, 'utf8')
1140
-
1141
- const lines = manifestNodes.map(n => `- ${String(n.name)}(${String(n.id)}) [${String(n.format)}] ${String(n.rows)} 行 → ${String(n.file)}`)
1142
- const failText = failures.length > 0 ? `\n失败节点(${failures.length}):\n${failures.map(f => ` - ${f}`).join('\n')}` : ''
1143
- return {
1144
- isError: failures.length > 0,
1145
- dir,
1146
- manifestPath,
1147
- rows: totalRows,
1148
- text: `MES 数据已导出(${manifestNodes.length}/${vis.nodes.length} 个点位,共 ${totalRows} 行):\n${lines.join('\n')}${mergedFile ? `\n- 多参数宽表: ${mergedFile}` : ''}${failText}\n\n目录: ${dir}\n语义清单: ${manifestPath}\n说明: README.md\n\n离线分析请直接读取上述文件;在线继续取数用 mes_fetch/mes_dataset_read。`,
1149
- }
1150
- }
1151
-
1152
- return { catalog, fetch, exportData }
1153
- }
1154
-
1155
- export type MesController = ReturnType<typeof createMesController>
1
+ /**
2
+ * MES 取数控制器(Agent 工具后端)—— mes-rest 点位目录 + 历史取数编排。
3
+ *
4
+ * 护栏全部**代码级**(不是提示词):绑线授权过滤、时间窗 ≤7 天、maxRows ≤5000、
5
+ * 每 agent 每 60s ≤6 次 fetch;数据原文不进 prompt —— 文本只给 stats + ≤3 行采样,
6
+ * 行级原文只落 CSV 数据集(mes-datasets)。
7
+ *
8
+ * 取数三模式:
9
+ * 无 from/to → 当前值快照(driver.read 内联直读);
10
+ * from/to 且 maxRows ≤ 2000 → 同步 fetchHistory 内联返回(缓冲截断保护);
11
+ * 其余(maxRows > 2000) → createFetchJob 异步落 CSV,回 job_id/dataset_id。
12
+ */
13
+ import { randomUUID } from 'node:crypto'
14
+ import { closeSync, mkdirSync, openSync, readFileSync, writeFileSync, writeSync } from 'node:fs'
15
+ import { join, resolve, sep } from 'node:path'
16
+ import { ensureDataDir } from '@/shared/config/home.mjs'
17
+ import { getActiveLineRun } from '../dcw/line-run'
18
+ import { resolveDcwDriver } from '../dcw/drivers'
19
+ import type { DcwFieldDef, DcwHistoryFormat as MesHistoryFormat } from '../dcw/drivers/shared'
20
+ import { historyFormatOf, normalizeMesDictionary } from '../dcw/drivers/mes-rest'
21
+ import type { MesHistoryDriver, MesDatasetStatsView, MesDatasetStore } from './mes-datasets'
22
+ import { getMesDatasets } from './mes-datasets'
23
+ import { mesDataHookCode, mesRequestHookCode, runMesDataHook, runMesRequestHook, saveMesImageArtifact } from './mes-hook'
24
+ import type { MesHookArtifact, MesHookData } from './mes-hook'
25
+
26
+ /** mes-rest 驱动 kind(并行工作流收编进 DcwDriverKind 联合;此处按字符串经注册表解析,不 import 驱动实现) */
27
+ export const MES_REST_DRIVER_KIND = 'mes-rest'
28
+
29
+ // ============================================================
30
+ // 护栏常量(单一事实源;测试直接引用)
31
+ // ============================================================
32
+
33
+ /** 历史窗口上限:7 天 */
34
+ export const MES_WINDOW_MAX_MS = 7 * 24 * 3_600_000
35
+ /** 单次取数行数硬上限 */
36
+ export const MES_MAX_ROWS_CAP = 5000
37
+ /** 同步内联返回的行数上限(超过走异步数据集) */
38
+ export const MES_SYNC_INLINE_MAX_ROWS = 2000
39
+ /** 频次限流:窗口与次数(每 agent) */
40
+ export const MES_RATE_WINDOW_MS = 60_000
41
+ export const MES_RATE_MAX_CALLS = 6
42
+ /** max_rows 缺省值 */
43
+ export const MES_DEFAULT_MAX_ROWS = 500
44
+ /** 离线导出单次行数上限(CSV/JSONL 流式写盘;比在线取数宽,仍防磁盘失控) */
45
+ export const MES_EXPORT_MAX_ROWS = 200_000
46
+ /** 离线导出图像帧上限(单次) */
47
+ export const MES_EXPORT_MAX_FRAMES = 500
48
+
49
+ // ============================================================
50
+ // 频次限流(进程内内存计数;Map<agentId, 时间戳[]>)
51
+ // ============================================================
52
+
53
+ const fetchCallStamps = new Map<string, number[]>()
54
+
55
+ /** 记一次 fetch 并判定是否放行(滑动 60s 窗 ≤6 次;超限不记账) */
56
+ export function mesFetchRateCheck(agentId: string, nowMs = Date.now()): boolean {
57
+ const stamps = (fetchCallStamps.get(agentId) ?? []).filter(t => nowMs - t < MES_RATE_WINDOW_MS)
58
+ if (stamps.length >= MES_RATE_MAX_CALLS) {
59
+ fetchCallStamps.set(agentId, stamps)
60
+ return false
61
+ }
62
+ stamps.push(nowMs)
63
+ fetchCallStamps.set(agentId, stamps)
64
+ return true
65
+ }
66
+
67
+ /** 清空限流账(测试用) */
68
+ export function mesFetchRateReset(): void {
69
+ fetchCallStamps.clear()
70
+ }
71
+
72
+ // ============================================================
73
+ // 节点/依赖(结构化注入;缺省接真实服务,测试注入假件不联网)
74
+ // ============================================================
75
+
76
+ export interface MesNodeLike {
77
+ id: string
78
+ name: string
79
+ driver: string
80
+ lineId: string
81
+ unit: string
82
+ min: number
83
+ max: number
84
+ enabled: boolean
85
+ driverConfig: Record<string, string | number | boolean>
86
+ }
87
+
88
+ export interface MesControllerDeps {
89
+ /** 数据集服务(异步取数账本;缺省 getMesDatasets()) */
90
+ store: Pick<MesDatasetStore, 'createFetchJob'>
91
+ /** 全量 dcw 节点(缺省 dcw-node.repo) */
92
+ nodes: () => MesNodeLike[] | Promise<MesNodeLike[]>
93
+ /** 调用者可见节点(绑线过滤:dcw 绑定集;缺省 node-bindings.repo) */
94
+ boundNodeIds: (agentId: string) => Set<string> | Promise<Set<string>>
95
+ /** 驱动解析(缺省 dcw 注册表) */
96
+ resolveDriver: (kind: string) => MesHistoryDriver
97
+ nowMs: () => number
98
+ }
99
+
100
+ /** 缺省依赖:重模块(dcw 仓储/绑线仓储)经动态 import 引入,保持本模块可被 tsx 测试轻量直跑 */
101
+ function defaultDeps(): MesControllerDeps {
102
+ return {
103
+ store: new Proxy({} as Pick<MesDatasetStore, 'createFetchJob'>, {
104
+ get: (_t, prop) => {
105
+ const store = getMesDatasets() as unknown as Record<string | symbol, unknown>
106
+ const v = store[prop]
107
+ return typeof v === 'function' ? (v as (...a: unknown[]) => unknown).bind(store) : v
108
+ },
109
+ }),
110
+ nodes: async () => {
111
+ const { getDcwNodeRepo } = await import('../dcw/dcw-node.repo')
112
+ return getDcwNodeRepo().all()
113
+ },
114
+ boundNodeIds: async (agentId) => {
115
+ // 权限模型 v2:dcw 绑定(存量)∪ 绑定配方内的参数节点(kind='recipe' 的配方可见节点)
116
+ const { getAgentNodeBindingRepo } = await import('../agents/node-bindings.repo')
117
+ const { getDcwController } = await import('../dcw/dcw-controller')
118
+ const bindings = getAgentNodeBindingRepo().byAgent(agentId)
119
+ const ids = new Set(bindings.filter(b => b.kind === 'dcw').map(b => b.nodeId))
120
+ const recipeIds = new Set(bindings.filter(b => b.kind === 'recipe').map(b => b.nodeId))
121
+ if (recipeIds.size > 0) {
122
+ for (const r of getDcwController().listRecipes()) {
123
+ if (!recipeIds.has(r.id)) continue
124
+ for (const p of r.params) ids.add(p.nodeId)
125
+ }
126
+ }
127
+ return ids
128
+ },
129
+ resolveDriver: kind => resolveDcwDriver(kind as Parameters<typeof resolveDcwDriver>[0]),
130
+ nowMs: () => Date.now(),
131
+ }
132
+ }
133
+
134
+ export type MesCatalogEntry = {
135
+ id: string
136
+ name: string
137
+ lineId: string
138
+ unit: string
139
+ min: number
140
+ max: number
141
+ desc: string
142
+ readable: boolean
143
+ writable: boolean
144
+ historyable: boolean
145
+ /** 历史格式(scalar/vector/image/table/event;historyMap 未配置时 scalar) */
146
+ format: MesHistoryFormat
147
+ /** 已配置数据下沉 hook(dataHook) */
148
+ hooked: boolean
149
+ enabled: boolean
150
+ /** 字段级数据字典(响应缓存 ∪ 节点静态配置;无则空数组) */
151
+ fields: DcwFieldDef[]
152
+ }
153
+
154
+ // ============================================================
155
+ // 字段字典缓存(响应返回 → 后续 catalog/导出复用)
156
+ // ============================================================
157
+
158
+ const dictionaryCache = new Map<string, DcwFieldDef[]>()
159
+ const DICTIONARY_CACHE_MAX = 200
160
+
161
+ function cacheDictionary(nodeId: string, fields: DcwFieldDef[] | undefined): void {
162
+ if (!fields || fields.length === 0) return
163
+ dictionaryCache.delete(nodeId)
164
+ dictionaryCache.set(nodeId, fields)
165
+ while (dictionaryCache.size > DICTIONARY_CACHE_MAX) {
166
+ const oldest = dictionaryCache.keys().next().value
167
+ if (oldest === undefined) break
168
+ dictionaryCache.delete(oldest)
169
+ }
170
+ }
171
+
172
+ /** 节点静态字典(driverConfig.dictionary / fieldDictionary 的 JSON 文本) */
173
+ function configuredDictionary(cfg: Record<string, unknown>): DcwFieldDef[] {
174
+ for (const key of ['dictionary', 'fieldDictionary', 'fields']) {
175
+ const raw = cfg[key]
176
+ if (raw === undefined || raw === null || String(raw).trim() === '') continue
177
+ try {
178
+ const parsed = typeof raw === 'string' ? JSON.parse(raw) as unknown : raw
179
+ const fields = normalizeMesDictionary(parsed)
180
+ if (fields.length > 0) return fields
181
+ }
182
+ catch { /* 坏配置不击穿目录;由驱动测试报错 */ }
183
+ }
184
+ return []
185
+ }
186
+
187
+ /** 节点有效字典:响应缓存优先(实时真相),否则静态配置 */
188
+ export function mesDictionaryOfNode(nodeId: string, cfg: Record<string, unknown>): DcwFieldDef[] {
189
+ return dictionaryCache.get(nodeId) ?? configuredDictionary(cfg)
190
+ }
191
+
192
+ /** 字典一行摘要(字段名(标签,单位;量程;点数)) */
193
+ export function fieldSummaryOf(fields: DcwFieldDef[]): string {
194
+ return fields.slice(0, 8).map((f) => {
195
+ const bits = [f.label, f.unit, f.min != null || f.max != null ? `${f.min ?? '-∞'}~${f.max ?? '+∞'}` : '', f.points?.length ? `${f.points.length} 点` : '']
196
+ .filter(Boolean)
197
+ return bits.length > 0 ? `${f.field}(${bits.join(',')})` : f.field
198
+ }).join('; ')
199
+ }
200
+
201
+ /** 字段字典 → 多行可读文本(Agent 直接引用;含单位/量程/物理意义/逐点语义) */
202
+ export function formatDictionary(fields: DcwFieldDef[], indent = ' '): string {
203
+ if (fields.length === 0) return ''
204
+ const pointLine = (f: DcwFieldDef): string => {
205
+ const pts = f.points ?? []
206
+ if (pts.length === 0) return ''
207
+ const head = pts.slice(0, 6).map(p => `${p.index ?? '?'}=${p.label ?? p.field}${p.unit ? `(${p.unit})` : ''}`).join(', ')
208
+ return `; 点位 ${pts.length} 个: ${head}${pts.length > 6 ? ', …' : ''}`
209
+ }
210
+ const lines = fields.slice(0, 24).map((f) => {
211
+ const meta = [
212
+ f.label && f.label !== f.field ? `标签 ${f.label}` : '',
213
+ f.unit ? `单位 ${f.unit}` : '',
214
+ f.min != null || f.max != null ? `量程 ${f.min ?? '-∞'}~${f.max ?? '+∞'}` : '',
215
+ f.kind ? `形态 ${f.kind}` : '',
216
+ ].filter(Boolean).join(' | ')
217
+ const desc = f.description ? ` — ${f.description.slice(0, 160)}` : ''
218
+ return `${indent}- ${f.field}${meta ? ` [${meta}]` : ''}${desc}${pointLine(f)}`
219
+ })
220
+ return `字段字典(${fields.length} 个字段,来自 MES 响应/节点配置):\n${lines.join('\n')}${fields.length > 24 ? `\n${indent}(仅显示前 24 个字段)` : ''}`
221
+ }
222
+
223
+ /** 目录条目合成:desc/readMap/writeMap/historyMap 均来自 driverConfig(数据驱动,零硬编码) */
224
+ export function mesCatalogEntryOf(n: MesNodeLike): MesCatalogEntry {
225
+ const cfg = n.driverConfig ?? {}
226
+ return {
227
+ id: n.id,
228
+ name: n.name,
229
+ lineId: n.lineId ?? '',
230
+ unit: n.unit ?? '',
231
+ min: n.min,
232
+ max: n.max,
233
+ desc: String(cfg.desc ?? ''),
234
+ readable: Boolean(cfg.readMap),
235
+ writable: Boolean(cfg.writeMap),
236
+ historyable: Boolean(cfg.historyMap),
237
+ format: historyFormatOf(cfg as Record<string, unknown>),
238
+ hooked: Boolean(cfg.dataHook),
239
+ enabled: Boolean(n.enabled),
240
+ fields: mesDictionaryOfNode(n.id, cfg as Record<string, unknown>),
241
+ }
242
+ }
243
+
244
+ // ============================================================
245
+ // 控制器
246
+ // ============================================================
247
+
248
+ export type MesToolResult = { text: string, isError?: boolean }
249
+
250
+ export type MesFetchOutcome = MesToolResult & {
251
+ mode?: 'snapshot' | 'inline' | 'async'
252
+ data?: {
253
+ job_ids?: string[]
254
+ dataset_ids?: string[]
255
+ stats?: Array<{ nodeId: string, stats: MesDatasetStatsView, truncated: boolean }>
256
+ }
257
+ }
258
+
259
+ export interface MesFetchArgs {
260
+ ids?: unknown
261
+ from?: string
262
+ to?: string
263
+ max_rows?: number | string
264
+ /** 透传给 requestHook/dataHook 的参数对象(Agent 只传 param,其余交给配置) */
265
+ param?: unknown
266
+ /** 内联/快照回包是否附带采样行的实际数组/数值内容(默认 false=只给统计与均值) */
267
+ include_data?: boolean | string
268
+ }
269
+
270
+ export interface MesCatalogArgs {
271
+ q?: string
272
+ line_id?: string
273
+ /** 按产品 id 收窄到该产品产线(可选;与 line_id 冲突时拒绝) */
274
+ product_id?: string
275
+ /** 按配方 id 收窄到该配方产线(可选;与 line_id 冲突时拒绝) */
276
+ recipe_id?: string
277
+ limit?: number | string
278
+ /** 调用者可读产线集(绑线授权口径);提供时严格过滤(孤儿/越线点位不可见,空集=空目录 fail-closed) */
279
+ scope_line_ids?: string[]
280
+ }
281
+
282
+ export interface MesExportArgs {
283
+ ids?: unknown
284
+ from?: string
285
+ to?: string
286
+ max_rows?: number | string
287
+ /** 透传给 requestHook 的调用参数 */
288
+ param?: unknown
289
+ /** 导出子目录(相对 <数据根>/mes-exports;绝对路径须落在 AW_MES_EXPORT_ROOT 内) */
290
+ folder?: string
291
+ title?: string
292
+ note?: string
293
+ /** 标量节点是否生成按时间对齐的 merged.csv(缺省 true) */
294
+ merge?: boolean | string
295
+ }
296
+
297
+ export function createMesController(deps: Partial<MesControllerDeps> = {}) {
298
+ const d: MesControllerDeps = { ...defaultDeps(), ...deps }
299
+
300
+ // ---------- 目录 ----------
301
+
302
+ /** mes-rest 点位目录(q 对 name/desc 子串过滤;line_id 精确过滤;limit 缺省 20;
303
+ * scope_line_ids 提供时按调用者可读产线严格过滤——跨产线点位与孤儿(未分配)点位不可见) */
304
+ async function catalog(args: MesCatalogArgs = {}): Promise<MesToolResult & { entries: MesCatalogEntry[], total: number }> {
305
+ const all = await d.nodes()
306
+ let mes = all.filter(n => n.driver === MES_REST_DRIVER_KIND).map(mesCatalogEntryOf)
307
+ if (Array.isArray(args.scope_line_ids)) {
308
+ const scope = new Set(args.scope_line_ids)
309
+ mes = mes.filter(e => e.lineId !== '' && scope.has(e.lineId))
310
+ }
311
+ const total = mes.length
312
+ let lineId = String(args.line_id ?? '').trim()
313
+ const productId = String(args.product_id ?? '').trim()
314
+ if (productId) {
315
+ const { getDcwProductRepo } = await import('../dcw/dcw-product.repo')
316
+ const product = getDcwProductRepo().byId(productId)
317
+ if (!product) return { text: `产品 ${productId} 不存在。`, isError: true, entries: [], total: 0 }
318
+ if (lineId && product.lineId !== lineId) return { text: `产品 ${productId} 归属产线 ${product.lineId},与 line_id=${lineId} 不一致。`, isError: true, entries: [], total: 0 }
319
+ lineId = product.lineId
320
+ }
321
+ const recipeId = String(args.recipe_id ?? '').trim()
322
+ if (recipeId) {
323
+ const { getDcwController } = await import('../dcw/dcw-controller')
324
+ const recipe = getDcwController().listRecipes().find(r => r.id === recipeId)
325
+ if (!recipe) return { text: `配方 ${recipeId} 不存在。`, isError: true, entries: [], total: 0 }
326
+ if (lineId && recipe.lineId !== lineId) return { text: `配方 ${recipeId} 归属产线 ${recipe.lineId},与 line_id=${lineId} 不一致。`, isError: true, entries: [], total: 0 }
327
+ lineId = recipe.lineId
328
+ }
329
+ if (lineId) mes = mes.filter(e => e.lineId === lineId)
330
+ const q = String(args.q ?? '').trim().toLowerCase()
331
+ if (q) mes = mes.filter(e => e.name.toLowerCase().includes(q) || e.desc.toLowerCase().includes(q))
332
+ const limit = Math.min(Math.max(Math.round(Number(args.limit)) || 20, 1), 100)
333
+ const shown = mes.slice(0, limit)
334
+
335
+ const cap = (e: MesCatalogEntry): string => {
336
+ const hist = e.historyable ? (e.format !== 'scalar' ? `史·${e.format}` : '史') : null
337
+ const ab = [e.readable ? '读' : null, e.writable ? '写' : null, hist, e.hooked ? '钩子' : null].filter(Boolean)
338
+ return ab.length > 0 ? ab.join('/') : '无能力位'
339
+ }
340
+ const body = shown.map((e) => {
341
+ const fields = e.fields.length > 0 ? ` | 字段: ${fieldSummaryOf(e.fields)}` : ''
342
+ return `- ${e.name}(id=${e.id}) | 产线 ${e.lineId || '未分配'} | 单位 ${e.unit || '-'} | 量程 ${e.min}~${e.max} | 能力 ${cap(e)}${e.enabled ? '' : ' [停用]'}${e.desc ? ` | ${e.desc.slice(0, 80)}` : ''}${fields}`
343
+ })
344
+ const more = mes.length - shown.length
345
+ const text = `MES REST 点位目录(共 ${total} 个${lineId ? `,产线 ${lineId}` : ''}${q ? `,关键字「${args.q}」` : ''};显示 ${shown.length} 条):\n${body.join('\n') || '(无匹配点位)'}${more > 0 ? `\n(另有 ${more} 条未显示,可收紧 q/line_id 或调大 limit≤100)` : ''}\n\n说明:能力 读=可读当前值,写=可写设定值,史=可取历史(史·vector=每时间点检测向量,史·image=图像帧,史·table/event=记录流),钩子=已配 dataHook(取数后自动做下沉处理并回传摘要与产物)。字段级语义来自 MES 响应 dictionaryPath 或节点 driverConfig.dictionary;首次 mes_fetch 后缓存,后续目录可直接看到字段标签/单位/点位。历史取数用 mes_fetch(ids=[点位id], from, to, max_rows, param?);需要落盘到目录做离线分析用 mes_export。`
346
+ return { text, entries: shown, total }
347
+ }
348
+
349
+ // ---------- 取数 ----------
350
+
351
+ /** 归一 ids + 授权过滤(绑线路径:仅调用者 dcw 绑定的 mes-rest 节点) */
352
+ async function resolveVisibleIds(agentId: string, rawIds: unknown): Promise<{ ok: true, nodes: MesNodeLike[] } | { ok: false, text: string, isError: true }> {
353
+ const ids = Array.isArray(rawIds) ? [...new Set(rawIds.map(x => String(x ?? '').trim()).filter(Boolean))] : []
354
+ if (ids.length === 0) return { ok: false, text: 'ids 必填:目标 mes-rest 点位 id 数组(catalog 输出的 id;至少 1 个)。', isError: true }
355
+ const all = await d.nodes()
356
+ const bound = await d.boundNodeIds(agentId)
357
+ const mesById = new Map(all.filter(n => n.driver === MES_REST_DRIVER_KIND).map(n => [n.id, n]))
358
+ const picked: MesNodeLike[] = []
359
+ const missing: string[] = []
360
+ const notAllowed: string[] = []
361
+ for (const id of ids) {
362
+ const n = mesById.get(id)
363
+ if (!n) {
364
+ missing.push(id)
365
+ continue
366
+ }
367
+ if (!bound.has(id)) {
368
+ notAllowed.push(id)
369
+ continue
370
+ }
371
+ picked.push(n)
372
+ }
373
+ if (missing.length > 0 || notAllowed.length > 0) {
374
+ const allowed = [...bound]
375
+ .map(id => mesById.get(id))
376
+ .filter((n): n is MesNodeLike => !!n && n.driver === MES_REST_DRIVER_KIND)
377
+ const parts: string[] = []
378
+ if (missing.length > 0) parts.push(`不存在或不是 mes-rest 点位:${missing.join(', ')}`)
379
+ if (notAllowed.length > 0) parts.push(`无权访问(须为你绑定的数控节点):${notAllowed.join(', ')}`)
380
+ return {
381
+ ok: false,
382
+ text: `取数被拒:${parts.join(';')}。你有权取数的 mes-rest 点位:${allowed.map(n => `${n.name}(${n.id})`).join(', ') || '(无)'}。`,
383
+ isError: true,
384
+ }
385
+ }
386
+ return { ok: true, nodes: picked }
387
+ }
388
+
389
+ /** 时间窗/行数护栏归一(代码级;返回错误文本或归一值) */
390
+ function normalizeWindow(args: MesFetchArgs): { ok: true, from?: string, to?: string, maxRows: number } | { ok: false, text: string, isError?: true } {
391
+ const from = String(args.from ?? '').trim()
392
+ const to = String(args.to ?? '').trim()
393
+ if ((from && !to) || (!from && to)) {
394
+ return { ok: false, text: 'from/to 必须成对提供(历史取数),或都不传(当前值快照模式)。' }
395
+ }
396
+ if (from && to) {
397
+ const fromMs = Date.parse(from)
398
+ const toMs = Date.parse(to)
399
+ if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) return { ok: false, text: 'from/to 必须是合法 ISO 时间戳。' }
400
+ if (fromMs >= toMs) return { ok: false, text: `时间窗无效:from(${from}) 必须早于 to(${to})。` }
401
+ if (toMs - fromMs > MES_WINDOW_MAX_MS) {
402
+ return { ok: false, text: `时间窗被拒:窗口 ${(toMs - fromMs) / 3_600_000 / 24} 天超过上限 7 天。请拆成 ≤7 天的分段分批取数。`, isError: true }
403
+ }
404
+ }
405
+ const maxRows = args.max_rows == null || args.max_rows === '' ? MES_DEFAULT_MAX_ROWS : Math.round(Number(args.max_rows))
406
+ if (!Number.isFinite(maxRows) || maxRows < 1) return { ok: false, text: 'max_rows 必须为 ≥1 的整数。' }
407
+ if (maxRows > MES_MAX_ROWS_CAP) {
408
+ return { ok: false, text: `max_rows=${maxRows} 被拒:单次取数上限 ${MES_MAX_ROWS_CAP} 行。请缩小时间窗或分批取数。`, isError: true }
409
+ }
410
+ return { ok: true, from: from || undefined, to: to || undefined, maxRows }
411
+ }
412
+
413
+ /** 统计摘要(数值列;均值/采样标准差) */
414
+ function statsOf(values: number[], firstTs: string | null, lastTs: string | null): MesDatasetStatsView {
415
+ const n = values.length
416
+ if (n === 0) return { count: 0, min: null, max: null, mean: null, stddev: null, firstTs: null, lastTs: null }
417
+ const min = Math.min(...values)
418
+ const max = Math.max(...values)
419
+ const mean = values.reduce((a, b) => a + b, 0) / n
420
+ const stddev = n > 1 ? Math.sqrt(values.reduce((a, b) => a + (b - mean) ** 2, 0) / (n - 1)) : 0
421
+ return { count: n, min, max, mean, stddev, firstTs, lastTs }
422
+ }
423
+
424
+ const fmtN = (v: number | null | undefined, digits = 3): string =>
425
+ v == null || !Number.isFinite(v) ? '-' : String(Number(v.toFixed(digits)))
426
+ const shortTs = (iso: string | null): string => iso && iso.length >= 19 ? iso.slice(5, 19).replace('T', ' ') : (iso ?? '-')
427
+ const clip = (v: unknown, max: number): string => {
428
+ const s = typeof v === 'string' ? v : JSON.stringify(v) ?? String(v)
429
+ return s.length > max ? `${s.slice(0, max)}…` : s
430
+ }
431
+
432
+ // -------- 格式感知取数(行形态全谱;内存硬顶防大payload 拖垮进程) --------
433
+
434
+ /** 泛化历史行缓冲的硬顶 */
435
+ const VECTOR_ELEMENT_CAP = 2_000_000
436
+ const IMAGE_BASE64_CAP = 16_000_000
437
+ const RECORD_JSON_CAP = 8_000_000
438
+ /** image 格式自动落盘帧数上限(其余帧不落盘,回包注明) */
439
+ const IMAGE_AUTOSAVE_MAX = 20
440
+
441
+ interface GenRow { ts: string, value?: number, values?: number[], data?: string, mime?: string, record?: unknown }
442
+
443
+ interface GenStats extends MesDatasetStatsView {
444
+ /** vector:维度(首行长度)与维度不齐行数 */
445
+ dim?: number
446
+ dimMismatch?: number
447
+ /** vector:全体元素均值(比行均值更细) */
448
+ elementMean?: number
449
+ }
450
+
451
+ /** requestHook 覆盖合并:克隆 driverConfig,把 {path,query,headers} 合入 historyMap JSON */
452
+ async function configWithRequestHook(node: MesNodeLike, param: unknown): Promise<Record<string, unknown>> {
453
+ const cfg = { ...(node.driverConfig as Record<string, unknown>) }
454
+ const hookCode = mesRequestHookCode(cfg as Record<string, unknown>)
455
+ if (!hookCode) return cfg
456
+ const overrides = await runMesRequestHook(hookCode, param, { nodeId: node.id })
457
+ if (overrides.path === undefined && overrides.query === undefined && overrides.headers === undefined) return cfg
458
+ try {
459
+ const map = JSON.parse(String(cfg.historyMap ?? '{}')) as Record<string, unknown>
460
+ if (overrides.path !== undefined) map.path = overrides.path
461
+ const baseQuery = (map.query !== null && typeof map.query === 'object' && !Array.isArray(map.query) ? map.query : {}) as Record<string, unknown>
462
+ map.query = { ...baseQuery, ...(overrides.query ?? {}) }
463
+ const baseHeaders = (map.headers !== null && typeof map.headers === 'object' && !Array.isArray(map.headers) ? map.headers : {}) as Record<string, unknown>
464
+ if (overrides.headers !== undefined) map.headers = { ...baseHeaders, ...overrides.headers }
465
+ cfg.historyMap = JSON.stringify(map)
466
+ }
467
+ catch (err) {
468
+ throw new AppError(422, 'MES_HOOK_FAILED', `requestHook 覆盖合并失败(historyMap 非法 JSON):${err instanceof Error ? err.message : String(err)}`)
469
+ }
470
+ return cfg
471
+ }
472
+
473
+ /** 向量行统计摘要(行均值序列 stats + 维度 + 全体元素均值) */
474
+ function vectorStats(rows: GenRow[]): GenStats {
475
+ const rowMeans = rows.map((r) => {
476
+ const vs = r.values ?? []
477
+ return vs.length > 0 ? vs.reduce((a, b) => a + b, 0) / vs.length : NaN
478
+ }).filter(v => Number.isFinite(v))
479
+ const all: number[] = []
480
+ for (const r of rows) if (Array.isArray(r.values)) all.push(...r.values)
481
+ const base = statsOf(rowMeans, rows[0]?.ts ?? null, rows[rows.length - 1]?.ts ?? null) as GenStats
482
+ base.dim = Array.isArray(rows[0]?.values) ? rows[0]!.values!.length : undefined
483
+ base.dimMismatch = base.dim === undefined ? undefined : rows.filter(r => Array.isArray(r.values) && r.values!.length !== base.dim).length
484
+ base.elementMean = all.length > 0 ? all.reduce((a, b) => a + b, 0) / all.length : undefined
485
+ return base
486
+ }
487
+
488
+ /** 同步取单节点历史(格式感知:统计+采样+图像落盘+dataHook 下沉处理;原文不回传) */
489
+ async function inlineFetchNode(node: MesNodeLike, from: string, to: string, maxRows: number, param: unknown, includeData = false): Promise<{
490
+ text: string
491
+ stats: MesDatasetStatsView
492
+ truncated: boolean
493
+ sample: string[]
494
+ hookText?: string
495
+ artifacts: MesHookArtifact[]
496
+ }> {
497
+ const cfg = node.driverConfig as Record<string, unknown>
498
+ const format = historyFormatOf(cfg)
499
+ const driver = d.resolveDriver(node.driver)
500
+ if (typeof driver.fetchHistory !== 'function') {
501
+ return { text: `驱动 ${node.driver} 未提供历史原语(fetchHistory)`, stats: statsOf([], null, null), truncated: true, sample: [], artifacts: [] }
502
+ }
503
+ const effCfg = await configWithRequestHook(node, param)
504
+ const buf: GenRow[] = []
505
+ let truncated = false
506
+ let vecElems = 0
507
+ let imgChars = 0
508
+ let recChars = 0
509
+ let memoryHit = ''
510
+ let dictionary: DcwFieldDef[]
511
+ const result = await driver.fetchHistory({
512
+ driverConfig: effCfg,
513
+ fromIso: from,
514
+ toIso: to,
515
+ maxRows,
516
+ onRows: (batch) => {
517
+ for (const r of batch ?? []) {
518
+ if (buf.length >= maxRows) {
519
+ truncated = true
520
+ break
521
+ }
522
+ const row: GenRow = { ts: String(r?.ts ?? '') }
523
+ if (typeof r?.value === 'number') row.value = r.value
524
+ if (Array.isArray(r?.values)) {
525
+ vecElems += r.values.length
526
+ if (vecElems > VECTOR_ELEMENT_CAP) {
527
+ memoryHit = `向量元素总量超过 ${VECTOR_ELEMENT_CAP} 上限`
528
+ truncated = true
529
+ break
530
+ }
531
+ row.values = r.values as number[]
532
+ }
533
+ if (typeof r?.data === 'string') {
534
+ imgChars += r.data.length
535
+ if (imgChars > IMAGE_BASE64_CAP) {
536
+ memoryHit = `图像载荷总量超过 ${Math.round(IMAGE_BASE64_CAP / 1024 / 1024)}MB 上限`
537
+ truncated = true
538
+ break
539
+ }
540
+ row.data = r.data
541
+ row.mime = typeof r?.mime === 'string' ? r.mime : 'image/png'
542
+ }
543
+ if (r?.record !== undefined && r.record !== null) {
544
+ let json: string
545
+ try {
546
+ json = JSON.stringify(r.record)
547
+ }
548
+ catch {
549
+ continue
550
+ }
551
+ recChars += json.length
552
+ if (recChars > RECORD_JSON_CAP) {
553
+ memoryHit = `记录载荷总量超过 ${Math.round(RECORD_JSON_CAP / 1024 / 1024)}MB 上限`
554
+ truncated = true
555
+ break
556
+ }
557
+ row.record = r.record
558
+ }
559
+ buf.push(row)
560
+ }
561
+ },
562
+ })
563
+ if (result?.dictionary && result.dictionary.length > 0) {
564
+ dictionary = result.dictionary
565
+ cacheDictionary(node.id, dictionary)
566
+ }
567
+ else {
568
+ dictionary = mesDictionaryOfNode(node.id, cfg)
569
+ }
570
+ if (result && result.complete === false) truncated = true
571
+ if (!truncated && memoryHit) truncated = true
572
+
573
+ // 统计与采样(按格式)
574
+ let stats: GenStats
575
+ let autosaved: MesHookArtifact[] = []
576
+ const sample: string[] = []
577
+ let tableFieldStats = ''
578
+ if (format === 'vector') {
579
+ stats = vectorStats(buf)
580
+ // 空窗口不得生成采样下标(否则 buf[0] undefined → 取数崩溃)
581
+ const idx = buf.length > 0 ? [...new Set([0, Math.floor((buf.length - 1) / 2), buf.length - 1])].slice(0, 3) : []
582
+ const vecField = dictionary.find(f => f.kind === 'vector' || (f.points?.length ?? 0) > 0)
583
+ const pointLabel = (i: number): string => {
584
+ const p = vecField?.points?.[i]
585
+ return p?.label ?? p?.field ?? `v${i}`
586
+ }
587
+ for (const i of idx) {
588
+ const r = buf[i]!
589
+ const vs = r.values ?? []
590
+ const m = vs.length > 0 ? vs.reduce((a, b) => a + b, 0) / vs.length : NaN
591
+ const valuesTxt = includeData && vs.length > 0
592
+ ? `,values=[${vs.slice(0, 64).map((v, j) => `${pointLabel(j)}=${Number(v.toFixed(4))}`).join(',')}${vs.length > 64 ? ',…' : ''}]`
593
+ : ''
594
+ sample.push(`${shortTs(r.ts)},dim=${vs.length},mean=${fmtN(m)},min=${fmtN(vs.length ? Math.min(...vs) : NaN)},max=${fmtN(vs.length ? Math.max(...vs) : NaN)}${valuesTxt}`)
595
+ }
596
+ }
597
+ else if (format === 'image') {
598
+ stats = { count: buf.length, min: null, max: null, mean: null, stddev: null, firstTs: buf[0]?.ts ?? null, lastTs: buf[buf.length - 1]?.ts ?? null }
599
+ // 图像 base64 永不进 prompt:自动落盘(≤20 帧),采样给文件名
600
+ const saved: MesHookArtifact[] = []
601
+ for (const [i, r] of buf.entries()) {
602
+ if (typeof r.data !== 'string') continue
603
+ if (saved.length >= IMAGE_AUTOSAVE_MAX) break
604
+ const a = saveMesImageArtifact(node.id, `frame-${String(i).padStart(4, '0')}`, r.data, r.mime ?? 'image/png')
605
+ if (a) saved.push(a)
606
+ }
607
+ const idx = buf.length > 0 ? [...new Set([0, Math.floor((buf.length - 1) / 2), buf.length - 1])].slice(0, 3) : []
608
+ for (const i of idx) {
609
+ const r = buf[i]!
610
+ const kb = r.data ? Math.round(r.data.length * 3 / 4 / 1024) : 0
611
+ const f = saved.find(x => x.name.includes(`frame-${String(i).padStart(4, '0')}`))
612
+ sample.push(`${shortTs(r.ts)},${r.mime ?? 'image/png'},~${kb}KB${f ? ` → ${f.name}` : ''}`)
613
+ }
614
+ autosaved = saved
615
+ }
616
+ else if (format === 'table' || format === 'event') {
617
+ stats = { count: buf.length, min: null, max: null, mean: null, stddev: null, firstTs: buf[0]?.ts ?? null, lastTs: buf[buf.length - 1]?.ts ?? null }
618
+ const idx = buf.length > 0 ? [...new Set([0, Math.floor((buf.length - 1) / 2), buf.length - 1])].slice(0, 3) : []
619
+ for (const i of idx) {
620
+ const r = buf[i]!
621
+ let body: string
622
+ try {
623
+ body = JSON.stringify(r.record)
624
+ }
625
+ catch {
626
+ body = '(不可序列化)'
627
+ }
628
+ sample.push(`${shortTs(r.ts)},${clip(body ?? '', 120)}`)
629
+ }
630
+ // map/多参数行:逐数值字段统计(最多 12 个字段),让 Agent 不必只看 3 行采样
631
+ const cols = new Map<string, number[]>()
632
+ for (const r of buf) {
633
+ if (r.record === null || typeof r.record !== 'object' || Array.isArray(r.record)) continue
634
+ for (const [k, v] of Object.entries(r.record as Record<string, unknown>)) {
635
+ if (v === null || v === '' || typeof v === 'boolean') continue
636
+ const n = Number(v)
637
+ if (!Number.isFinite(n)) continue
638
+ const arr = cols.get(k) ?? []
639
+ arr.push(n)
640
+ cols.set(k, arr)
641
+ }
642
+ }
643
+ const fieldLines = [...cols.entries()].slice(0, 12).map(([k, vs]) => {
644
+ const mean = vs.reduce((a, b) => a + b, 0) / vs.length
645
+ const def = dictionary.find(f => f.field === k)
646
+ const label = def?.label ? `${def.label}(${k})` : k
647
+ const unit = def?.unit ? ` ${def.unit}` : ''
648
+ return `${label}: n=${vs.length} min=${fmtN(Math.min(...vs))} max=${fmtN(Math.max(...vs))} mean=${fmtN(mean)}${unit}`
649
+ })
650
+ if (fieldLines.length > 0) {
651
+ tableFieldStats = ` 数值字段统计(${cols.size} 个字段${cols.size > 12 ? ',显示前12' : ''}): ${fieldLines.join(' | ')}`
652
+ }
653
+ }
654
+ else {
655
+ const values = buf.map(r => r.value).filter((v): v is number => Number.isFinite(v))
656
+ stats = statsOf(values, buf[0]?.ts ?? null, buf[buf.length - 1]?.ts ?? null)
657
+ const idx = buf.length > 0 ? [...new Set([0, Math.floor((buf.length - 1) / 2), buf.length - 1])].slice(0, 3) : []
658
+ for (const i of idx) sample.push(`${shortTs(buf[i]!.ts)},${fmtN(buf[i]!.value ?? NaN)}${includeData ? ` (value=${buf[i]!.value ?? '-'})` : ''}`)
659
+ }
660
+
661
+ const fmtLabel = format === 'scalar' ? `标量` : format === 'vector' ? `向量(dim=${stats.dim ?? '?'})` : format === 'image' ? `图像(${(buf[0]?.mime as string) ?? 'image/png'})` : format === 'table' ? `表格记录` : `事件记录`
662
+ const statLine = format === 'scalar'
663
+ ? ` 统计:min ${fmtN(stats.min)} / max ${fmtN(stats.max)} / mean ${fmtN(stats.mean)} / stddev ${fmtN(stats.stddev)} ${node.unit}`
664
+ : format === 'vector'
665
+ ? ` 统计(按行均值):min ${fmtN(stats.min)} / max ${fmtN(stats.max)} / mean ${fmtN(stats.mean)} / stddev ${fmtN(stats.stddev)} ${node.unit};全体元素均值 ${fmtN(stats.elementMean ?? NaN)}${stats.dimMismatch ? `;维度漂移 ${stats.dimMismatch} 行` : ''}`
666
+ : ` 统计:${stats.count} 条记录(非数值格式不做均值)`
667
+ const dictText = formatDictionary(dictionary)
668
+ const text = [
669
+ `■ ${node.name}(id=${node.id})[格式 ${fmtLabel};节点单位 ${node.unit || '-'};量程 ${node.min}~${node.max}]`,
670
+ ` 行数 ${stats.count}${truncated ? `(截断:${memoryHit || '达到 maxRows 上限'})` : '(完整)'} | 首 ${shortTs(stats.firstTs)} ~ 末 ${shortTs(stats.lastTs)}`,
671
+ statLine,
672
+ sample.length > 0 ? ` 采样(≤3 行): ${sample.join(' | ')}` : ' 采样:无有效行',
673
+ ...(tableFieldStats ? [tableFieldStats] : []),
674
+ ...(dictText ? [dictText] : []),
675
+ ].join('\n')
676
+
677
+ // dataHook 下沉处理(用户配置的 (param, data, ctx) => {...})
678
+ let hookText: string | undefined
679
+ const artifacts: MesHookArtifact[] = [...(autosaved as MesHookArtifact[])]
680
+ const hookCode = mesDataHookCode(cfg)
681
+ if (hookCode) {
682
+ const hookData: MesHookData = {
683
+ node: { id: node.id, name: node.name, lineId: node.lineId, unit: node.unit },
684
+ format,
685
+ rows: buf,
686
+ window: { from, to },
687
+ }
688
+ try {
689
+ const outcome = await runMesDataHook(hookCode, param, hookData, { nodeId: node.id })
690
+ if (outcome.ok) {
691
+ artifacts.push(...outcome.artifacts)
692
+ const parts = [` 钩子(dataHook):已执行,产物 ${outcome.artifacts.length} 个`]
693
+ if (outcome.summary) parts.push(` 处理摘要: ${outcome.summary}`)
694
+ if (outcome.context) parts.push(` 处理说明: ${outcome.context}`)
695
+ if (outcome.logs.length > 0) parts.push(` hook 日志(≤3): ${outcome.logs.slice(0, 3).join(' / ')}`)
696
+ hookText = parts.join('\n')
697
+ }
698
+ else {
699
+ hookText = ` 钩子(dataHook)执行失败:${outcome.error ?? '未知原因'}(统计仍基于原始数据)`
700
+ }
701
+ }
702
+ catch (err) {
703
+ hookText = ` 钩子(dataHook)执行失败:${err instanceof Error ? err.message : String(err)}`
704
+ }
705
+ }
706
+
707
+ // 产物行(hook 之外含自动落盘图像)
708
+ if (artifacts.length > 0) {
709
+ const shown = artifacts.slice(0, 8).map(a => `${a.name}(${Math.max(1, Math.round(a.bytes / 1024))}KB)`)
710
+ hookText = `${hookText ?? ''}\n 产物(${artifacts.length}${artifacts.length > 8 ? ',显示前8' : ''}): ${shown.join(' | ')}`
711
+ }
712
+ return { text, stats, truncated, sample, hookText, artifacts }
713
+ }
714
+
715
+ /**
716
+ * 取数编排(护栏全代码级):
717
+ * 授权过滤 → 窗口/行数归一 → 频次限流 → 快照 / 内联 / 异步三模式。
718
+ */
719
+ async function fetch(agentId: string, args: MesFetchArgs): Promise<MesFetchOutcome> {
720
+ // ① 授权:ids 必须是调用者可见(绑线)的 mes-rest 节点
721
+ const vis = await resolveVisibleIds(agentId, args.ids)
722
+ if (!vis.ok) return { text: vis.text, isError: true }
723
+ // ② 窗口/行数护栏
724
+ const win = normalizeWindow(args)
725
+ if (!win.ok) return { text: win.text, isError: true }
726
+ // ③ 频次限流(每 agent 每 60s ≤6 次)
727
+ if (!mesFetchRateCheck(agentId, d.nowMs())) {
728
+ return { text: `取数过于频繁:每 60 秒最多 ${MES_RATE_MAX_CALLS} 次。请先消化已有结果,稍后再取。`, isError: true }
729
+ }
730
+ // ④ 格式门控:image/table/event 的原文(帧/记录)不进 prompt 也不落 CSV 数据集,
731
+ // 只支持内联行数(≤MES_SYNC_INLINE_MAX_ROWS);大窗口请拆小分批
732
+ if (win.maxRows > MES_SYNC_INLINE_MAX_ROWS) {
733
+ const INLINE_ONLY = new Set(['image', 'table', 'event'])
734
+ const hits = vis.nodes.filter(n => INLINE_ONLY.has(historyFormatOf(n.driverConfig as Record<string, unknown>)))
735
+ if (hits.length > 0) {
736
+ return {
737
+ text: `行数上限冲突:${hits.map(n => `${n.name}(${n.id})`).join(', ')} 是 图像/表格/事件 格式点位,只在 max_rows ≤ ${MES_SYNC_INLINE_MAX_ROWS} 的内联模式支持(原文不落 CSV 数据集)。请缩小时间窗或调低 max_rows 后重取。`,
738
+ isError: true,
739
+ }
740
+ }
741
+ }
742
+
743
+ // 模式一:当前值快照(无 from/to)
744
+ if (!win.from || !win.to) {
745
+ const lines: string[] = []
746
+ for (const node of vis.nodes) {
747
+ const driver = d.resolveDriver(node.driver)
748
+ try {
749
+ if (typeof driver.read !== 'function') {
750
+ lines.push(`- ${node.name}(${node.id}):驱动 ${node.driver} 不支持读取`)
751
+ continue
752
+ }
753
+ const r = await driver.read({ domain: { min: node.min, max: node.max }, driverConfig: node.driverConfig })
754
+ const at = new Date(d.nowMs()).toISOString()
755
+ if (r.dictionary && r.dictionary.length > 0) cacheDictionary(node.id, r.dictionary)
756
+ const dict = r.dictionary && r.dictionary.length > 0 ? r.dictionary : mesDictionaryOfNode(node.id, node.driverConfig as Record<string, unknown>)
757
+ lines.push(r.ok && r.eng != null
758
+ ? `- ${node.name}(${node.id}):${fmtN(r.eng)}${node.unit} @ ${shortTs(at)}${dict.length > 0 ? `\n${formatDictionary(dict, ' ')}` : ''}`
759
+ : `- ${node.name}(${node.id}):读取失败(${r.message.slice(0, 80)})`)
760
+ }
761
+ catch (err) {
762
+ lines.push(`- ${node.name}(${node.id}):读取异常(${(err instanceof Error ? err.message : String(err)).slice(0, 80)})`)
763
+ }
764
+ }
765
+ return {
766
+ mode: 'snapshot',
767
+ text: `MES 当前值快照(${vis.nodes.length} 个点位,内联直读):\n${lines.join('\n')}\n\n说明:当前值为直读快照;历史窗口用 mes_fetch 带 from/to(≤7 天,max_rows≤${MES_MAX_ROWS_CAP})。`,
768
+ }
769
+ }
770
+
771
+ // 模式二:同步内联(行数 ≤ MES_SYNC_INLINE_MAX_ROWS;格式感知+dataHook 下沉)
772
+ if (win.maxRows <= MES_SYNC_INLINE_MAX_ROWS) {
773
+ const sections: string[] = []
774
+ const statsOut: NonNullable<MesFetchOutcome['data']>['stats'] = []
775
+ for (const node of vis.nodes) {
776
+ try {
777
+ const one = await inlineFetchNode(node, win.from, win.to, win.maxRows, args.param, args.include_data === true || args.include_data === 'true')
778
+ sections.push(one.hookText ? `${one.text}\n${one.hookText}` : one.text)
779
+ statsOut.push({ nodeId: node.id, stats: one.stats, truncated: one.truncated })
780
+ }
781
+ catch (err) {
782
+ sections.push(`■ ${node.name}(id=${node.id})\n 取数失败:${err instanceof Error ? err.message : String(err)}`)
783
+ }
784
+ }
785
+ return {
786
+ mode: 'inline',
787
+ text: `MES 历史取数(内联同步,${vis.nodes.length} 个点位,窗口 ${shortTs(win.from)} ~ ${shortTs(win.to)}):\n${sections.join('\n')}\n\n说明:以上为统计摘要与 ≤3 行采样;MES 原文不进入对话。向量/图像/记录点位按各自格式呈现,已配置数据钩子(dataHook)的点位会附处理摘要与产物清单(文件落 <数据根>/mes-artifacts/<点位id>/)。需要标量/向量全量行请用更大 max_rows(> ${MES_SYNC_INLINE_MAX_ROWS})走异步数据集,再用 mes_dataset_read 读。`,
788
+ data: { stats: statsOut },
789
+ }
790
+ }
791
+
792
+ // 模式三:异步数据集(行数 > MES_SYNC_INLINE_MAX_ROWS;进程内异步,绝不进调度循环;
793
+ // requestHook 覆盖在此同样生效——合并进作业用的 driverConfig)
794
+ const jobIds: string[] = []
795
+ const datasetIds: string[] = []
796
+ const lines: string[] = []
797
+ for (const node of vis.nodes) {
798
+ let effCfg: Record<string, unknown>
799
+ try {
800
+ effCfg = await configWithRequestHook(node, args.param)
801
+ }
802
+ catch (err) {
803
+ lines.push(`- ${node.name}(${node.id}):requestHook 失败,作业未创建(${err instanceof Error ? err.message : String(err)})`)
804
+ continue
805
+ }
806
+ const run = node.lineId ? getActiveLineRun(node.lineId) : null
807
+ const { jobId, datasetId } = d.store.createFetchJob({
808
+ nodeId: node.id,
809
+ fromIso: win.from,
810
+ toIso: win.to,
811
+ maxRows: win.maxRows,
812
+ agentId,
813
+ lineId: node.lineId,
814
+ nodeName: node.name,
815
+ driverConfig: effCfg,
816
+ dictionary: mesDictionaryOfNode(node.id, node.driverConfig as Record<string, unknown>),
817
+ nodeMeta: {
818
+ unit: node.unit,
819
+ min: node.min,
820
+ max: node.max,
821
+ description: String(node.driverConfig.desc ?? ''),
822
+ semantics: String(node.driverConfig.semantics ?? ''),
823
+ format: historyFormatOf(node.driverConfig as Record<string, unknown>),
824
+ },
825
+ context: run
826
+ ? { lineId: run.lineId, productId: run.productId, recipeId: run.recipeId, runId: run.runId }
827
+ : { lineId: node.lineId },
828
+ })
829
+ jobIds.push(jobId)
830
+ datasetIds.push(datasetId)
831
+ lines.push(`- ${node.name}(${node.id}):job_id=${jobId} dataset_id=${datasetId} status=running`)
832
+ }
833
+ return {
834
+ mode: 'async',
835
+ text: `已创建 ${lines.length} 个异步取数作业(窗口 ${shortTs(win.from)} ~ ${shortTs(win.to)},max_rows=${win.maxRows}):\n${lines.join('\n')}\n\n勿轮询;未完成先做别的,用 mes_datasets 查状态,完成后 mes_dataset_read(dataset_id, mode=stats/rows) 读内容。`,
836
+ data: { job_ids: jobIds, dataset_ids: datasetIds },
837
+ }
838
+ }
839
+
840
+ // ---------- 离线导出(指定目录 + manifest/README 语义清单) ----------
841
+
842
+ /** 安全子路径:只允许落在 root 内(拒绝 ../、绝对路径逃逸、盘符切换) */
843
+ function resolveUnderRoot(root: string, folder: string, fallback: string): { ok: true, dir: string } | { ok: false, text: string } {
844
+ const base = resolve(root)
845
+ const raw = String(folder ?? '').trim()
846
+ if (!raw) return { ok: true, dir: join(base, fallback) }
847
+ const target = resolve(base, raw)
848
+ if (target !== base && !target.startsWith(`${base}${sep}`)) {
849
+ return {
850
+ ok: false,
851
+ text: `导出目录被拒:folder=${raw} 越出允许根目录 ${base}(只接受相对路径;如需自定义根目录,请由管理员设置环境变量 AW_MES_EXPORT_ROOT)。`,
852
+ }
853
+ }
854
+ return { ok: true, dir: target }
855
+ }
856
+
857
+ function safeSeg(value: string): string {
858
+ return value.replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 80) || 'node'
859
+ }
860
+
861
+ function writeChunk(fd: number, text: string): void {
862
+ const buf = Buffer.from(text, 'utf8')
863
+ let off = 0
864
+ while (off < buf.length) off += writeSync(fd, buf, off, buf.length - off)
865
+ }
866
+
867
+ /**
868
+ * 把可见 MES 点位的历史原样导出到目录(流式写盘):
869
+ * scalar → data.csv(ts,value)
870
+ * vector → data.csv(宽表 ts,v0..vN)+ manifest 里的逐点语义
871
+ * image → frames.jsonl(元数据)+ frames/*.png
872
+ * table/event → records.jsonl
873
+ * 每个导出目录都写 manifest.json + README.md(字段含义/单位/量程/产线批次上下文),
874
+ * Agent 与离线分析器都能直接读懂,不需要回读平台。
875
+ */
876
+ async function exportData(agentId: string, args: MesExportArgs): Promise<MesToolResult & { dir?: string, manifestPath?: string, rows?: number }> {
877
+ const vis = await resolveVisibleIds(agentId, args.ids)
878
+ if (!vis.ok) return { text: vis.text, isError: true }
879
+ const from = String(args.from ?? '').trim()
880
+ const to = String(args.to ?? '').trim()
881
+ if (!from || !to) return { text: 'mes_export 需要 from/to(ISO)历史窗口;当前值快照请用 mes_fetch。', isError: true }
882
+ const fromMs = Date.parse(from)
883
+ const toMs = Date.parse(to)
884
+ if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) return { text: 'from/to 必须是合法 ISO 时间戳。', isError: true }
885
+ if (fromMs >= toMs) return { text: `时间窗无效:from(${from}) 必须早于 to(${to})。`, isError: true }
886
+ if (toMs - fromMs > MES_WINDOW_MAX_MS) {
887
+ return { text: `时间窗被拒:超过 7 天上限。请拆成 ≤7 天的分段导出。`, isError: true }
888
+ }
889
+ const rawMax = args.max_rows == null || args.max_rows === '' ? MES_MAX_ROWS_CAP : Math.round(Number(args.max_rows))
890
+ if (!Number.isFinite(rawMax) || rawMax < 1) return { text: 'max_rows 必须为 ≥1 的整数。', isError: true }
891
+ const maxRows = Math.min(rawMax, MES_EXPORT_MAX_ROWS)
892
+ if (!mesFetchRateCheck(agentId, d.nowMs())) {
893
+ return { text: `导出过于频繁:每 60 秒最多 ${MES_RATE_MAX_CALLS} 次。请稍后再试。`, isError: true }
894
+ }
895
+
896
+ const root = process.env.AW_MES_EXPORT_ROOT
897
+ ? resolve(process.env.AW_MES_EXPORT_ROOT)
898
+ : join(ensureDataDir(), 'mes-exports')
899
+ const exportId = `mesexp-${new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14)}-${randomUUID().slice(0, 6)}`
900
+ const where = resolveUnderRoot(root, String(args.folder ?? ''), exportId)
901
+ if (!where.ok) return { text: where.text, isError: true }
902
+ const dir = where.dir
903
+ mkdirSync(dir, { recursive: true })
904
+
905
+ const title = String(args.title ?? '').trim() || `MES 数据导出 ${exportId}`
906
+ const note = String(args.note ?? '').trim()
907
+ const manifestNodes: Array<Record<string, unknown>> = []
908
+ const failures: string[] = []
909
+ const scalarFiles: Array<{ nodeName: string, nodeId: string, file: string }> = []
910
+ let totalRows = 0
911
+
912
+ for (const node of vis.nodes) {
913
+ const cfg = node.driverConfig as Record<string, unknown>
914
+ const format = historyFormatOf(cfg)
915
+ const nodeDir = join(dir, safeSeg(node.id))
916
+ try {
917
+ mkdirSync(nodeDir, { recursive: true })
918
+ const driver = d.resolveDriver(node.driver)
919
+ if (typeof driver.fetchHistory !== 'function') {
920
+ failures.push(`${node.name}(${node.id}):驱动 ${node.driver} 无历史原语`)
921
+ continue
922
+ }
923
+ const effCfg = await configWithRequestHook(node, args.param)
924
+ const run = node.lineId ? getActiveLineRun(node.lineId) : null
925
+ let dictionary = mesDictionaryOfNode(node.id, cfg)
926
+ let rows = 0
927
+ let truncated = false
928
+ let dim = 0
929
+ let dimDrift = 0
930
+ let skipped = 0
931
+ let frameSaved = 0
932
+ let frameSkipped = 0
933
+ let fd: number | null = null
934
+ let headerWritten = false
935
+ let columns: string[] = []
936
+ let fileRel = ''
937
+ const jsonl: string[] = []
938
+
939
+ if (format === 'image') {
940
+ mkdirSync(join(nodeDir, 'frames'), { recursive: true })
941
+ }
942
+ else {
943
+ fd = openSync(join(nodeDir, format === 'table' || format === 'event' ? 'records.jsonl' : 'data.csv'), 'w')
944
+ }
945
+
946
+ const result = await driver.fetchHistory({
947
+ driverConfig: effCfg,
948
+ fromIso: from,
949
+ toIso: to,
950
+ maxRows,
951
+ onRows: (batch) => {
952
+ if (!Array.isArray(batch)) return
953
+ for (const r of batch) {
954
+ if (rows >= maxRows) {
955
+ truncated = true
956
+ break
957
+ }
958
+ const ts = String(r?.ts ?? '')
959
+ if (format === 'vector') {
960
+ if (!Array.isArray(r?.values) || r.values.length === 0) {
961
+ skipped++
962
+ continue
963
+ }
964
+ if (!headerWritten) {
965
+ dim = r.values.length
966
+ columns = ['ts', ...Array.from({ length: dim }, (_, i) => `v${i}`)]
967
+ writeChunk(fd!, `${columns.join(',')}\r\n`)
968
+ headerWritten = true
969
+ }
970
+ if (r.values.length !== dim) dimDrift++
971
+ const cells = [ts]
972
+ for (let i = 0; i < dim; i++) {
973
+ const v = r.values[i]
974
+ cells.push(Number.isFinite(v) ? String(v) : '')
975
+ }
976
+ writeChunk(fd!, `${cells.join(',')}\r\n`)
977
+ rows++
978
+ continue
979
+ }
980
+ if (format === 'image') {
981
+ if (typeof r?.data !== 'string' || r.data.trim() === '') {
982
+ skipped++
983
+ continue
984
+ }
985
+ if (frameSaved >= MES_EXPORT_MAX_FRAMES) {
986
+ frameSkipped++
987
+ truncated = true
988
+ continue
989
+ }
990
+ const mime = typeof r.mime === 'string' && r.mime.includes('/') ? r.mime : 'image/png'
991
+ const ext = mime.includes('jpeg') ? 'jpg' : mime.includes('webp') ? 'webp' : 'png'
992
+ const name = `frames/${String(frameSaved).padStart(5, '0')}-${ts.replace(/[:.]/g, '-')}.${ext}`
993
+ try {
994
+ writeFileSync(join(nodeDir, name), Buffer.from(r.data, 'base64'))
995
+ jsonl.push(JSON.stringify({ ts, mime, file: name, ...(r.record !== null && typeof r.record === 'object' ? { record: r.record } : {}) }))
996
+ frameSaved++
997
+ rows++
998
+ }
999
+ catch (imgErr) {
1000
+ skipped++
1001
+ jsonl.push(JSON.stringify({ ts, mime, error: imgErr instanceof Error ? imgErr.message : String(imgErr) }))
1002
+ }
1003
+ continue
1004
+ }
1005
+ if (format === 'table' || format === 'event') {
1006
+ if (r?.record === null || r?.record === undefined) {
1007
+ skipped++
1008
+ continue
1009
+ }
1010
+ jsonl.push(JSON.stringify({ ts, record: r.record }))
1011
+ rows++
1012
+ continue
1013
+ }
1014
+ if (typeof r?.value !== 'number' || !Number.isFinite(r.value)) {
1015
+ skipped++
1016
+ continue
1017
+ }
1018
+ if (!headerWritten) {
1019
+ columns = ['ts', 'value']
1020
+ writeChunk(fd!, `${columns.join(',')}\r\n`)
1021
+ headerWritten = true
1022
+ }
1023
+ writeChunk(fd!, `${ts},${r.value}\r\n`)
1024
+ rows++
1025
+ }
1026
+ },
1027
+ })
1028
+ if (result?.dictionary && result.dictionary.length > 0) {
1029
+ dictionary = result.dictionary
1030
+ cacheDictionary(node.id, dictionary)
1031
+ }
1032
+ if (result && result.complete === false) truncated = true
1033
+ if (format === 'image' || format === 'table' || format === 'event') {
1034
+ writeFileSync(join(nodeDir, 'records.jsonl'), `${jsonl.join('\n')}${jsonl.length > 0 ? '\n' : ''}`, 'utf8')
1035
+ fileRel = `${safeSeg(node.id)}/records.jsonl`
1036
+ }
1037
+ else {
1038
+ if (!headerWritten) {
1039
+ columns = format === 'vector' ? ['ts'] : ['ts', 'value']
1040
+ writeChunk(fd!, `${columns.join(',')}\r\n`)
1041
+ headerWritten = true
1042
+ }
1043
+ fileRel = `${safeSeg(node.id)}/data.csv`
1044
+ }
1045
+ if (fd != null) {
1046
+ closeSync(fd)
1047
+ fd = null
1048
+ }
1049
+ if (format === 'scalar') scalarFiles.push({ nodeName: node.name, nodeId: node.id, file: fileRel })
1050
+ totalRows += rows
1051
+ manifestNodes.push({
1052
+ id: node.id,
1053
+ name: node.name,
1054
+ line_id: node.lineId,
1055
+ format,
1056
+ unit: node.unit,
1057
+ range: { min: node.min, max: node.max },
1058
+ description: String(cfg.desc ?? ''),
1059
+ semantics: String(cfg.semantics ?? ''),
1060
+ file: fileRel,
1061
+ columns,
1062
+ rows,
1063
+ ...(format === 'vector' ? { vector: { dim, dimension_drift_rows: dimDrift } } : {}),
1064
+ ...(format === 'image' ? { frames: { saved: frameSaved, skipped: frameSkipped } } : {}),
1065
+ skipped_rows: skipped,
1066
+ truncated,
1067
+ fields: dictionary,
1068
+ context: run ? { line_id: run.lineId, product_id: run.productId, recipe_id: run.recipeId, run_id: run.runId } : { line_id: node.lineId },
1069
+ })
1070
+ }
1071
+ catch (err) {
1072
+ failures.push(`${node.name}(${node.id}):${err instanceof Error ? err.message : String(err)}`)
1073
+ }
1074
+ }
1075
+
1076
+ // 多标量节点按时间对齐的宽表(默认生成;纯时间戳交集,不做插值)
1077
+ let mergedFile: string | null = null
1078
+ const mergeEnabled = !(args.merge === false || args.merge === 'false')
1079
+ if (mergeEnabled && scalarFiles.length > 1) {
1080
+ try {
1081
+ const series = scalarFiles.map((s) => {
1082
+ const map = new Map<string, number>()
1083
+ const raw = readFileSync(join(dir, s.file), 'utf8')
1084
+ for (const line of raw.split(/\r?\n/).slice(1)) {
1085
+ const [ts, v] = line.split(',')
1086
+ if (ts && v !== undefined && Number.isFinite(Number(v))) map.set(ts, Number(v))
1087
+ }
1088
+ return { ...s, map }
1089
+ })
1090
+ const times = [...new Set(series.flatMap(s => [...s.map.keys()]))].sort()
1091
+ const header = ['time', ...series.map(s => `${s.nodeName}(${s.nodeId})`)]
1092
+ const lines = [header.join(',')]
1093
+ for (const ts of times) lines.push([ts, ...series.map(s => s.map.get(ts) ?? '')].join(','))
1094
+ writeFileSync(join(dir, 'merged.csv'), `${lines.join('\n')}\n`, 'utf8')
1095
+ mergedFile = join(dir, 'merged.csv')
1096
+ }
1097
+ catch { /* merge 失败不影响单节点导出 */ }
1098
+ }
1099
+
1100
+ const manifest = {
1101
+ schema: 'aw.mes-export/1',
1102
+ export_id: exportId,
1103
+ created_at: new Date().toISOString(),
1104
+ title,
1105
+ note,
1106
+ window: { from, to, from_ms: fromMs, to_ms: toMs },
1107
+ directory: dir,
1108
+ nodes: manifestNodes,
1109
+ merged_file: mergedFile,
1110
+ totals: { nodes: manifestNodes.length, rows: totalRows, failed_nodes: failures.length },
1111
+ usage: 'data.csv 首行为列名(ts=时间,v0..vN=向量点位);records.jsonl 每行一条记录;image 格式的像素在 frames/ 下,records.jsonl 是对应元数据。字段含义/单位/量程见 nodes[].fields(向量逐点语义在 fields[].points);批次归属见 nodes[].context。',
1112
+ }
1113
+ const manifestPath = join(dir, 'manifest.json')
1114
+ writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8')
1115
+
1116
+ const readme: string[] = [
1117
+ `# ${title}`,
1118
+ '',
1119
+ `- 导出时间: ${new Date().toISOString()}`,
1120
+ `- 时间窗: ${from} ~ ${to}`,
1121
+ `- 导出目录: ${dir}`,
1122
+ `- 说明: ${note || '(无)'}`,
1123
+ '',
1124
+ '## 文件与字段',
1125
+ '',
1126
+ ]
1127
+ for (const n of manifestNodes) {
1128
+ readme.push(`### ${String(n.name)} (${String(n.id)})`)
1129
+ readme.push(`- 格式: ${String(n.format)};文件: ${String(n.file)};行数: ${String(n.rows)}`)
1130
+ readme.push(`- 单位: ${String(n.unit || '-')};量程: ${JSON.stringify(n.range)}`)
1131
+ if (n.semantics) readme.push(`- 物理意义: ${String(n.semantics)}`)
1132
+ const fields = Array.isArray(n.fields) ? n.fields as DcwFieldDef[] : []
1133
+ const dict = formatDictionary(fields, ' ')
1134
+ if (dict) readme.push(dict)
1135
+ readme.push('')
1136
+ }
1137
+ if (mergedFile) readme.push(`多参数对齐宽表: ${mergedFile}(列名=节点名(节点id);仅对齐相同时间戳,不插值)`, '')
1138
+ if (failures.length > 0) readme.push('## 失败节点', '', ...failures.map(f => `- ${f}`), '')
1139
+ writeFileSync(join(dir, 'README.md'), `${readme.join('\n')}\n`, 'utf8')
1140
+
1141
+ const lines = manifestNodes.map(n => `- ${String(n.name)}(${String(n.id)}) [${String(n.format)}] ${String(n.rows)} 行 → ${String(n.file)}`)
1142
+ const failText = failures.length > 0 ? `\n失败节点(${failures.length}):\n${failures.map(f => ` - ${f}`).join('\n')}` : ''
1143
+ return {
1144
+ isError: failures.length > 0,
1145
+ dir,
1146
+ manifestPath,
1147
+ rows: totalRows,
1148
+ text: `MES 数据已导出(${manifestNodes.length}/${vis.nodes.length} 个点位,共 ${totalRows} 行):\n${lines.join('\n')}${mergedFile ? `\n- 多参数宽表: ${mergedFile}` : ''}${failText}\n\n目录: ${dir}\n语义清单: ${manifestPath}\n说明: README.md\n\n离线分析请直接读取上述文件;在线继续取数用 mes_fetch/mes_dataset_read。`,
1149
+ }
1150
+ }
1151
+
1152
+ return { catalog, fetch, exportData }
1153
+ }
1154
+
1155
+ export type MesController = ReturnType<typeof createMesController>