agentworkshop 0.7.38 → 0.7.40
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.
- package/.AgentWorkShop/prompts/aml-mission-default.md +20 -20
- package/.AgentWorkShop/prompts/aml-playbook.md +49 -49
- package/.AgentWorkShop/prompts/host-tools.json +1293 -1238
- package/.AgentWorkShop/prompts/peer-reply-cross-channel.md +10 -10
- package/.output/.AgentWorkShop/prompts/aml-mission-default.md +20 -20
- package/.output/.AgentWorkShop/prompts/aml-playbook.md +49 -49
- package/.output/.AgentWorkShop/prompts/host-tools.json +1293 -1238
- package/.output/.AgentWorkShop/prompts/peer-reply-cross-channel.md +10 -10
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/88GOowgO2.js +1 -0
- package/.output/public/_nuxt/{BNT8gYU92.js → BC9wjTJK2.js} +2 -2
- package/.output/public/_nuxt/BOt2SP4z.js +1 -0
- package/.output/public/_nuxt/BP-NyKVG.js +18 -0
- package/.output/public/_nuxt/{HBLJ-wei.js → BXxH0UQE.js} +1 -1
- package/.output/public/_nuxt/{zIGh7R49.js → BneN7fbu.js} +1 -1
- package/.output/public/_nuxt/BsROmY89.js +1 -0
- package/.output/public/_nuxt/{C_OLzD09.js → C4oW1HsE.js} +1 -1
- package/.output/public/_nuxt/CFxtLwjp.js +1 -0
- package/.output/public/_nuxt/{Cec0Ua3F.js → CS50LB_l.js} +1 -1
- package/.output/public/_nuxt/C_iYD-EB.js +1 -0
- package/.output/public/_nuxt/{DAe0h2MB.js → ClILjvWH.js} +1 -1
- package/.output/public/_nuxt/CssgYAAL2.js +1 -0
- package/.output/public/_nuxt/{CY9LbPCI.js → CzOCSGLe.js} +1 -1
- package/.output/public/_nuxt/D8qvkfyY.js +1 -0
- package/.output/public/_nuxt/DCn7QZ5N.js +2 -0
- package/.output/public/_nuxt/DGIuvyRN2.js +1 -0
- package/.output/public/_nuxt/{CojCTLKD.js → DGj-WEBg.js} +1 -1
- package/.output/public/_nuxt/{DDShH71m.js → DS8qj8EL.js} +1 -1
- package/.output/public/_nuxt/DTFCy6h-.js +1 -0
- package/.output/public/_nuxt/{DrYV5i68.js → DUjW5Yq5.js} +1 -1
- package/.output/public/_nuxt/DZshyNLa.js +1 -0
- package/.output/public/_nuxt/{45zuyAso.js → D_OTvQza.js} +1 -1
- package/.output/public/_nuxt/DcsCcxp4.js +1 -0
- package/.output/public/_nuxt/{DUrecWPx.js → Dihnimlk.js} +2 -2
- package/.output/public/_nuxt/Dqw1lpr-.js +1 -0
- package/.output/public/_nuxt/{BG8sCcwx.js → Dr9v6C0f.js} +9 -9
- package/.output/public/_nuxt/{8NMOXZOV.js → Du9ZJtnj.js} +1 -1
- package/.output/public/_nuxt/TownView.f-YOdXRs.css +1 -0
- package/.output/public/_nuxt/_id_.CM4bIgKY.css +1 -0
- package/.output/public/_nuxt/_id_.bNV69Dtf.css +1 -0
- package/.output/public/_nuxt/_wsId_.B4WiqkIS.css +1 -0
- package/.output/public/_nuxt/agents.ZD0rVdHE.css +1 -0
- package/.output/public/_nuxt/aml.BN8ZEW4h.css +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/f4707884-7cf4-4a31-80d2-e3d72b73745f.json +1 -0
- package/.output/public/_nuxt/channel-templates.BOtahzPi.css +1 -0
- package/.output/public/_nuxt/daq.B0D3dPAc.css +1 -0
- package/.output/public/_nuxt/dcw.8Y7FqCVN.css +1 -0
- package/.output/public/_nuxt/default.J32SgqFY.css +1 -0
- package/.output/public/_nuxt/entry.bdm0tv6M.css +1 -0
- package/.output/public/_nuxt/logs.BpKzmKsh.css +1 -0
- package/.output/public/_nuxt/monitor.D9pe7qN6.css +1 -0
- package/.output/public/_nuxt/pages.D7aSDlUI.css +1 -0
- package/.output/public/_nuxt/permissions.DwTVlFe6.css +1 -0
- package/.output/public/_nuxt/plugins.sb4nDGqr.css +1 -0
- package/.output/public/_nuxt/{Cbq-mryP.js → qr6R6Ha1.js} +1 -1
- package/.output/public/_nuxt/settings.BTgR-NiE.css +1 -0
- package/.output/public/_nuxt/teams.CxnxKVVs.css +1 -0
- package/.output/public/_nuxt/tokens.BFY7qv4f.css +1 -0
- package/.output/public/_nuxt/{town.DKIAhKnx.css → town.BBXZmeoP.css} +1 -1
- package/.output/public/_nuxt/users.DLgZ1D0h.css +1 -0
- package/.output/public/_nuxt/workshop.CR_QzeAN.css +1 -0
- package/.output/public/_nuxt/{BzHEilTt.js → xh3_vYcu.js} +1 -1
- package/.output/public/_nuxt/yF0aYMF1.js +4 -0
- package/.output/server/chunks/_/entity.mjs.map +1 -1
- package/.output/server/chunks/_/nitro.mjs +2244 -1464
- package/.output/server/chunks/_/nitro.mjs.map +1 -1
- package/.output/server/chunks/build/{TownView-jVazYOjN.mjs → TownView-BuLAsmpR.mjs} +288 -206
- package/.output/server/chunks/build/TownView-BuLAsmpR.mjs.map +1 -0
- package/.output/server/chunks/build/{_id_-CfVosNg3.mjs → _id_-BU1wfOID.mjs} +138 -138
- package/.output/server/chunks/build/{_id_-CfVosNg3.mjs.map → _id_-BU1wfOID.mjs.map} +1 -1
- package/.output/server/chunks/build/{_id_-Hwr4rZpr.mjs → _id_-BYsEua57.mjs} +33 -32
- package/.output/server/chunks/build/_id_-BYsEua57.mjs.map +1 -0
- package/.output/server/chunks/build/{_wsId_-BVg3bB77.mjs → _wsId_-BxlDcJHg.mjs} +293 -259
- package/.output/server/chunks/build/{_wsId_-BVg3bB77.mjs.map → _wsId_-BxlDcJHg.mjs.map} +1 -1
- package/.output/server/chunks/build/{agents-Bvin73QY.mjs → agents-CLQqJF2y.mjs} +21 -27
- package/.output/server/chunks/build/agents-CLQqJF2y.mjs.map +1 -0
- package/.output/server/chunks/build/{aml-BCSJCdX7.mjs → aml-_7FdFL2p.mjs} +109 -109
- package/.output/server/chunks/build/{aml-BCSJCdX7.mjs.map → aml-_7FdFL2p.mjs.map} +1 -1
- package/.output/server/chunks/build/api-error-dul30BYQ.mjs.map +1 -1
- package/.output/server/chunks/build/{channel-templates-BTq8570n.mjs → channel-templates-p6SZNjlM.mjs} +19 -19
- package/.output/server/chunks/build/{channel-templates-BTq8570n.mjs.map → channel-templates-p6SZNjlM.mjs.map} +1 -1
- package/.output/server/chunks/build/{daq-C03Uu5UE.mjs → daq-cgyjKmJu.mjs} +188 -122
- package/.output/server/chunks/build/daq-cgyjKmJu.mjs.map +1 -0
- package/.output/server/chunks/build/{dcw-6vEYVeje.mjs → dcw-CoTxBlAZ.mjs} +45 -45
- package/.output/server/chunks/build/{dcw-6vEYVeje.mjs.map → dcw-CoTxBlAZ.mjs.map} +1 -1
- package/.output/server/chunks/build/{default-hseyOqBT.mjs → default-BE4r0FZN.mjs} +158 -79
- package/.output/server/chunks/build/{default-hseyOqBT.mjs.map → default-BE4r0FZN.mjs.map} +1 -1
- package/.output/server/chunks/build/{logs-B-xhuqln.mjs → logs-BSOeZwwI.mjs} +34 -34
- package/.output/server/chunks/build/{logs-B-xhuqln.mjs.map → logs-BSOeZwwI.mjs.map} +1 -1
- package/.output/server/chunks/build/{monitor-CyfDt4nR.mjs → monitor-C0okQaXz.mjs} +33 -33
- package/.output/server/chunks/build/{monitor-CyfDt4nR.mjs.map → monitor-C0okQaXz.mjs.map} +1 -1
- package/.output/server/chunks/build/{pages-BO7yZsXA.mjs → pages-DFxjn9Xa.mjs} +33 -17
- package/.output/server/chunks/build/pages-DFxjn9Xa.mjs.map +1 -0
- package/.output/server/chunks/build/{permissions-B52oOmaO.mjs → permissions-68SsNjex.mjs} +12 -12
- package/.output/server/chunks/build/{permissions-B52oOmaO.mjs.map → permissions-68SsNjex.mjs.map} +1 -1
- package/.output/server/chunks/build/{plugins-CUWmMdyt.mjs → plugins-lGlUr1lj.mjs} +17 -17
- package/.output/server/chunks/build/{plugins-CUWmMdyt.mjs.map → plugins-lGlUr1lj.mjs.map} +1 -1
- package/.output/server/chunks/build/{settings-DoQ2Oq3P.mjs → settings-Ddd1qx2Z.mjs} +50 -47
- package/.output/server/chunks/build/settings-Ddd1qx2Z.mjs.map +1 -0
- package/.output/server/chunks/build/{teams-2kz3CusY.mjs → teams-MEDLZdMn.mjs} +38 -34
- package/.output/server/chunks/build/teams-MEDLZdMn.mjs.map +1 -0
- package/.output/server/chunks/build/{tokens-BbWLqtVz.mjs → tokens-C7fTM5C2.mjs} +14 -14
- package/.output/server/chunks/build/{tokens-BbWLqtVz.mjs.map → tokens-C7fTM5C2.mjs.map} +1 -1
- package/.output/server/chunks/build/{town-BOl6hs9B.mjs → town-qMPql9Se.mjs} +36 -10
- package/.output/server/chunks/build/town-qMPql9Se.mjs.map +1 -0
- package/.output/server/chunks/build/useDaqStream-CIBaiGAl.mjs +1 -1
- package/.output/server/chunks/build/useDcwStream-CBbiYnWe.mjs +1 -1
- package/.output/server/chunks/build/useResponsive-BKDMGTHs.mjs +49 -0
- package/.output/server/chunks/build/useResponsive-BKDMGTHs.mjs.map +1 -0
- package/.output/server/chunks/build/{users-fohSmF-J.mjs → users-Cfd5-l2-.mjs} +6 -6
- package/.output/server/chunks/build/{users-fohSmF-J.mjs.map → users-Cfd5-l2-.mjs.map} +1 -1
- package/.output/server/chunks/build/{workshop-DX5-ldc4.mjs → workshop-BL5bhfs0.mjs} +15 -15
- package/.output/server/chunks/build/{workshop-DX5-ldc4.mjs.map → workshop-BL5bhfs0.mjs.map} +1 -1
- package/.output/server/chunks/build/{workspaces-BuydxM-3.mjs → workspaces-Bgz5Ekwp.mjs} +18 -3
- package/.output/server/chunks/build/workspaces-Bgz5Ekwp.mjs.map +1 -0
- package/.output/server/chunks/routes/api/system/config-groups/_id_.patch.mjs.map +1 -1
- package/.output/server/chunks/routes/api/system/index.patch.mjs.map +1 -1
- package/.output/server/chunks/routes/api/system/index.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/system/settings/events.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/agent-tools/invoke.post.mjs +6 -2
- package/.output/server/chunks/routes/api/workshop/agent-tools/invoke.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/aml/datasets/_id_.get.mjs +2 -1
- package/.output/server/chunks/routes/api/workshop/aml/datasets/_id_.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/channel-templates/_id/instantiate.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/channels.post.mjs +3 -3
- package/.output/server/chunks/routes/api/workshop/daq/index.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.patch.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/_id/write.post.mjs +3 -2
- package/.output/server/chunks/routes/api/workshop/dcw/_id/write.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/_id_.delete.mjs +2 -1
- package/.output/server/chunks/routes/api/workshop/dcw/_id_.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index2.post.mjs +8 -6
- package/.output/server/chunks/routes/api/workshop/dcw/index2.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index3.post.mjs +5 -5
- package/.output/server/chunks/routes/api/workshop/dcw/index3.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index4.get.mjs +14 -4
- package/.output/server/chunks/routes/api/workshop/dcw/index4.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index4.post.mjs +4 -4
- package/.output/server/chunks/routes/api/workshop/dcw/index4.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index5.get.mjs +4 -3
- package/.output/server/chunks/routes/api/workshop/dcw/index5.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index5.post.mjs +31 -0
- package/.output/server/chunks/routes/api/workshop/dcw/index5.post.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/index6.get.mjs +28 -0
- package/.output/server/chunks/routes/api/workshop/dcw/index6.get.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/lines/_id_.patch.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id/read.post.mjs +32 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id/read.post.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id/write.post.mjs +34 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id/write.post.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.delete.mjs +33 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.delete.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.patch.mjs +34 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.patch.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.delete.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.patch.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/harnesses/_id/providers.get.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/harnesses.get.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/hitl/pending.get.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/hitl/respond.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/index.put.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/index6.get.mjs +2 -0
- package/.output/server/chunks/routes/api/workshop/index6.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/index9.get.mjs +3 -1
- package/.output/server/chunks/routes/api/workshop/index9.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/plugins/_name/disable.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/plugins/_name/enable.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.delete.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.put.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/workspaces/_id/channel-templates/_tplId_.post.mjs +1 -1
- package/.output/server/chunks/routes/renderer.mjs +3 -3
- package/.output/server/chunks/virtual/entry.mjs +53 -25
- package/.output/server/chunks/virtual/precomputed.mjs +1 -1
- package/.output/server/package.json +1 -1
- package/README-zh.md +204 -40
- package/README.md +739 -591
- package/app/app.vue +9 -3
- package/app/assets/css/main.css +517 -7
- package/app/components/AppHeader.vue +98 -24
- package/app/components/AppSidebar.vue +118 -11
- package/app/components/AwChart.vue +2 -1
- package/app/components/workshop/AgentInspectorDrawer.vue +6 -6
- package/app/components/workshop/AgentLanesView.vue +52 -1
- package/app/components/workshop/AssetLibrary.vue +4 -2
- package/app/components/workshop/ChannelSessionList.vue +4 -2
- package/app/components/workshop/Composer.vue +96 -0
- package/app/components/workshop/DaqNodeRow.vue +19 -0
- package/app/components/workshop/DaqTemplateIcon.vue +33 -0
- package/app/components/workshop/DeviceTwinPanel.vue +37 -35
- package/app/components/workshop/EventBlock.vue +3 -3
- package/app/components/workshop/InspectorPanel.vue +47 -11
- package/app/components/workshop/LiveAgentBar.vue +34 -0
- package/app/components/workshop/TaskBoardView.vue +83 -33
- package/app/components/workshop/TranscriptTimeline.vue +56 -0
- package/app/components/workshop/blocks/ClusterError.vue +1 -1
- package/app/components/workshop/blocks/ClusterRoute.vue +3 -1
- package/app/components/workshop/blocks/ClusterStatus.vue +2 -2
- package/app/components/workshop/blocks/ClusterStream.vue +8 -2
- package/app/components/workshop/town/ModelPreview3D.vue +1 -1
- package/app/components/workshop/town/TownView.vue +507 -82
- package/app/composables/useResponsive.ts +88 -0
- package/app/composables/useRouteMeta.ts +3 -0
- package/app/composables/workshop/useDcwStream.ts +1 -1
- package/app/composables/workshop/useVisibleInterval.ts +2 -2
- package/app/composables/workshop/useWorkshopApi.ts +1 -1
- package/app/layouts/default.vue +46 -2
- package/app/pages/aml/index.vue +712 -616
- package/app/pages/daq/[id].vue +3 -2
- package/app/pages/daq/index.vue +209 -9
- package/app/pages/dcw/[id].vue +109 -28
- package/app/pages/dcw/index.vue +83 -23
- package/app/pages/index.vue +35 -1
- package/app/pages/logs/index.vue +147 -13
- package/app/pages/monitor.vue +56 -12
- package/app/pages/permissions/index.vue +34 -0
- package/app/pages/plugins/index.vue +35 -4
- package/app/pages/settings.vue +90 -21
- package/app/pages/tokens.vue +23 -0
- package/app/pages/town.vue +50 -5
- package/app/pages/users.vue +23 -0
- package/app/pages/workshop/agents.vue +92 -2
- package/app/pages/workshop/channel-templates.vue +53 -0
- package/app/pages/workshop/index.vue +14 -0
- package/app/pages/workshop/teams.vue +66 -6
- package/app/pages/workshop/w/[wsId].vue +202 -14
- package/app/plugins/aw-plugins.client.ts +13 -8
- package/app/stores/app.ts +33 -1
- package/app/stores/workshop/user.ts +1 -1
- package/app/stores/workshop/workspaces.ts +18 -2
- package/app/utils/api-error.ts +1 -1
- package/cli/commands/build.mjs +8 -1
- package/docker-compose.yml +6 -0
- package/docs/full-test-plan.md +4 -0
- package/docs/plugins.en.md +1 -0
- package/docs/plugins.md +1 -0
- package/i18n/locales/en.ts +3 -0
- package/i18n/locales/zh-CN.ts +3 -0
- package/nuxt.config.ts +31 -0
- package/package.json +9 -1
- package/scripts/_audit/detached-start.mjs +103 -0
- package/scripts/_audit/guard-upstream-liveness.mjs +104 -0
- package/scripts/_dbg-param-map-e2e.ts +242 -0
- package/scripts/_dbg-param-map-rest-smoke.mjs +73 -0
- package/scripts/_dbg-param-real-scenario.mjs +153 -0
- package/scripts/_dbg-perms-e2e.mjs +10 -3
- package/scripts/_dbg-protocol-matrix.mjs +453 -441
- package/scripts/_dbg-render-regression.mjs +151 -130
- package/scripts/_dbg-town-agents-probe.mjs +60 -0
- package/scripts/_dbg-visual-acceptance.mjs +63 -0
- package/scripts/api-live-e2e.mjs +40 -8
- package/scripts/capture-walkthrough.mjs +232 -0
- package/scripts/e2e-agent-team.mjs +5 -3
- package/scripts/render-walkthrough-figure.mjs +46 -0
- package/scripts/seed-walkthrough-fixture.mjs +143 -0
- package/scripts/test-plugin-hardening.mjs +8 -0
- package/scripts/three-system-e2e.mjs +6 -6
- package/scripts/ui/admin-shots.mjs +46 -0
- package/scripts/ui/audit-layout.mjs +301 -0
- package/scripts/ui/bump-microfont.mjs +39 -0
- package/scripts/ui/lib.mjs +198 -0
- package/scripts/ui/linkcheck2.mjs +37 -0
- package/scripts/ui/live-render-check.mjs +72 -0
- package/scripts/ui/md-lint.mjs +80 -0
- package/scripts/ui/perf-audit.mjs +132 -0
- package/scripts/ui/readme-assets.mjs +30 -0
- package/scripts/ui/readme-shots.mjs +42 -0
- package/scripts/ui/record.mjs +225 -0
- package/scripts/ui/seed-admin.mjs +68 -0
- package/scripts/ui/seed-demo.mjs +83 -0
- package/scripts/ui/shot-hero.mjs +25 -0
- package/scripts/ui/shots.mjs +75 -0
- package/scripts/ui/sim-ui-shot.mjs +16 -0
- package/scripts/ui/verify-nav.mjs +51 -0
- package/scripts/ui/verify-responsive.mjs +285 -0
- package/server/api/system/config-groups/[id].patch.ts +1 -1
- package/server/api/system/config-groups/index.post.ts +1 -1
- package/server/api/system/settings/events.get.ts +1 -1
- package/server/api/system/settings/index.patch.ts +1 -1
- package/server/api/workshop/agent-tools/invoke.post.ts +16 -2
- package/server/api/workshop/aml/datasets/[id].get.ts +8 -1
- package/server/api/workshop/daq/infra/reconnect.post.ts +1 -1
- package/server/api/workshop/daq/templates/[key].delete.ts +1 -0
- package/server/api/workshop/daq/templates/[key].patch.ts +1 -0
- package/server/api/workshop/daq/templates/index.post.ts +1 -0
- package/server/api/workshop/dcw/[id]/write.post.ts +10 -2
- package/server/api/workshop/dcw/[id].delete.ts +5 -2
- package/server/api/workshop/dcw/index.get.ts +2 -0
- package/server/api/workshop/dcw/lines/[id].patch.ts +1 -1
- package/server/api/workshop/dcw/params/[id]/read.post.ts +17 -0
- package/server/api/workshop/dcw/params/[id]/write.post.ts +21 -0
- package/server/api/workshop/dcw/params/[id].delete.ts +19 -0
- package/server/api/workshop/dcw/params/[id].patch.ts +23 -0
- package/server/api/workshop/dcw/params/index.get.ts +27 -0
- package/server/api/workshop/dcw/params/index.post.ts +25 -0
- package/server/api/workshop/permissions/index.get.ts +3 -1
- package/server/plugins/aw-plugins.ts +14 -3
- package/server/plugins/dev-stability-guard.ts +3 -1
- package/server/plugins/system-config.ts +6 -1
- package/server/plugins-builtin/rag-bridge/index.mjs +9 -2
- package/server/services/system-config.ts +28 -9
- package/server/services/workshop/agents/adapters/one-shot-cli-agent.ts +2 -1
- package/server/services/workshop/agents/agent-interface.ts +8 -6
- package/server/services/workshop/agents/base-agent.ts +18 -4
- package/server/services/workshop/agents/claude-agent.ts +7 -3
- package/server/services/workshop/agents/codex-agent.ts +3 -3
- package/server/services/workshop/agents/dsh-agent.ts +3 -3
- package/server/services/workshop/agents/goose-agent.ts +0 -1
- package/server/services/workshop/agents/harness-terminal.ts +14 -1
- package/server/services/workshop/agents/hermes-agent.ts +4 -2
- package/server/services/workshop/agents/host-tool-bridge.ts +5 -1
- package/server/services/workshop/agents/industrial-context.ts +4 -1
- package/server/services/workshop/agents/industrial-tools.ts +164 -6
- package/server/services/workshop/agents/omp-agent.ts +15 -9
- package/server/services/workshop/agents/opencode-agent.ts +47 -21
- package/server/services/workshop/agents/qwen-agent.ts +10 -5
- package/server/services/workshop/aml/entity.ts +3 -1
- package/server/services/workshop/aml/python-runtime.ts +3 -2
- package/server/services/workshop/daq/bus/mqtt.adapter.ts +8 -4
- package/server/services/workshop/daq/daq-controller.ts +18 -3
- package/server/services/workshop/daq/daq-runtime.ts +5 -3
- package/server/services/workshop/daq/drivers.ts +63 -8
- package/server/services/workshop/daq/host-ports.ts +3 -2
- package/server/services/workshop/daq/storage/timescale.adapter.ts +3 -1
- package/server/services/workshop/db/channel.repo.ts +4 -0
- package/server/services/workshop/db/ops.repo.ts +5 -2
- package/server/services/workshop/db/retention.ts +8 -3
- package/server/services/workshop/dcw/dcw-controller.ts +143 -16
- package/server/services/workshop/dcw/dcw-product.repo.ts +38 -1
- package/server/services/workshop/dcw/dcw-runtime.ts +3 -2
- package/server/services/workshop/dcw/drivers.ts +5 -2
- package/server/services/workshop/dcw/param-conversion.ts +78 -0
- package/server/services/workshop/dcw/param-limits.ts +142 -0
- package/server/services/workshop/dcw/param-map.repo.ts +305 -0
- package/server/services/workshop/dcw/recipe-rollback-manager.ts +13 -7
- package/server/services/workshop/runtime/agent-runtime.ts +4 -0
- package/server/services/workshop/runtime/manager.ts +9 -2
- package/server/services/workshop/settings.ts +4 -2
- package/server/types/pg.d.ts +49 -0
- package/server/utils/stability-severity.ts +13 -2
- package/shared/config/groups.mjs +22 -1
- package/shared/config/home.d.mts +28 -0
- package/shared/dcw-protocol.ts +136 -0
- package/uno.config.ts +12 -1
- package/.output/public/_nuxt/BFkgkW8u.js +0 -4
- package/.output/public/_nuxt/C5gUkRwn.js +0 -1
- package/.output/public/_nuxt/CM12FuB42.js +0 -1
- package/.output/public/_nuxt/CZiw7sEV.js +0 -1
- package/.output/public/_nuxt/Cc_9VzD42.js +0 -1
- package/.output/public/_nuxt/CdPzkOMV.js +0 -1
- package/.output/public/_nuxt/D1YDxZpZ.js +0 -1
- package/.output/public/_nuxt/D20Yamr4.js +0 -1
- package/.output/public/_nuxt/DVsjtsvZ2.js +0 -1
- package/.output/public/_nuxt/DmqknNvV.js +0 -18
- package/.output/public/_nuxt/DnUuIR83.js +0 -1
- package/.output/public/_nuxt/S_fVQwJK.js +0 -1
- package/.output/public/_nuxt/TownView.0oLiQgTC.css +0 -1
- package/.output/public/_nuxt/_id_.D-SYuyZb.css +0 -1
- package/.output/public/_nuxt/_id_.hma_BU6T.css +0 -1
- package/.output/public/_nuxt/_wsId_.B12v3PhY.css +0 -1
- package/.output/public/_nuxt/agents.BV70ioCv.css +0 -1
- package/.output/public/_nuxt/ahgEJu2R.js +0 -1
- package/.output/public/_nuxt/aml.COEKNNqK.css +0 -1
- package/.output/public/_nuxt/builds/meta/44b66249-54d0-4c8a-9057-9755a32329e2.json +0 -1
- package/.output/public/_nuxt/channel-templates.C-M5nKcC.css +0 -1
- package/.output/public/_nuxt/daq.B3265ZDn.css +0 -1
- package/.output/public/_nuxt/dcw.DLYZqEhT.css +0 -1
- package/.output/public/_nuxt/default.DE_vT238.css +0 -1
- package/.output/public/_nuxt/entry.BB-Eeh-J.css +0 -1
- package/.output/public/_nuxt/logs.CqFyMrJw.css +0 -1
- package/.output/public/_nuxt/monitor.B--1dPzs.css +0 -1
- package/.output/public/_nuxt/pages.ooEzrMm9.css +0 -1
- package/.output/public/_nuxt/permissions.B1pjGChZ.css +0 -1
- package/.output/public/_nuxt/plugins.5e5chZ67.css +0 -1
- package/.output/public/_nuxt/pz2JDAM7.js +0 -2
- package/.output/public/_nuxt/settings.Dm3M0RLy.css +0 -1
- package/.output/public/_nuxt/teams.BC75EGnR.css +0 -1
- package/.output/public/_nuxt/tokens.xRb1fSPU.css +0 -1
- package/.output/public/_nuxt/users.CXnP2E08.css +0 -1
- package/.output/public/_nuxt/workshop.Jk5HxWPE.css +0 -1
- package/.output/server/chunks/build/TownView-jVazYOjN.mjs.map +0 -1
- package/.output/server/chunks/build/_id_-Hwr4rZpr.mjs.map +0 -1
- package/.output/server/chunks/build/agents-Bvin73QY.mjs.map +0 -1
- package/.output/server/chunks/build/daq-C03Uu5UE.mjs.map +0 -1
- package/.output/server/chunks/build/pages-BO7yZsXA.mjs.map +0 -1
- package/.output/server/chunks/build/settings-DoQ2Oq3P.mjs.map +0 -1
- package/.output/server/chunks/build/teams-2kz3CusY.mjs.map +0 -1
- package/.output/server/chunks/build/town-BOl6hs9B.mjs.map +0 -1
- package/.output/server/chunks/build/workspaces-BuydxM-3.mjs.map +0 -1
- /package/.output/public/_nuxt/{36oeS8_R2.js → 36oeS8_R.js} +0 -0
- /package/.output/public/_nuxt/{CYWVXZTS.js → CYWVXZTS2.js} +0 -0
|
@@ -1,441 +1,453 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 全协议连通矩阵实测(真实模拟工况;DAQ 只读 + DCW 读/写闭环)。
|
|
3
|
-
* NO_PROXY='*' node scripts/_dbg-protocol-matrix.mjs [--base http://127.0.0.1:3000]
|
|
4
|
-
*
|
|
5
|
-
* 前置(模拟工况,全部在跑):
|
|
6
|
-
* MQTT :1883(aw/sim/temp 每 2s) · HTTP :1889(/api/value;/api/setpoint)
|
|
7
|
-
* ModbusTCP :1502(40001 压力 f32 0.6~1.1 / 40003 温度 f32 165~175)
|
|
8
|
-
* ModbusRTU :15030(40001 f32 40.25↔44.25) · OPC UA :4840(ns=2;s=AW.Temp/AW.SetTemp)
|
|
9
|
-
* PLC 涂布产线 :15040(PV 温度 40001 / SP 温度 40021 可写,一阶热惯性)
|
|
10
|
-
*
|
|
11
|
-
* 矩阵:
|
|
12
|
-
* DAQ 读取 ×5(mqtt/http/modbus-tcp/modbus-rtu/opcua):test-connection → 采样落库(Timescale)→ WS 帧
|
|
13
|
-
* DCW 读/写 ×4:modbus-tcp(PLC 真闭环 SP→PV 收敛)/ opcua(回读)/ mqtt(发布+订阅验证)/ http(POST 落达验证)
|
|
14
|
-
* 联锁:配方窗口负例(越窗 400)
|
|
15
|
-
*/
|
|
16
|
-
const BASE = (() => {
|
|
17
|
-
const i = process.argv.indexOf('--base')
|
|
18
|
-
return i > 0 ? process.argv[i + 1] : 'http://127.0.0.1:3000'
|
|
19
|
-
})()
|
|
20
|
-
const WS_BASE = BASE.replace(/^http/, 'ws')
|
|
21
|
-
const TAG = Date.now().toString(36)
|
|
22
|
-
import net from 'node:net'
|
|
23
|
-
import { spawnSync } from 'node:child_process'
|
|
24
|
-
import fs from 'node:fs'
|
|
25
|
-
import { spawn } from 'node:child_process'
|
|
26
|
-
import { resolve } from 'node:path'
|
|
27
|
-
|
|
28
|
-
let failures = 0
|
|
29
|
-
let passed = 0
|
|
30
|
-
const results = []
|
|
31
|
-
const check = (id, name, ok, detail = '') => {
|
|
32
|
-
console.log(` ${ok ? 'PASS' : 'FAIL'} ${id} ${name}${detail ? ` — ${detail}` : ''}`)
|
|
33
|
-
results.push({ id, name, ok, detail })
|
|
34
|
-
ok ? passed++ : failures++
|
|
35
|
-
}
|
|
36
|
-
const sleep = ms => new Promise(r => setTimeout(r, ms))
|
|
37
|
-
|
|
38
|
-
const api = async (method, path, { body, token } = {}, attempt = 0) => {
|
|
39
|
-
const headers = { 'content-type': 'application/json' }
|
|
40
|
-
if (token) headers.authorization = `Bearer ${token}`
|
|
41
|
-
try {
|
|
42
|
-
const res = await fetch(`${BASE}${path}`, { method, headers, body: body !== undefined ? JSON.stringify(body) : undefined })
|
|
43
|
-
return { status: res.status, ...(await res.json().catch(() => ({}))) }
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
// dev server 可能正被外部击杀/自愈重启:短重试跨过死亡窗口
|
|
47
|
-
if (attempt < 3) { await sleep(2500); return api(method, path, { body, token }, attempt + 1) }
|
|
48
|
-
throw err
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function waitUntil(name, cond, timeoutMs = 30_000, intervalMs = 800) {
|
|
53
|
-
const deadline = Date.now() + timeoutMs
|
|
54
|
-
let last = null
|
|
55
|
-
while (Date.now() < deadline) {
|
|
56
|
-
try { last = await cond(); if (last) return last } catch (e) { last = e }
|
|
57
|
-
await sleep(intervalMs)
|
|
58
|
-
}
|
|
59
|
-
throw new Error(`timeout:${name} last=${String(last).slice(0, 160)}`)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** AEP WS(全局 peer:daq.reading/daq.frame 等场景帧) */
|
|
63
|
-
function openAep(token) {
|
|
64
|
-
const frames = []
|
|
65
|
-
const ws = new WebSocket(`${WS_BASE}/api/workshop/ws?token=${encodeURIComponent(token)}`)
|
|
66
|
-
ws.addEventListener('message', (ev) => {
|
|
67
|
-
try {
|
|
68
|
-
const e = JSON.parse(ev.data)
|
|
69
|
-
if (e.type && e.type !== 'pong') frames.push(e)
|
|
70
|
-
}
|
|
71
|
-
catch { /* ignore */ }
|
|
72
|
-
})
|
|
73
|
-
return { ws, frames, ready: new Promise(r => ws.addEventListener('open', () => r())) }
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function main() {
|
|
77
|
-
console.log(`\n━━━ 全协议矩阵实测 @ ${BASE} (tag=${TAG}) ━━━`)
|
|
78
|
-
|
|
79
|
-
// ── P0. 模拟工况 preflight(自愈):并行会话的端口清理可能杀掉模拟器,开跑前逐一拉活 ──
|
|
80
|
-
const SIMS = [
|
|
81
|
-
{ name: 'mqtt-http', ports: [18830, 1889], cmd: 'scripts/dev-protocol-simulators.mjs', env: { MQTT_SIM_PORT: '18830', HTTP_SIM_PORT: '1889' }, log: 'sim-mqtt-http.log' },
|
|
82
|
-
{ name: 'modbus-tcp', ports: [1502], cmd: 'scripts/dev-modbus-simulator.mjs', env: {}, log: 'sim-modbus-tcp.log' },
|
|
83
|
-
{ name: 'opcua', ports: [4840], cmd: 'scripts/dev-opcua-simulator.mjs', env: { OPCUA_SIM_PORT: '4840' }, log: 'sim-opcua.log' },
|
|
84
|
-
{ name: 'plc', ports: [15040], cmd: 'scripts/dev-plc-simulator.mjs', env: {}, args: ['--port', '15040'], log: 'sim-plc.log' },
|
|
85
|
-
{ name: 'rtu', ports: [15030], cmd: 'scripts/_rtu-mini-slave.mjs', env: {}, log: 'sim-rtu.log' },
|
|
86
|
-
]
|
|
87
|
-
const portUp = (port) => new Promise((res) => {
|
|
88
|
-
const s = net.connect(port, '127.0.0.1')
|
|
89
|
-
const t = setTimeout(() => { s.destroy(); res(false) }, 1000)
|
|
90
|
-
s.on('connect', () => { clearTimeout(t); s.destroy(); res(true) })
|
|
91
|
-
s.on('error', () => { clearTimeout(t); res(false) })
|
|
92
|
-
})
|
|
93
|
-
const portOwners = (port) => {
|
|
94
|
-
// netstat 找出该端口所有 LISTENING 持有者(Windows 双绑竞态:僵尸实例会导致读写分家)
|
|
95
|
-
const out = spawnSync('cmd', ['/c', `netstat -ano | findstr :${port} | findstr LISTENING`], { encoding: 'utf-8' })
|
|
96
|
-
const pids = new Set()
|
|
97
|
-
for (const line of (out.stdout ?? '').split('\n')) {
|
|
98
|
-
const m = line.trim().match(/\s(\d+)\s*$/)
|
|
99
|
-
if (m) pids.add(m[1])
|
|
100
|
-
}
|
|
101
|
-
return [...pids]
|
|
102
|
-
}
|
|
103
|
-
for (const sim of SIMS) {
|
|
104
|
-
// 清场:杀掉端口上所有旧持有者(僵尸/双绑),保证唯一新实例
|
|
105
|
-
for (const pid of portOwners(sim.ports[0])) {
|
|
106
|
-
spawnSync('cmd', ['/c', `taskkill /F /PID ${pid}`])
|
|
107
|
-
console.log(` [preflight] ${sim.name} 清掉旧持有者 pid=${pid}`)
|
|
108
|
-
await sleep(300)
|
|
109
|
-
}
|
|
110
|
-
let up = false
|
|
111
|
-
{
|
|
112
|
-
const fd = fs.openSync(resolve('.AgentWorkShop/data', sim.log), 'a')
|
|
113
|
-
const child = spawn(process.execPath, [sim.cmd, ...(sim.args ?? [])], {
|
|
114
|
-
cwd: process.cwd(), env: { ...process.env, NO_PROXY: '127.0.0.1,localhost', ...sim.env },
|
|
115
|
-
detached: true, stdio: ['ignore', fd, fd],
|
|
116
|
-
})
|
|
117
|
-
child.unref()
|
|
118
|
-
console.log(` [preflight] ${sim.name} → 拉起唯一实例 pid=${child.pid}`)
|
|
119
|
-
for (let i = 0; i < 15 && !up; i++) { await sleep(1000); up = await portUp(sim.ports[0]) }
|
|
120
|
-
if (!up) throw new Error(`preflight:${sim.name} 拉起失败`)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
check('0.0', '模拟工况 preflight(六端口唯一实例)', true)
|
|
124
|
-
|
|
125
|
-
// dev server 健康(被外部击杀 → 清僵尸 guard 自愈;最多等 90s)
|
|
126
|
-
{
|
|
127
|
-
let ok = false
|
|
128
|
-
for (let i = 0; i < 30 && !ok; i++) {
|
|
129
|
-
try { ok = (await fetch(`${BASE}/api/health`)).status === 200 } catch { ok = false }
|
|
130
|
-
if (!ok) {
|
|
131
|
-
if (i === 0) {
|
|
132
|
-
const lockPath = resolve('.AgentWorkShop/.runtime/aw.lock')
|
|
133
|
-
let lockPid = 0
|
|
134
|
-
try { lockPid = Number(JSON.parse(fs.readFileSync(lockPath, 'utf-8')).pid ?? 0) } catch { /* 无锁 */ }
|
|
135
|
-
if (lockPid) {
|
|
136
|
-
spawnSync('cmd', ['/c', `taskkill /F /PID ${lockPid}`])
|
|
137
|
-
try { fs.unlinkSync(lockPath) } catch { /* 无锁 */ }
|
|
138
|
-
console.log(` [preflight] dev server 僵尸 guard(pid=${lockPid})已清,重启…`)
|
|
139
|
-
const fd = fs.openSync(resolve('.AgentWorkShop/data/dev-server.log'), 'a')
|
|
140
|
-
const child = spawn(process.execPath, ['bin/aw.mjs', 'dev'], {
|
|
141
|
-
cwd: process.cwd(), env: { ...process.env, NO_PROXY: '127.0.0.1,localhost' },
|
|
142
|
-
detached: true, stdio: ['ignore', fd, fd],
|
|
143
|
-
})
|
|
144
|
-
child.unref()
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
await sleep(3000)
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (!ok) throw new Error('preflight:dev server 90s 未恢复')
|
|
151
|
-
}
|
|
152
|
-
console.log(' [preflight] dev server 健康')
|
|
153
|
-
|
|
154
|
-
// ── 0. 注册 + 产线 ──
|
|
155
|
-
const reg = await api('POST', '/api/users/register', {
|
|
156
|
-
body: { email: `proto-${TAG}@test.local`, password: 'Passw0rd!123', name: `proto-${TAG}` },
|
|
157
|
-
})
|
|
158
|
-
const token = reg.data?.token
|
|
159
|
-
if (!token) throw new Error(`注册失败: ${JSON.stringify(reg).slice(0, 200)}`)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
{
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
{
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
//
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
await
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
// 6.
|
|
366
|
-
const
|
|
367
|
-
check("6.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 全协议连通矩阵实测(真实模拟工况;DAQ 只读 + DCW 读/写闭环)。
|
|
3
|
+
* NO_PROXY='*' node scripts/_dbg-protocol-matrix.mjs [--base http://127.0.0.1:3000]
|
|
4
|
+
*
|
|
5
|
+
* 前置(模拟工况,全部在跑):
|
|
6
|
+
* MQTT :1883(aw/sim/temp 每 2s) · HTTP :1889(/api/value;/api/setpoint)
|
|
7
|
+
* ModbusTCP :1502(40001 压力 f32 0.6~1.1 / 40003 温度 f32 165~175)
|
|
8
|
+
* ModbusRTU :15030(40001 f32 40.25↔44.25) · OPC UA :4840(ns=2;s=AW.Temp/AW.SetTemp)
|
|
9
|
+
* PLC 涂布产线 :15040(PV 温度 40001 / SP 温度 40021 可写,一阶热惯性)
|
|
10
|
+
*
|
|
11
|
+
* 矩阵:
|
|
12
|
+
* DAQ 读取 ×5(mqtt/http/modbus-tcp/modbus-rtu/opcua):test-connection → 采样落库(Timescale)→ WS 帧
|
|
13
|
+
* DCW 读/写 ×4:modbus-tcp(PLC 真闭环 SP→PV 收敛)/ opcua(回读)/ mqtt(发布+订阅验证)/ http(POST 落达验证)
|
|
14
|
+
* 联锁:配方窗口负例(越窗 400)
|
|
15
|
+
*/
|
|
16
|
+
const BASE = (() => {
|
|
17
|
+
const i = process.argv.indexOf('--base')
|
|
18
|
+
return i > 0 ? process.argv[i + 1] : 'http://127.0.0.1:3000'
|
|
19
|
+
})()
|
|
20
|
+
const WS_BASE = BASE.replace(/^http/, 'ws')
|
|
21
|
+
const TAG = Date.now().toString(36)
|
|
22
|
+
import net from 'node:net'
|
|
23
|
+
import { spawnSync } from 'node:child_process'
|
|
24
|
+
import fs from 'node:fs'
|
|
25
|
+
import { spawn } from 'node:child_process'
|
|
26
|
+
import { resolve } from 'node:path'
|
|
27
|
+
|
|
28
|
+
let failures = 0
|
|
29
|
+
let passed = 0
|
|
30
|
+
const results = []
|
|
31
|
+
const check = (id, name, ok, detail = '') => {
|
|
32
|
+
console.log(` ${ok ? 'PASS' : 'FAIL'} ${id} ${name}${detail ? ` — ${detail}` : ''}`)
|
|
33
|
+
results.push({ id, name, ok, detail })
|
|
34
|
+
ok ? passed++ : failures++
|
|
35
|
+
}
|
|
36
|
+
const sleep = ms => new Promise(r => setTimeout(r, ms))
|
|
37
|
+
|
|
38
|
+
const api = async (method, path, { body, token } = {}, attempt = 0) => {
|
|
39
|
+
const headers = { 'content-type': 'application/json' }
|
|
40
|
+
if (token) headers.authorization = `Bearer ${token}`
|
|
41
|
+
try {
|
|
42
|
+
const res = await fetch(`${BASE}${path}`, { method, headers, body: body !== undefined ? JSON.stringify(body) : undefined })
|
|
43
|
+
return { status: res.status, ...(await res.json().catch(() => ({}))) }
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
// dev server 可能正被外部击杀/自愈重启:短重试跨过死亡窗口
|
|
47
|
+
if (attempt < 3) { await sleep(2500); return api(method, path, { body, token }, attempt + 1) }
|
|
48
|
+
throw err
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function waitUntil(name, cond, timeoutMs = 30_000, intervalMs = 800) {
|
|
53
|
+
const deadline = Date.now() + timeoutMs
|
|
54
|
+
let last = null
|
|
55
|
+
while (Date.now() < deadline) {
|
|
56
|
+
try { last = await cond(); if (last) return last } catch (e) { last = e }
|
|
57
|
+
await sleep(intervalMs)
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`timeout:${name} last=${String(last).slice(0, 160)}`)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** AEP WS(全局 peer:daq.reading/daq.frame 等场景帧) */
|
|
63
|
+
function openAep(token) {
|
|
64
|
+
const frames = []
|
|
65
|
+
const ws = new WebSocket(`${WS_BASE}/api/workshop/ws?token=${encodeURIComponent(token)}`)
|
|
66
|
+
ws.addEventListener('message', (ev) => {
|
|
67
|
+
try {
|
|
68
|
+
const e = JSON.parse(ev.data)
|
|
69
|
+
if (e.type && e.type !== 'pong') frames.push(e)
|
|
70
|
+
}
|
|
71
|
+
catch { /* ignore */ }
|
|
72
|
+
})
|
|
73
|
+
return { ws, frames, ready: new Promise(r => ws.addEventListener('open', () => r())) }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function main() {
|
|
77
|
+
console.log(`\n━━━ 全协议矩阵实测 @ ${BASE} (tag=${TAG}) ━━━`)
|
|
78
|
+
|
|
79
|
+
// ── P0. 模拟工况 preflight(自愈):并行会话的端口清理可能杀掉模拟器,开跑前逐一拉活 ──
|
|
80
|
+
const SIMS = [
|
|
81
|
+
{ name: 'mqtt-http', ports: [18830, 1889], cmd: 'scripts/dev-protocol-simulators.mjs', env: { MQTT_SIM_PORT: '18830', HTTP_SIM_PORT: '1889' }, log: 'sim-mqtt-http.log' },
|
|
82
|
+
{ name: 'modbus-tcp', ports: [1502], cmd: 'scripts/dev-modbus-simulator.mjs', env: {}, log: 'sim-modbus-tcp.log' },
|
|
83
|
+
{ name: 'opcua', ports: [4840], cmd: 'scripts/dev-opcua-simulator.mjs', env: { OPCUA_SIM_PORT: '4840' }, log: 'sim-opcua.log' },
|
|
84
|
+
{ name: 'plc', ports: [15040], cmd: 'scripts/dev-plc-simulator.mjs', env: {}, args: ['--port', '15040'], log: 'sim-plc.log' },
|
|
85
|
+
{ name: 'rtu', ports: [15030], cmd: 'scripts/_rtu-mini-slave.mjs', env: {}, log: 'sim-rtu.log' },
|
|
86
|
+
]
|
|
87
|
+
const portUp = (port) => new Promise((res) => {
|
|
88
|
+
const s = net.connect(port, '127.0.0.1')
|
|
89
|
+
const t = setTimeout(() => { s.destroy(); res(false) }, 1000)
|
|
90
|
+
s.on('connect', () => { clearTimeout(t); s.destroy(); res(true) })
|
|
91
|
+
s.on('error', () => { clearTimeout(t); res(false) })
|
|
92
|
+
})
|
|
93
|
+
const portOwners = (port) => {
|
|
94
|
+
// netstat 找出该端口所有 LISTENING 持有者(Windows 双绑竞态:僵尸实例会导致读写分家)
|
|
95
|
+
const out = spawnSync('cmd', ['/c', `netstat -ano | findstr :${port} | findstr LISTENING`], { encoding: 'utf-8' })
|
|
96
|
+
const pids = new Set()
|
|
97
|
+
for (const line of (out.stdout ?? '').split('\n')) {
|
|
98
|
+
const m = line.trim().match(/\s(\d+)\s*$/)
|
|
99
|
+
if (m) pids.add(m[1])
|
|
100
|
+
}
|
|
101
|
+
return [...pids]
|
|
102
|
+
}
|
|
103
|
+
for (const sim of SIMS) {
|
|
104
|
+
// 清场:杀掉端口上所有旧持有者(僵尸/双绑),保证唯一新实例
|
|
105
|
+
for (const pid of portOwners(sim.ports[0])) {
|
|
106
|
+
spawnSync('cmd', ['/c', `taskkill /F /PID ${pid}`])
|
|
107
|
+
console.log(` [preflight] ${sim.name} 清掉旧持有者 pid=${pid}`)
|
|
108
|
+
await sleep(300)
|
|
109
|
+
}
|
|
110
|
+
let up = false
|
|
111
|
+
{
|
|
112
|
+
const fd = fs.openSync(resolve('.AgentWorkShop/data', sim.log), 'a')
|
|
113
|
+
const child = spawn(process.execPath, [sim.cmd, ...(sim.args ?? [])], {
|
|
114
|
+
cwd: process.cwd(), env: { ...process.env, NO_PROXY: '127.0.0.1,localhost', ...sim.env },
|
|
115
|
+
detached: true, stdio: ['ignore', fd, fd],
|
|
116
|
+
})
|
|
117
|
+
child.unref()
|
|
118
|
+
console.log(` [preflight] ${sim.name} → 拉起唯一实例 pid=${child.pid}`)
|
|
119
|
+
for (let i = 0; i < 15 && !up; i++) { await sleep(1000); up = await portUp(sim.ports[0]) }
|
|
120
|
+
if (!up) throw new Error(`preflight:${sim.name} 拉起失败`)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
check('0.0', '模拟工况 preflight(六端口唯一实例)', true)
|
|
124
|
+
|
|
125
|
+
// dev server 健康(被外部击杀 → 清僵尸 guard 自愈;最多等 90s)
|
|
126
|
+
{
|
|
127
|
+
let ok = false
|
|
128
|
+
for (let i = 0; i < 30 && !ok; i++) {
|
|
129
|
+
try { ok = (await fetch(`${BASE}/api/health`)).status === 200 } catch { ok = false }
|
|
130
|
+
if (!ok) {
|
|
131
|
+
if (i === 0) {
|
|
132
|
+
const lockPath = resolve('.AgentWorkShop/.runtime/aw.lock')
|
|
133
|
+
let lockPid = 0
|
|
134
|
+
try { lockPid = Number(JSON.parse(fs.readFileSync(lockPath, 'utf-8')).pid ?? 0) } catch { /* 无锁 */ }
|
|
135
|
+
if (lockPid) {
|
|
136
|
+
spawnSync('cmd', ['/c', `taskkill /F /PID ${lockPid}`])
|
|
137
|
+
try { fs.unlinkSync(lockPath) } catch { /* 无锁 */ }
|
|
138
|
+
console.log(` [preflight] dev server 僵尸 guard(pid=${lockPid})已清,重启…`)
|
|
139
|
+
const fd = fs.openSync(resolve('.AgentWorkShop/data/dev-server.log'), 'a')
|
|
140
|
+
const child = spawn(process.execPath, ['bin/aw.mjs', 'dev'], {
|
|
141
|
+
cwd: process.cwd(), env: { ...process.env, NO_PROXY: '127.0.0.1,localhost' },
|
|
142
|
+
detached: true, stdio: ['ignore', fd, fd],
|
|
143
|
+
})
|
|
144
|
+
child.unref()
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
await sleep(3000)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (!ok) throw new Error('preflight:dev server 90s 未恢复')
|
|
151
|
+
}
|
|
152
|
+
console.log(' [preflight] dev server 健康')
|
|
153
|
+
|
|
154
|
+
// ── 0. 注册 + 产线 ──
|
|
155
|
+
const reg = await api('POST', '/api/users/register', {
|
|
156
|
+
body: { email: `proto-${TAG}@test.local`, password: 'Passw0rd!123', name: `proto-${TAG}` },
|
|
157
|
+
})
|
|
158
|
+
const token = reg.data?.token
|
|
159
|
+
if (!token) throw new Error(`注册失败: ${JSON.stringify(reg).slice(0, 200)}`)
|
|
160
|
+
|
|
161
|
+
// 角色前置:建线/建节点需 admin/editor(0.7.x 权限硬化);admin 把测试用户提为 editor
|
|
162
|
+
const admLogin = await api('POST', '/api/users/login', {
|
|
163
|
+
body: { email: 'admin@awshop.local', password: process.env.AW_ADMIN_PASS ?? 'admin123' },
|
|
164
|
+
}).catch(() => null)
|
|
165
|
+
const admTok = admLogin?.data?.token
|
|
166
|
+
const regId = reg.data?.user?.id
|
|
167
|
+
if (admTok && regId) {
|
|
168
|
+
const promoted = await api('PUT', `/api/users/${regId}`, { body: { role: 'editor' }, token: admTok }).catch(() => null)
|
|
169
|
+
check('0.0b', 'admin 提升测试用户为 editor', promoted?.data?.role === 'editor', promoted?.message ?? '')
|
|
170
|
+
}
|
|
171
|
+
else { console.log(' [skip] admin 不可用,建线可能被 403(设 AW_ADMIN_PASS)') }
|
|
172
|
+
|
|
173
|
+
const line = (await api('POST', '/api/workshop/dcw/lines', { body: { name: `全协议产线-${TAG}` }, token })).data?.line
|
|
174
|
+
check('0.1', '建产线', Boolean(line?.id))
|
|
175
|
+
|
|
176
|
+
// ── 0.2 产线级权限(新版权限模型:普通用户默认无权,admin 逐线授 operate) ──
|
|
177
|
+
const ADMIN_PASS = process.env.AW_ADMIN_PASS ?? 'admin123'
|
|
178
|
+
const adminLogin = await api('POST', '/api/users/login', {
|
|
179
|
+
body: { email: 'admin@awshop.local', password: ADMIN_PASS },
|
|
180
|
+
}).catch(() => null)
|
|
181
|
+
const adminTok = adminLogin?.data?.token
|
|
182
|
+
if (adminTok) {
|
|
183
|
+
const granted = await api('PUT', '/api/workshop/permissions', {
|
|
184
|
+
body: { userId: reg.data?.user?.id, grants: [{ lineId: line.id, mode: 'operate' }] }, token: adminTok,
|
|
185
|
+
}).catch(() => null)
|
|
186
|
+
check('0.2', 'admin 授予测试用户产线 operate 权限', Boolean(granted?.data?.userId), granted?.message ?? '')
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
console.log(' [skip] admin 登录失败(可设 AW_ADMIN_PASS),以普通用户无权态继续(写入段将按权限模型拒绝)')
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ── 1. DAQ 五协议节点(配置连接 + 连接测试) ──
|
|
193
|
+
const daqDefs = [
|
|
194
|
+
{ id: 'mqtt', driver: 'mqtt', templateRef: 'daq-temp-tc', name: `MQTT温度-${TAG}`, expect: [30, 75],
|
|
195
|
+
cfg: { host: '127.0.0.1', port: 18830, topic: 'aw/sim/temp', jsonPath: 'data.temp' } },
|
|
196
|
+
{ id: 'http', driver: 'http', templateRef: 'daq-temp-tc', name: `HTTP流量-${TAG}`, expect: [38, 48],
|
|
197
|
+
cfg: { url: 'http://127.0.0.1:1889/api/value', jsonPath: 'data.value' } },
|
|
198
|
+
{ id: 'mbtcp', driver: 'modbus-tcp', templateRef: 'daq-pressure-tx', name: `ModbusTCP压力-${TAG}`, expect: [0.5, 1.25],
|
|
199
|
+
cfg: { host: '127.0.0.1', port: 1502, unitId: 1, register: 40001, registerType: 'holding', dataType: 'float32', byteOrder: 'big' } },
|
|
200
|
+
{ id: 'rtu', driver: 'modbus-rtu', templateRef: 'daq-temp-tc', name: `RTU温度-${TAG}`, expect: [60, 72],
|
|
201
|
+
cfg: { host: '127.0.0.1', port: 15030, unitId: 1, register: 40001, registerType: 'holding', dataType: 'uint16' } },
|
|
202
|
+
{ id: 'opcua', driver: 'opcua', templateRef: 'daq-temp-tc', name: `OPCUA温度-${TAG}`, expect: [140, 200],
|
|
203
|
+
cfg: { endpoint: 'opc.tcp://127.0.0.1:4840', nodeId: 'ns=2;s=AW.Temp' } },
|
|
204
|
+
{ id: 'plcpv', driver: 'modbus-tcp', templateRef: 'daq-temp-tc', name: `PLC-PV温度-${TAG}`, expect: [0, 260],
|
|
205
|
+
cfg: { host: '127.0.0.1', port: 15040, unitId: 1, register: 40001, registerType: 'holding', dataType: 'float32', byteOrder: 'big' } },
|
|
206
|
+
]
|
|
207
|
+
const daqNodes = {}
|
|
208
|
+
for (const d of daqDefs) {
|
|
209
|
+
const t = await api('POST', '/api/workshop/daq/test-driver', { body: { driver: d.driver, driverConfig: d.cfg }, token })
|
|
210
|
+
check(`1.${d.id}-test`, `${d.driver} 连接测试`, t.data?.test?.ok === true, JSON.stringify(t.data?.test ?? t.message ?? {}).slice(0, 120))
|
|
211
|
+
const created = await api('POST', '/api/workshop/daq', {
|
|
212
|
+
body: { templateRef: d.templateRef, name: d.name, driver: d.driver, driverConfig: d.cfg, lineId: line.id, intervalMs: 800, publishIntervalMs: 0 }, token,
|
|
213
|
+
})
|
|
214
|
+
daqNodes[d.id] = created.data?.node
|
|
215
|
+
check(`1.${d.id}-create`, `${d.driver} 节点创建`, Boolean(daqNodes[d.id]?.id), created.message ?? '')
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ── 2. DCW 节点(四路下发通道) ──
|
|
219
|
+
const dcwDefs = [
|
|
220
|
+
{ id: 'plcsp', driver: 'modbus-tcp', name: `PLC-SP温度-${TAG}`, recipe: true,
|
|
221
|
+
cfg: { host: '127.0.0.1', port: 15040, unitId: 1, register: 40021, dataType: 'float32', byteOrder: 'big' } },
|
|
222
|
+
{ id: 'ocusp', driver: 'opcua', name: `OPCUA-SP-${TAG}`,
|
|
223
|
+
cfg: { endpoint: 'opc.tcp://127.0.0.1:4840', nodeId: 'ns=2;s=AW.SetTemp' } },
|
|
224
|
+
{ id: 'mqsp', driver: 'mqtt', name: `MQTT-SP-${TAG}`,
|
|
225
|
+
cfg: { host: '127.0.0.1', port: 18830, topic: `aw/sim/setpoint-${TAG}`, jsonKey: 'setpoint', qos: 1 } },
|
|
226
|
+
{ id: 'htsp', driver: 'http', name: `HTTP-SP-${TAG}`,
|
|
227
|
+
cfg: { url: 'http://127.0.0.1:1889/api/setpoint', bodyKey: 'setpoint' } },
|
|
228
|
+
]
|
|
229
|
+
const dcwNodes = {}
|
|
230
|
+
for (const d of dcwDefs) {
|
|
231
|
+
const t = await api('POST', '/api/workshop/dcw/test-driver', { body: { driver: d.driver, driverConfig: d.cfg }, token })
|
|
232
|
+
check(`2.${d.id}-test`, `DCW ${d.driver} 连接测试`, t.data?.test?.ok === true, JSON.stringify(t.data?.test ?? t.message ?? {}).slice(0, 120))
|
|
233
|
+
const created = await api('POST', '/api/workshop/dcw', {
|
|
234
|
+
body: { templateRef: 'dcw-temp-sp', name: d.name, driver: d.driver, driverConfig: d.cfg, lineId: line.id }, token,
|
|
235
|
+
})
|
|
236
|
+
dcwNodes[d.id] = created.data?.node
|
|
237
|
+
check(`2.${d.id}-create`, `DCW ${d.driver} 节点创建`, Boolean(dcwNodes[d.id]?.id), created.message ?? '')
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// ── 3. 产品/配方/开跑(激活数采门控 + 配方窗口) ──
|
|
241
|
+
// 预置:先把 PLC SP 裸写到 25℃,让 PV 从上轮残留收敛到低温 —— 6.4c 的"爬升"才有确定性基线
|
|
242
|
+
{
|
|
243
|
+
const net = await import('node:net')
|
|
244
|
+
await new Promise((resolve) => {
|
|
245
|
+
const sock = net.connect(15040, '127.0.0.1')
|
|
246
|
+
const b = Buffer.alloc(4)
|
|
247
|
+
b.writeFloatBE(25)
|
|
248
|
+
const words = [b.readUInt16BE(0), b.readUInt16BE(2)]
|
|
249
|
+
const frame = Buffer.alloc(17)
|
|
250
|
+
frame.writeUInt16BE(1, 0) // txn
|
|
251
|
+
frame.writeUInt16BE(0, 2) // proto
|
|
252
|
+
frame.writeUInt16BE(11, 4) // len(unit+PDU)
|
|
253
|
+
frame.writeUInt8(1, 6) // unit
|
|
254
|
+
frame.writeUInt8(16, 7) // FC16
|
|
255
|
+
frame.writeUInt16BE(20, 8) // start = 40021-40001
|
|
256
|
+
frame.writeUInt16BE(2, 10) // qty words
|
|
257
|
+
frame.writeUInt8(4, 12) // byte count
|
|
258
|
+
frame.writeUInt16BE(words[0], 13)
|
|
259
|
+
frame.writeUInt16BE(words[1], 15)
|
|
260
|
+
sock.on('connect', () => sock.write(frame))
|
|
261
|
+
sock.on('data', () => { sock.destroy(); resolve() })
|
|
262
|
+
sock.on('error', () => resolve())
|
|
263
|
+
setTimeout(() => { sock.destroy(); resolve() }, 3000)
|
|
264
|
+
})
|
|
265
|
+
await sleep(22_000) // τ=8s ×3,PV 充分回落(<60)
|
|
266
|
+
}
|
|
267
|
+
const prod = (await api('POST', '/api/workshop/dcw/products', { body: { name: `全协议产品-${TAG}`, lineId: line.id }, token })).data?.product
|
|
268
|
+
const plcSp = dcwNodes.plcsp
|
|
269
|
+
const recipe = (await api('POST', '/api/workshop/dcw/recipes', {
|
|
270
|
+
body: {
|
|
271
|
+
productId: prod.id, name: `全协议配方-${TAG}`,
|
|
272
|
+
params: [{ templateRef: 'dcw-temp-sp', nodeId: plcSp.id, value: 180, min: 176, max: 188 }],
|
|
273
|
+
daqWindows: [{ nodeId: daqNodes.plcpv.id, min: 100, max: 260 }],
|
|
274
|
+
}, token,
|
|
275
|
+
})).data?.recipe
|
|
276
|
+
check('3.1', '产品+配方(PLC-SP 绑工艺窗 176~188)', Boolean(prod?.id && recipe?.id))
|
|
277
|
+
const start = await api('POST', `/api/workshop/dcw/lines/${line.id}/start`, { body: { recipeId: recipe.id }, token })
|
|
278
|
+
check('3.2', '产线开跑(数采门控激活)', start.code === 0, start.message ?? '')
|
|
279
|
+
|
|
280
|
+
// ── 4. DAQ 采样落库 + 数值域 + WS 帧 ──
|
|
281
|
+
const aep = openAep(token)
|
|
282
|
+
await aep.ready
|
|
283
|
+
await sleep(21000) // 采样缺省 5000ms:9s 只攒 ~3 点,21s 保证 n>=4
|
|
284
|
+
for (const d of daqDefs) {
|
|
285
|
+
const node = daqNodes[d.id]
|
|
286
|
+
const s = await api('GET', `/api/workshop/daq/${node.id}/samples?bucketMs=1000`, { token })
|
|
287
|
+
const points = s.data?.points ?? s.data ?? []
|
|
288
|
+
const n = Array.isArray(points) ? points.length : 0
|
|
289
|
+
const lastVal = n > 0 ? Number(Object.values(points[n - 1] ?? {})[1] ?? NaN) : NaN
|
|
290
|
+
const inRange = Number.isFinite(lastVal) && lastVal >= d.expect[0] && lastVal <= d.expect[1]
|
|
291
|
+
check(`4.${d.id}`, `${d.driver} 持续采样落库(Timescale)`, n >= 4 && inRange,
|
|
292
|
+
`points=${n} last=${lastVal} 期望域[${d.expect.join(',')}] ${s.message ?? ''}`)
|
|
293
|
+
}
|
|
294
|
+
const daqFrames = aep.frames.filter(f => f.type === 'daq.reading' || f.type === 'daq.frame')
|
|
295
|
+
check('4.ws', 'WS 实时推送(daq.reading/frame 场景帧)', daqFrames.length >= 10, `frames=${daqFrames.length} total=${aep.frames.length}`)
|
|
296
|
+
|
|
297
|
+
// ── 5. DCW 读(读回设备参数);响应形状 { read: {...} } ──
|
|
298
|
+
const rPlc = await api('POST', `/api/workshop/dcw/${dcwNodes.plcsp.id}/read`, { token })
|
|
299
|
+
const plcRead = Number(rPlc.data?.read?.value ?? rPlc.data?.value ?? NaN)
|
|
300
|
+
check('5.1', 'DCW Modbus 读 SP 寄存器', rPlc.code === 0 && Number.isFinite(plcRead), `value=${plcRead} ${JSON.stringify(rPlc.data ?? {}).slice(0, 120)} ${rPlc.message ?? ''}`)
|
|
301
|
+
const rOpc = await api('POST', `/api/workshop/dcw/${dcwNodes.ocusp.id}/read`, { token })
|
|
302
|
+
const opcRead = Number(rOpc.data?.read?.value ?? rOpc.data?.value ?? NaN)
|
|
303
|
+
check('5.2', 'DCW OPC UA 读节点', rOpc.code === 0 && Number.isFinite(opcRead), `value=${opcRead} data=${JSON.stringify(rOpc.data ?? {}).slice(0, 160)} ${rOpc.message ?? ''}`)
|
|
304
|
+
const rMq = await api('POST', `/api/workshop/dcw/${dcwNodes.mqsp.id}/read`, { token })
|
|
305
|
+
const mqReadVal = rMq.data?.read?.value ?? rMq.data?.value
|
|
306
|
+
check('5.3', 'DCW MQTT 读=能力外优雅报错(仅下行)', !Number.isFinite(Number(mqReadVal)) && (rMq.code !== 0 || rMq.data?.read?.ok === false || rMq.data?.ok === false), `code=${rMq.code} read=${JSON.stringify(rMq.data?.read ?? {}).slice(0, 100)}`)
|
|
307
|
+
|
|
308
|
+
// ── 6. DCW 写 ×4 ──
|
|
309
|
+
// 6.1 MQTT 下行:先建订阅(不等待)→ 驱动写 → 收到的报文即真实链路证据
|
|
310
|
+
let mqttRx = null
|
|
311
|
+
try {
|
|
312
|
+
const { default: mqtt } = await import('mqtt')
|
|
313
|
+
const sub = await new Promise((resolve) => {
|
|
314
|
+
const c = mqtt.connect('mqtt://127.0.0.1:18830', { connectTimeout: 4000 })
|
|
315
|
+
const timer = setTimeout(() => { c.end(true); resolve(null) }, 8000)
|
|
316
|
+
c.on('connect', () => c.subscribe(`aw/sim/setpoint-${TAG}`, { qos: 1 }, () => { clearTimeout(timer); resolve(c) }))
|
|
317
|
+
c.on('error', () => { clearTimeout(timer); resolve(null) })
|
|
318
|
+
})
|
|
319
|
+
if (sub) {
|
|
320
|
+
const wMq = await api('POST', `/api/workshop/dcw/${dcwNodes.mqsp.id}/write`, { body: { value: 165.5 }, token })
|
|
321
|
+
check("6.1a", "DCW MQTT 下发执行", wMq.code === 0 && wMq.data?.outcome?.ok === true, JSON.stringify(wMq.data ?? wMq.message ?? {}).slice(0, 140))
|
|
322
|
+
mqttRx = await new Promise((resolve) => {
|
|
323
|
+
const timer = setTimeout(() => { sub.end(true); resolve(null) }, 10_000)
|
|
324
|
+
sub.on('message', (_t, payload) => { clearTimeout(timer); sub.end(true); resolve(payload.toString()) })
|
|
325
|
+
})
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
catch { /* mqtt 包不可用则跳过订阅验证 */ }
|
|
329
|
+
// broker 侧确定性验收:模拟器把真实路由落盘(broker 收到即证据,不依赖订阅端时序)
|
|
330
|
+
let auditHit = null
|
|
331
|
+
{
|
|
332
|
+
const auditPath = resolve('.AgentWorkShop/data/sim-setpoint-routes.log')
|
|
333
|
+
for (let i = 0; i < 10 && !auditHit; i++) {
|
|
334
|
+
await sleep(1000)
|
|
335
|
+
try {
|
|
336
|
+
const content = fs.readFileSync(auditPath, 'utf-8')
|
|
337
|
+
auditHit = content.split('\n').reverse().find(l => l.includes(`aw/sim/setpoint-${TAG}`)) ?? null
|
|
338
|
+
}
|
|
339
|
+
catch { /* 文件未生成 */ }
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
check('6.1b', 'DCW MQTT 真实报文抵达 Broker(broker 路由审计)', auditHit !== null && auditHit.includes('165.5'), `audit=${auditHit?.trim() ?? 'null'}`)
|
|
343
|
+
// 环境噪声重试:broker 实例可能在订阅/发布之间被杀换新,换全新订阅再写一次
|
|
344
|
+
if (auditHit === null) {
|
|
345
|
+
try {
|
|
346
|
+
const { default: mqtt2 } = await import('mqtt')
|
|
347
|
+
const sub2 = await new Promise((resolve) => {
|
|
348
|
+
const c = mqtt2.connect('mqtt://127.0.0.1:18830', { connectTimeout: 3000 })
|
|
349
|
+
const timer = setTimeout(() => { c.end(true); resolve(null) }, 6000)
|
|
350
|
+
c.on('connect', () => c.subscribe(`aw/sim/setpoint-${TAG}`, { qos: 1 }, () => { clearTimeout(timer); resolve(c) }))
|
|
351
|
+
c.on('error', () => { clearTimeout(timer); resolve(null) })
|
|
352
|
+
})
|
|
353
|
+
if (sub2) {
|
|
354
|
+
await api('POST', `/api/workshop/dcw/${dcwNodes.mqsp.id}/write`, { body: { value: 165.5 }, token })
|
|
355
|
+
mqttRx = await new Promise((resolve) => {
|
|
356
|
+
const timer = setTimeout(() => { sub2.end(true); resolve(null) }, 8000)
|
|
357
|
+
sub2.on('message', (_t, payload) => { clearTimeout(timer); sub2.end(true); resolve(payload.toString()) })
|
|
358
|
+
})
|
|
359
|
+
check('6.1b-retry', 'DCW MQTT 报文抵达(重订重写)', mqttRx !== null && mqttRx.includes('165.5'), `payload=${mqttRx}`)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
catch { /* ignore */ }
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// 6.2 HTTP 下发:经驱动 POST,模拟器日志留痕
|
|
366
|
+
const wHt = await api('POST', `/api/workshop/dcw/${dcwNodes.htsp.id}/write`, { body: { value: 168.25 }, token })
|
|
367
|
+
check("6.2a", "DCW HTTP 下发执行", wHt.code === 0 && wHt.data?.outcome?.ok === true, JSON.stringify(wHt.data ?? wHt.message ?? {}).slice(0, 140))
|
|
368
|
+
|
|
369
|
+
// 6.3 OPC UA 写 + 回读校验
|
|
370
|
+
const wOpc = await api('POST', `/api/workshop/dcw/${dcwNodes.ocusp.id}/write`, { body: { value: 172.5 }, token })
|
|
371
|
+
check("6.3a", "DCW OPC UA 写入", wOpc.code === 0 && wOpc.data?.outcome?.ok === true, JSON.stringify(wOpc.data ?? wOpc.message ?? {}).slice(0, 140))
|
|
372
|
+
await sleep(1200)
|
|
373
|
+
const rOpc2 = await api('POST', `/api/workshop/dcw/${dcwNodes.ocusp.id}/read`, { token })
|
|
374
|
+
const opc2 = Number(rOpc2.data?.read?.value ?? rOpc2.data?.value ?? NaN)
|
|
375
|
+
check('6.3b', 'DCW OPC UA 回读=172.5±1', Number.isFinite(opc2) && Math.abs(opc2 - 172.5) <= 1, `read=${opc2}`)
|
|
376
|
+
|
|
377
|
+
// 6.4 PLC Modbus 写(配方窗内)+ 真闭环 SP→PV 收敛
|
|
378
|
+
const wPlc = await api('POST', `/api/workshop/dcw/${plcSp.id}/write`, { body: { value: 182 }, token })
|
|
379
|
+
check("6.4a", "DCW Modbus 写 SP=182(配方窗内)", wPlc.code === 0 && wPlc.data?.outcome?.ok === true, JSON.stringify(wPlc.data ?? wPlc.message ?? {}).slice(0, 140))
|
|
380
|
+
const wPlcBad = await api('POST', `/api/workshop/dcw/${plcSp.id}/write`, { body: { value: 195 }, token })
|
|
381
|
+
check('6.4b', '配方窗联锁负例(195 越窗 → 400)', wPlcBad.status === 400, `status=${wPlcBad.status} msg=${String(wPlcBad.message ?? '').slice(0, 80)}`)
|
|
382
|
+
|
|
383
|
+
// PLC 一阶热惯性:PV 从 ~26(预置衰减后)随配方 SP=180 + 写 182 爬升收敛
|
|
384
|
+
const pvNode = daqNodes.plcpv
|
|
385
|
+
const pvStart = await api('GET', `/api/workshop/daq/${pvNode.id}/samples?bucketMs=1000`, { token })
|
|
386
|
+
const pv0 = (pvStart.data?.points ?? []).slice(-3).map(p => Number(Object.values(p)[1])).filter(Number.isFinite).at(-1)
|
|
387
|
+
let pvLastSeen = null
|
|
388
|
+
let pvEnd = null
|
|
389
|
+
let pvDiag = ''
|
|
390
|
+
try {
|
|
391
|
+
pvEnd = await waitUntil('PV 收敛', async () => {
|
|
392
|
+
const s = await api('GET', `/api/workshop/daq/${pvNode.id}/samples?bucketMs=1000`, { token })
|
|
393
|
+
const pts = s.data?.points ?? []
|
|
394
|
+
const v = pts.slice(-2).map(p => Number(Object.values(p)[1])).find(Number.isFinite)
|
|
395
|
+
if (Number.isFinite(v)) pvLastSeen = v
|
|
396
|
+
const view = await api('GET', '/api/workshop/daq', { token })
|
|
397
|
+
const me = (Array.isArray(view.data) ? view.data : (view.data?.nodes ?? [])).find(x => x.id === pvNode.id)
|
|
398
|
+
const lines = await api('GET', '/api/workshop/dcw/lines', { token })
|
|
399
|
+
const ln = (Array.isArray(lines.data) ? lines.data : (lines.data?.lines ?? [])).find(l => l.id === line.id)
|
|
400
|
+
pvDiag = `pts=${pts.length} node=${me?.state} err=${String(me?.lastError ?? '-').slice(0, 40)} lineRun=${ln && (ln.activeRun || ln.run) ? 'on' : 'off'}`
|
|
401
|
+
return Number.isFinite(v) && v >= 170 ? v : null
|
|
402
|
+
}, 90_000, 2500)
|
|
403
|
+
} catch { /* keep null */ }
|
|
404
|
+
// 物理真值回退:DAQ 观测链若被环境中断(模拟器运行中被杀/ revived),直接裸读寄存器验证闭环
|
|
405
|
+
let rawSp = null
|
|
406
|
+
let rawPv = null
|
|
407
|
+
if (!pvEnd) {
|
|
408
|
+
await new Promise((resolveRaw) => {
|
|
409
|
+
const sock = net.connect(15040, '127.0.0.1')
|
|
410
|
+
let buf = Buffer.alloc(0)
|
|
411
|
+
sock.on('connect', () => sock.write(Buffer.from([0, 1, 0, 0, 0, 6, 1, 3, 0, 0, 0, 0x16])))
|
|
412
|
+
sock.on('data', (d) => {
|
|
413
|
+
buf = Buffer.concat([buf, d])
|
|
414
|
+
if (buf.length >= 9 + 44) {
|
|
415
|
+
rawPv = Number(buf.subarray(9, 13).readFloatBE(0).toFixed(1))
|
|
416
|
+
rawSp = Number(buf.subarray(49, 53).readFloatBE(0).toFixed(1))
|
|
417
|
+
sock.destroy(); resolveRaw()
|
|
418
|
+
}
|
|
419
|
+
})
|
|
420
|
+
sock.on('error', () => resolveRaw())
|
|
421
|
+
setTimeout(() => { sock.destroy(); resolveRaw() }, 4000)
|
|
422
|
+
})
|
|
423
|
+
}
|
|
424
|
+
const loopProven = (Number.isFinite(pv0) && pv0 < 60 && Number.isFinite(pvEnd) && pvEnd >= 170)
|
|
425
|
+
|| (rawSp !== null && Math.abs(rawSp - 182) <= 2 && rawPv !== null && Math.abs(rawPv - rawSp) <= 6)
|
|
426
|
+
check('6.4c', '真实闭环:PLC PV 随 SP 收敛(≈26→≥170)', loopProven, `pv0=${pv0} pvEnd=${pvEnd} lastSeen=${pvLastSeen} | rawSP=${rawSp} rawPV=${rawPv} ${pvDiag}`)
|
|
427
|
+
|
|
428
|
+
// ── 7. 写后节点视图一致性 + journal ──
|
|
429
|
+
const list = await api('GET', '/api/workshop/dcw', { token })
|
|
430
|
+
const nodes = Array.isArray(list.data) ? list.data : (list.data?.nodes ?? [])
|
|
431
|
+
const plcNow = nodes.find(n => n.id === plcSp.id)
|
|
432
|
+
check('7.1', 'DCW 节点 readValue 收敛 182±2', plcNow && Math.abs(Number(plcNow.readValue) - 182) <= 2, `readValue=${plcNow?.readValue}`)
|
|
433
|
+
const journal = await api('GET', `/api/workshop/dcw/journal?nodeId=${plcSp.id}`, { token })
|
|
434
|
+
check('7.2', '写账本留痕(journal anchors)', (journal.data?.anchors ?? []).length >= 1, `anchors=${(journal.data?.anchors ?? []).length}`)
|
|
435
|
+
|
|
436
|
+
// ── 清理 ──
|
|
437
|
+
await api('POST', `/api/workshop/dcw/lines/${line.id}/stop`, { token }).catch(() => {})
|
|
438
|
+
for (const n of Object.values(daqNodes)) await api('DELETE', `/api/workshop/daq/${n.id}`, { token }).catch(() => {})
|
|
439
|
+
for (const n of Object.values(dcwNodes)) await api('DELETE', `/api/workshop/dcw/${n.id}`, { token }).catch(() => {})
|
|
440
|
+
await api('DELETE', `/api/workshop/dcw/lines/${line.id}`, { token }).catch(() => {})
|
|
441
|
+
|
|
442
|
+
console.log(`\n━━━ 矩阵结果: ${passed} passed / ${failures} failed ━━━`)
|
|
443
|
+
if (failures) {
|
|
444
|
+
console.log('失败项:')
|
|
445
|
+
for (const r of results.filter(x => !x.ok)) console.log(` ${r.id} ${r.name} — ${r.detail}`)
|
|
446
|
+
}
|
|
447
|
+
process.exit(failures === 0 ? 0 : 1)
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
main().catch((err) => {
|
|
451
|
+
console.error('FATAL', err)
|
|
452
|
+
process.exit(1)
|
|
453
|
+
})
|