agentworkshop 0.7.24 → 0.7.27

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 (243) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/2jaJHWIJ.js +1 -0
  3. package/.output/public/_nuxt/B7gZokg82.js +209 -0
  4. package/.output/public/_nuxt/{Dfe8vXdG.js → B8kt898d.js} +1 -1
  5. package/.output/public/_nuxt/{BvNJUu3s.js → BFGpEo8S.js} +1 -1
  6. package/.output/public/_nuxt/{BAfp6tmu.js → BG4zduPf.js} +5 -5
  7. package/.output/public/_nuxt/{BMb80_tm.js → BGhOrgle.js} +1 -1
  8. package/.output/public/_nuxt/{Bc-_IsBP.js → BHcpzI2n.js} +1 -1
  9. package/.output/public/_nuxt/{Djir5rSD.js → BTLEvDxM.js} +1 -1
  10. package/.output/public/_nuxt/{b50gYVZl.js → BWyR3awA.js} +1 -1
  11. package/.output/public/_nuxt/Bc89zKq2.js +1 -0
  12. package/.output/public/_nuxt/{CxY6LfeN.js → BetmGSO4.js} +1 -1
  13. package/.output/public/_nuxt/{DAR70Lf52.js → BgCrZKv_2.js} +1 -1
  14. package/.output/public/_nuxt/{DUToq-k_.js → BowTbasd.js} +1 -1
  15. package/.output/public/_nuxt/{D6HDb-vN2.js → BvtknqSC2.js} +1 -1
  16. package/.output/public/_nuxt/{CLZWFhZC.js → CTfqWGdy.js} +1 -1
  17. package/.output/public/_nuxt/Chc5pfAA.js +1 -0
  18. package/.output/public/_nuxt/CobSUzQv.js +2 -0
  19. package/.output/public/_nuxt/{kZV5TQvh2.js → CucID8qg2.js} +1 -1
  20. package/.output/public/_nuxt/{CAGL7TNK.js → DHbTyoAV.js} +1 -1
  21. package/.output/public/_nuxt/{DSa2O56y.js → DfLUN8kY.js} +1 -1
  22. package/.output/public/_nuxt/{Coik560n.js → DjU9Dx5Y.js} +1 -1
  23. package/.output/public/_nuxt/DnziMlcX.js +1 -0
  24. package/.output/public/_nuxt/{Ct68Z0232.js → DosOJEmZ2.js} +1 -1
  25. package/.output/public/_nuxt/{CDLv-n51.js → Q_SJDSgx.js} +1 -1
  26. package/.output/public/_nuxt/{TownView.zu2rU5nS.css → TownView.CtskuMXS.css} +1 -1
  27. package/.output/public/_nuxt/{CuVGPuP1.js → XY2z78rj.js} +1 -1
  28. package/.output/public/_nuxt/_id_.DdbYeLqn.css +1 -0
  29. package/.output/public/_nuxt/{C1CSiSBN.js → bFnZa2yd.js} +1 -1
  30. package/.output/public/_nuxt/builds/latest.json +1 -1
  31. package/.output/public/_nuxt/builds/meta/f7a8e33d-5422-45ac-895d-27168f97e3ad.json +1 -0
  32. package/.output/public/_nuxt/daq.DGV9QS8d.css +1 -0
  33. package/.output/public/_nuxt/{entry.AZM1Culo.css → entry.BN02X8iR.css} +1 -1
  34. package/.output/public/_nuxt/{X6IraCTB.js → rkVgzg62.js} +1 -1
  35. package/.output/public/_nuxt/settings.W6qrYAui.css +1 -0
  36. package/.output/public/_nuxt/teams.BBXVkyKq.css +1 -0
  37. package/.output/public/assets/game/character/yangyang-walk.glb +0 -0
  38. package/.output/server/chunks/_/host-bindings.mjs +1 -1
  39. package/.output/server/chunks/_/nitro.mjs +1013 -844
  40. package/.output/server/chunks/_/nitro.mjs.map +1 -1
  41. package/.output/server/chunks/build/{TownView-DxeQe1Bl.mjs → TownView-ftIylqiD.mjs} +178 -151
  42. package/.output/server/chunks/build/{TownView-DxeQe1Bl.mjs.map → TownView-ftIylqiD.mjs.map} +1 -1
  43. package/.output/server/chunks/build/{_id_-DQDqj-cZ.mjs → _id_-3Axz2-gV.mjs} +35 -35
  44. package/.output/server/chunks/build/{_id_-DQDqj-cZ.mjs.map → _id_-3Axz2-gV.mjs.map} +1 -1
  45. package/.output/server/chunks/build/{_id_-DY6v6sqB.mjs → _id_-CahfkmEt.mjs} +5 -5
  46. package/.output/server/chunks/build/{_id_-DY6v6sqB.mjs.map → _id_-CahfkmEt.mjs.map} +1 -1
  47. package/.output/server/chunks/build/{_wsId_-D38Vx6Ky.mjs → _wsId_-BymlQhzS.mjs} +7 -7
  48. package/.output/server/chunks/build/{_wsId_-D38Vx6Ky.mjs.map → _wsId_-BymlQhzS.mjs.map} +1 -1
  49. package/.output/server/chunks/build/{agents-GnmUGZir.mjs → agents-DuMiSWKp.mjs} +4 -4
  50. package/.output/server/chunks/build/{agents-GnmUGZir.mjs.map → agents-DuMiSWKp.mjs.map} +1 -1
  51. package/.output/server/chunks/build/{channel-templates-B4z6v8Z5.mjs → channel-templates-BStqJ-of.mjs} +2 -2
  52. package/.output/server/chunks/build/{channel-templates-B4z6v8Z5.mjs.map → channel-templates-BStqJ-of.mjs.map} +1 -1
  53. package/.output/server/chunks/build/{checkbox-dzcpU_Cd.mjs → checkbox-C1gABOca.mjs} +4 -4
  54. package/.output/server/chunks/build/{checkbox-dzcpU_Cd.mjs.map → checkbox-C1gABOca.mjs.map} +1 -1
  55. package/.output/server/chunks/build/{daq-B-3xCp_2.mjs → daq-ChYCABz1.mjs} +312 -426
  56. package/.output/server/chunks/build/daq-ChYCABz1.mjs.map +1 -0
  57. package/.output/server/chunks/build/{dcw-BL2dhuz7.mjs → dcw-CcQNGggh.mjs} +3 -3
  58. package/.output/server/chunks/build/{dcw-BL2dhuz7.mjs.map → dcw-CcQNGggh.mjs.map} +1 -1
  59. package/.output/server/chunks/build/{default-CLf5m0NE.mjs → default-95-zOTPt.mjs} +2 -2
  60. package/.output/server/chunks/build/{default-CLf5m0NE.mjs.map → default-95-zOTPt.mjs.map} +1 -1
  61. package/.output/server/chunks/build/{logs-Dto_umFY.mjs → logs-D-2UyGtE.mjs} +3 -3
  62. package/.output/server/chunks/build/{logs-Dto_umFY.mjs.map → logs-D-2UyGtE.mjs.map} +1 -1
  63. package/.output/server/chunks/build/{monitor-Cp4V-H2n.mjs → monitor-mfG5jBtz.mjs} +3 -3
  64. package/.output/server/chunks/build/{monitor-Cp4V-H2n.mjs.map → monitor-mfG5jBtz.mjs.map} +1 -1
  65. package/.output/server/chunks/build/{pages-Dc2H1QFu.mjs → pages-Dfosfchr.mjs} +4 -4
  66. package/.output/server/chunks/build/{pages-Dc2H1QFu.mjs.map → pages-Dfosfchr.mjs.map} +1 -1
  67. package/.output/server/chunks/build/{permissions-BTRW2CVd.mjs → permissions-B-hhZuzm.mjs} +3 -3
  68. package/.output/server/chunks/build/{permissions-BTRW2CVd.mjs.map → permissions-B-hhZuzm.mjs.map} +1 -1
  69. package/.output/server/chunks/build/{settings-UfGyDgM7.mjs → settings-BajN9TQW.mjs} +249 -20
  70. package/.output/server/chunks/build/settings-BajN9TQW.mjs.map +1 -0
  71. package/.output/server/chunks/build/{table-Cswq-l2r.mjs → table-Bf1r2JjE.mjs} +2 -2
  72. package/.output/server/chunks/build/{table-Cswq-l2r.mjs.map → table-Bf1r2JjE.mjs.map} +1 -1
  73. package/.output/server/chunks/build/{teams-Cbg27MWW.mjs → teams-t2SkRlJP.mjs} +346 -46
  74. package/.output/server/chunks/build/teams-t2SkRlJP.mjs.map +1 -0
  75. package/.output/server/chunks/build/{tokens-Bmm6rDfj.mjs → tokens-DiCojbN8.mjs} +3 -3
  76. package/.output/server/chunks/build/{tokens-Bmm6rDfj.mjs.map → tokens-DiCojbN8.mjs.map} +1 -1
  77. package/.output/server/chunks/build/{town-Dsh0jlwZ.mjs → town-C7QM8DYK.mjs} +5 -5
  78. package/.output/server/chunks/build/{town-Dsh0jlwZ.mjs.map → town-C7QM8DYK.mjs.map} +1 -1
  79. package/.output/server/chunks/build/{useDaqStream-DkRL3tEW.mjs → useDaqStream-BeA2X8KR.mjs} +26 -11
  80. package/.output/server/chunks/build/useDaqStream-BeA2X8KR.mjs.map +1 -0
  81. package/.output/server/chunks/build/{useDcwStream-DyB2ufQI.mjs → useDcwStream-BJW_MitY.mjs} +14 -6
  82. package/.output/server/chunks/build/useDcwStream-BJW_MitY.mjs.map +1 -0
  83. package/.output/server/chunks/build/{useDeviceTwins-ZbT86L9O.mjs → useDeviceTwins-Dwz_EY_i.mjs} +2 -2
  84. package/.output/server/chunks/build/{useDeviceTwins-ZbT86L9O.mjs.map → useDeviceTwins-Dwz_EY_i.mjs.map} +1 -1
  85. package/.output/server/chunks/build/{useOpsLog-8HCYFb6n.mjs → useOpsLog-Dm8QEb1I.mjs} +2 -2
  86. package/.output/server/chunks/build/{useOpsLog-8HCYFb6n.mjs.map → useOpsLog-Dm8QEb1I.mjs.map} +1 -1
  87. package/.output/server/chunks/build/{useWorkshopApi-D2gq06N2.mjs → useWorkshopApi-B-L3MmIX.mjs} +9 -2
  88. package/.output/server/chunks/build/{useWorkshopApi-D2gq06N2.mjs.map → useWorkshopApi-B-L3MmIX.mjs.map} +1 -1
  89. package/.output/server/chunks/build/{users-B50HHrfi.mjs → users-B9SAdEtH.mjs} +3 -3
  90. package/.output/server/chunks/build/{users-B50HHrfi.mjs.map → users-B9SAdEtH.mjs.map} +1 -1
  91. package/.output/server/chunks/routes/api/plugins/_name/_...path_.mjs +14 -2
  92. package/.output/server/chunks/routes/api/plugins/_name/_...path_.mjs.map +1 -1
  93. package/.output/server/chunks/routes/api/workshop/channel-templates/_id/instantiate.post.mjs +1 -1
  94. package/.output/server/chunks/routes/api/workshop/channels/_id/index.put.mjs +40 -0
  95. package/.output/server/chunks/routes/api/workshop/channels/_id/index.put.mjs.map +1 -0
  96. package/.output/server/chunks/routes/api/workshop/channels/_id/index4.get.mjs +21 -9
  97. package/.output/server/chunks/routes/api/workshop/channels/_id/index4.get.mjs.map +1 -1
  98. package/.output/server/chunks/routes/api/workshop/channels/_id/index5.get.mjs +33 -0
  99. package/.output/server/chunks/routes/api/workshop/channels/_id/index5.get.mjs.map +1 -0
  100. package/.output/server/chunks/routes/api/workshop/channels/_id/terminals.get.mjs +1 -1
  101. package/.output/server/chunks/routes/api/workshop/channels.post.mjs +15 -1
  102. package/.output/server/chunks/routes/api/workshop/channels.post.mjs.map +1 -1
  103. package/.output/server/chunks/routes/api/workshop/daq/_id/bind.post.mjs +1 -1
  104. package/.output/server/chunks/routes/api/workshop/daq/_id/bindings.put.mjs +1 -1
  105. package/.output/server/chunks/routes/api/workshop/daq/_id/frames/content.get.mjs +1 -1
  106. package/.output/server/chunks/routes/api/workshop/daq/_id/frames.get.mjs +1 -1
  107. package/.output/server/chunks/routes/api/workshop/daq/_id/samples.get.mjs +1 -1
  108. package/.output/server/chunks/routes/api/workshop/daq/_id/test.post.mjs +1 -1
  109. package/.output/server/chunks/routes/api/workshop/daq/_id_.delete.mjs +1 -1
  110. package/.output/server/chunks/routes/api/workshop/daq/_id_.patch.mjs +1 -1
  111. package/.output/server/chunks/routes/api/workshop/daq/alarms/_id/ack.post.mjs +1 -1
  112. package/.output/server/chunks/routes/api/workshop/daq/controller.post.mjs +1 -1
  113. package/.output/server/chunks/routes/api/workshop/daq/index.post.mjs +1 -1
  114. package/.output/server/chunks/routes/api/workshop/daq/infra/reconnect.post.mjs +1 -1
  115. package/.output/server/chunks/routes/api/workshop/daq/infra.get.mjs +1 -1
  116. package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.delete.mjs +1 -1
  117. package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.patch.mjs +1 -1
  118. package/.output/server/chunks/routes/api/workshop/daq/test-driver.post.mjs +1 -1
  119. package/.output/server/chunks/routes/api/workshop/dcw/_id/bind.post.mjs +1 -1
  120. package/.output/server/chunks/routes/api/workshop/dcw/_id/bindings.put.mjs +1 -1
  121. package/.output/server/chunks/routes/api/workshop/dcw/_id/param-ledger.get.mjs +1 -1
  122. package/.output/server/chunks/routes/api/workshop/dcw/_id/read.post.mjs +1 -1
  123. package/.output/server/chunks/routes/api/workshop/dcw/_id/test.post.mjs +1 -1
  124. package/.output/server/chunks/routes/api/workshop/dcw/_id/write.post.mjs +1 -1
  125. package/.output/server/chunks/routes/api/workshop/dcw/_id_.delete.mjs +1 -1
  126. package/.output/server/chunks/routes/api/workshop/dcw/_id_.patch.mjs +1 -1
  127. package/.output/server/chunks/routes/api/workshop/dcw/controller.post.mjs +1 -1
  128. package/.output/server/chunks/routes/api/workshop/dcw/index.get.mjs +1 -1
  129. package/.output/server/chunks/routes/api/workshop/dcw/index.post.mjs +1 -1
  130. package/.output/server/chunks/routes/api/workshop/dcw/index2.get.mjs +1 -1
  131. package/.output/server/chunks/routes/api/workshop/dcw/index2.post.mjs +1 -1
  132. package/.output/server/chunks/routes/api/workshop/dcw/index3.get.mjs +1 -1
  133. package/.output/server/chunks/routes/api/workshop/dcw/index3.post.mjs +1 -1
  134. package/.output/server/chunks/routes/api/workshop/dcw/index4.get.mjs +1 -1
  135. package/.output/server/chunks/routes/api/workshop/dcw/index4.post.mjs +1 -1
  136. package/.output/server/chunks/routes/api/workshop/dcw/index5.get.mjs +1 -1
  137. package/.output/server/chunks/routes/api/workshop/dcw/journal/node/_nodeId/rollback.post.mjs +1 -1
  138. package/.output/server/chunks/routes/api/workshop/dcw/line/query.get.mjs +1 -1
  139. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/start.post.mjs +1 -1
  140. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/stop.post.mjs +1 -1
  141. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id_.delete.mjs +1 -1
  142. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/judge.post.mjs +1 -1
  143. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/rollback.post.mjs +1 -1
  144. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/series.get.mjs +1 -1
  145. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id_.get.mjs +1 -1
  146. package/.output/server/chunks/routes/api/workshop/dcw/products/_id_.delete.mjs +1 -1
  147. package/.output/server/chunks/routes/api/workshop/dcw/products/_id_.patch.mjs +1 -1
  148. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/apply.post.mjs +1 -1
  149. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/mark-good.post.mjs +1 -1
  150. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/rollback-good.post.mjs +1 -1
  151. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id_.delete.mjs +1 -1
  152. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/close.post.mjs +1 -1
  153. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/data.get.mjs +1 -1
  154. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/rollback.post.mjs +1 -1
  155. package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.delete.mjs +1 -1
  156. package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.patch.mjs +1 -1
  157. package/.output/server/chunks/routes/api/workshop/dcw/test-driver.post.mjs +1 -1
  158. package/.output/server/chunks/routes/api/workshop/device-twins/_id_.delete.mjs +1 -1
  159. package/.output/server/chunks/routes/api/workshop/device-twins/_id_.patch.mjs +1 -1
  160. package/.output/server/chunks/routes/api/workshop/harnesses/_id/providers.get.mjs +1 -1
  161. package/.output/server/chunks/routes/api/workshop/harnesses.get.mjs +1 -1
  162. package/.output/server/chunks/routes/api/workshop/hitl/pending.get.mjs +1 -1
  163. package/.output/server/chunks/routes/api/workshop/hitl/respond.post.mjs +1 -1
  164. package/.output/server/chunks/routes/api/workshop/index.put.mjs +1 -1
  165. package/.output/server/chunks/routes/api/workshop/index3.post.mjs +1 -1
  166. package/.output/server/chunks/routes/api/workshop/index4.get.mjs +1 -1
  167. package/.output/server/chunks/routes/api/workshop/index4.post.mjs +1 -1
  168. package/.output/server/chunks/routes/api/workshop/index5.get.mjs +1 -1
  169. package/.output/server/chunks/routes/api/workshop/index5.post.mjs +1 -1
  170. package/.output/server/chunks/routes/api/workshop/index6.post.mjs +1 -1
  171. package/.output/server/chunks/routes/api/workshop/plugins/_name/disable.post.mjs +1 -1
  172. package/.output/server/chunks/routes/api/workshop/plugins/_name/enable.post.mjs +1 -1
  173. package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.delete.mjs +1 -1
  174. package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.put.mjs +1 -1
  175. package/.output/server/chunks/routes/api/workshop/workspaces/_id/channel-templates/_tplId_.post.mjs +1 -1
  176. package/.output/server/chunks/routes/renderer.mjs +2 -2
  177. package/.output/server/chunks/virtual/entry.mjs +352 -433
  178. package/.output/server/chunks/virtual/precomputed.mjs +1 -1
  179. package/.output/server/package.json +1 -1
  180. package/app/components/workshop/DaqNodeRow.vue +398 -0
  181. package/app/components/workshop/town/ModelPreview3D.vue +26 -4
  182. package/app/components/workshop/town/TownScene3D.ts +60 -12
  183. package/app/components/workshop/town/TownView.vue +4 -3
  184. package/app/composables/workshop/useCharacterAssets.ts +1 -0
  185. package/app/composables/workshop/useDaqStream.ts +24 -5
  186. package/app/composables/workshop/useDcwStream.ts +13 -4
  187. package/app/composables/workshop/useWorkshopApi.ts +294 -259
  188. package/app/pages/daq/[id].vue +27 -3
  189. package/app/pages/daq/index.vue +8 -355
  190. package/app/pages/settings.vue +253 -2
  191. package/app/pages/workshop/teams.vue +212 -2
  192. package/i18n/dicts/_en.json +361 -1
  193. package/i18n/dicts/plugins.json +10 -0
  194. package/i18n/dicts/settings.json +1 -0
  195. package/i18n/dicts/teamPlugins.json +10 -0
  196. package/i18n/locales/en.ts +1860 -1900
  197. package/i18n/locales/zh-CN.ts +1788 -1829
  198. package/package.json +149 -148
  199. package/public/assets/game/character/yangyang-walk.glb +0 -0
  200. package/scripts/_dbg-cpu-profile.mjs +53 -0
  201. package/scripts/_dbg-render-perf.mjs +142 -0
  202. package/scripts/_dbg-render-regression.mjs +130 -0
  203. package/scripts/i18n-merge.mjs +152 -30
  204. package/scripts/production-closed-loop-e2e.mjs +254 -0
  205. package/scripts/team-plugins-api-smoke.mjs +149 -0
  206. package/scripts/three-system-e2e.mjs +448 -0
  207. package/server/api/plugins/[name]/[...path].ts +46 -31
  208. package/server/api/workshop/channels/[id]/plugins/index.get.ts +35 -0
  209. package/server/api/workshop/channels/[id]/plugins/index.put.ts +39 -0
  210. package/server/api/workshop/channels.post.ts +17 -0
  211. package/server/data/dcw-lines.json +7 -0
  212. package/server/data/dcw-products.json +7 -0
  213. package/server/data/dcw-recipes.json +1 -1
  214. package/server/data/dcw-rollback.json +523 -11
  215. package/server/data/dcw-writes.json +72 -0
  216. package/server/data/dcws.json +368 -368
  217. package/server/data/scene-layouts.json +66 -0
  218. package/server/plugins/aw-plugins.ts +35 -27
  219. package/server/plugins-builtin/diag-bridge/index.mjs +556 -0
  220. package/server/plugins-builtin/rag-bridge/index.mjs +364 -0
  221. package/server/services/workshop/agents/host-tool-bridge.ts +659 -642
  222. package/server/services/workshop/agents/omp-agent.ts +1178 -1178
  223. package/server/services/workshop/agents/plugin-tools.ts +10 -1
  224. package/server/services/workshop/db/channel-plugins.repo.ts +65 -0
  225. package/server/services/workshop/plugins/host.mjs +52 -4
  226. package/server/services/workshop/runtime/manager.ts +2976 -2968
  227. package/shared/config/schema.json +4 -0
  228. package/.output/public/_nuxt/BUcmySDa2.js +0 -209
  229. package/.output/public/_nuxt/CYzpZzB_.js +0 -1
  230. package/.output/public/_nuxt/CjXIpPMR.js +0 -1
  231. package/.output/public/_nuxt/DKHcFE1i.js +0 -1
  232. package/.output/public/_nuxt/DjtE7AYt.js +0 -1
  233. package/.output/public/_nuxt/JOwsShod.js +0 -2
  234. package/.output/public/_nuxt/_id_.C-YXjn8Q.css +0 -1
  235. package/.output/public/_nuxt/builds/meta/024de5f7-6a10-4f53-82ab-bc65f3ec9e35.json +0 -1
  236. package/.output/public/_nuxt/daq.3OKj58HH.css +0 -1
  237. package/.output/public/_nuxt/settings.BqMF2nfj.css +0 -1
  238. package/.output/public/_nuxt/teams.DN0pAGGu.css +0 -1
  239. package/.output/server/chunks/build/daq-B-3xCp_2.mjs.map +0 -1
  240. package/.output/server/chunks/build/settings-UfGyDgM7.mjs.map +0 -1
  241. package/.output/server/chunks/build/teams-Cbg27MWW.mjs.map +0 -1
  242. package/.output/server/chunks/build/useDaqStream-DkRL3tEW.mjs.map +0 -1
  243. package/.output/server/chunks/build/useDcwStream-DyB2ufQI.mjs.map +0 -1
@@ -0,0 +1,364 @@
1
+ /**
2
+ * rag-bridge —— rag-knowledge 知识库桥接插件。
3
+ *
4
+ * 把本地 rag-knowledge 服务(FastAPI 后端 + Nuxt web)集成为 AgentWorkShop 的
5
+ * 团队知识库:启动即确保「aw-industrial」知识库存在,并向 agent 注入三个工具——
6
+ * kb_search(全库检索)/ kb_store(经验沉淀)/ kb_index(文档入库)。
7
+ * 另开放 /health、/search、/experience 三个插件 API 便于运维探查。
8
+ * 服务不可达时工具返回 isError 文本(含原因与修复建议),绝不抛异常拖垮宿主。
9
+ */
10
+ const KB_NAME = 'aw-industrial'
11
+ const CATEGORIES = ['best_practice', 'troubleshooting', 'lesson_learned', 'optimization', 'tip', 'workflow', 'decision']
12
+ const DEFAULT_BASE = 'http://127.0.0.1:8770' // FastAPI 后端
13
+ const DEFAULT_WEB = 'http://127.0.0.1:6789' // Nuxt web(文档写盘)
14
+
15
+ export default {
16
+ name: 'rag-bridge',
17
+ version: '1.0.0',
18
+ description: 'rag-knowledge 知识库桥接:工业知识检索/经验沉淀/文档入库三工具',
19
+ auth: 'user', // 平台转发层按此声明统一校验(缺省 'none' 开放)
20
+ async setup(ctx) {
21
+ // ---- 运行态 ----
22
+ const state = { outbound: true } // base_url 非法时禁用全部出站调用
23
+ const base = () => trimSlash(String(ctx.config?.get?.('plugins.kb.base_url') || ctx.kv.get('kb.base_url') || DEFAULT_BASE))
24
+ const web = () => trimSlash(String(ctx.config?.get?.('plugins.kb.web_url') || ctx.kv.get('kb.web_url') || DEFAULT_WEB))
25
+ const kbId = () => String(ctx.kv.get('kb.id') || '')
26
+
27
+ // ---- kv 默认值(幂等) ----
28
+ if (ctx.kv.get('kb.base_url') == null) ctx.kv.set('kb.base_url', DEFAULT_BASE)
29
+ if (ctx.kv.get('kb.web_url') == null) ctx.kv.set('kb.web_url', DEFAULT_WEB)
30
+ ctx.kv.set('kb.name', KB_NAME)
31
+
32
+ // base_url 守卫:仅 http/https 且 host 必须是 127.0.0.1/localhost(不合法则禁用出站)
33
+ try {
34
+ const u = new URL(base())
35
+ if ((u.protocol !== 'http:' && u.protocol !== 'https:') || !['127.0.0.1', 'localhost'].includes(u.hostname)) {
36
+ throw new Error(`base_url 必须是 http(s)://127.0.0.1|localhost,实际 ${base()}`)
37
+ }
38
+ state.outbound = true
39
+ }
40
+ catch (err) {
41
+ state.outbound = false
42
+ ctx.logger.error(`出站调用已禁用:${err?.message ?? err}(修正 kv['kb.base_url'] 后重启生效)`)
43
+ }
44
+
45
+ // ---- ensureKB:幂等初始化(失败仅告警,不阻塞装载) ----
46
+ try {
47
+ await ensureKB()
48
+ ctx.logger.info(`rag-bridge 就绪:kb=${KB_NAME}(${kbId() || '待建'}),出站=${state.outbound ? '启用' : '禁用'}`)
49
+ }
50
+ catch (err) {
51
+ ctx.logger.warn(`ensureKB 未完成(不影响装载,工具会在服务可用后按需重试):${err?.message ?? err}`)
52
+ }
53
+
54
+ // ================= 出站 HTTP(重试 + 超时 + success 断言) =================
55
+
56
+ function sleep(ms) {
57
+ return new Promise(resolve => ctx.timer.setTimeout(resolve, ms))
58
+ }
59
+
60
+ /** 单次 JSON 请求;429/网络错误按 1s*重试次数退避,最多重试 2 次;检索类调用方传 timeoutMs:30000 */
61
+ async function callJson(method, url, body, { timeoutMs = 15000, retries = 2 } = {}) {
62
+ let lastErr = ''
63
+ for (let attempt = 0; attempt <= retries; attempt++) {
64
+ if (attempt > 0) await sleep(1000 * attempt) // 退避 1s*n
65
+ try {
66
+ const res = method === 'GET'
67
+ ? await ctx.http.get(url, { timeoutMs })
68
+ : await ctx.http.post(url, body ?? {}, { timeoutMs })
69
+ if (res.status === 429) {
70
+ lastErr = `HTTP 429(限流)`
71
+ continue
72
+ }
73
+ if (!res.ok) return { ok: false, status: res.status, error: `HTTP ${res.status}` }
74
+ const json = await res.json().catch(() => null)
75
+ if (json == null) return { ok: false, status: res.status, error: '响应不是合法 JSON' }
76
+ return { ok: true, status: res.status, body: json }
77
+ }
78
+ catch (err) {
79
+ lastErr = err?.message ?? String(err) // 网络错误/超时(AbortSignal.timeout)
80
+ }
81
+ }
82
+ return { ok: false, error: lastErr || '未知错误' }
83
+ }
84
+
85
+ /** rag 业务调用:铁律——HTTP 200 但 body.success !== true 一律视为失败 */
86
+ async function ragCall(method, url, body, opts = {}) {
87
+ const r = await callJson(method, url, body, opts)
88
+ if (!r.ok) return r
89
+ if (r.body?.success !== true) {
90
+ return { ok: false, error: `服务返回 success!=true:${JSON.stringify(r.body).slice(0, 200)}` }
91
+ }
92
+ return r
93
+ }
94
+
95
+ const outboundOff = () => ({ ok: false, error: '出站调用已禁用:kv["kb.base_url"] 非法(仅允许 http/https 且 host 为 127.0.0.1/localhost)' })
96
+
97
+ // ================= ensureKB(catalog 查找 → 建库 → experience init) =================
98
+
99
+ async function ensureKB() {
100
+ // ① catalog 查找同名库(响应 {success,count,knowledgeBases:[{kbId,name,...}]})
101
+ const cat = state.outbound
102
+ ? await callJson('GET', `${web()}/api/kb/catalog`, null, { timeoutMs: 10000 })
103
+ : { ok: false, error: '出站已禁用' }
104
+ if (cat.ok) {
105
+ const list = Array.isArray(cat.body?.knowledgeBases) ? cat.body.knowledgeBases : []
106
+ const hit = list.find(kb => kb?.name === KB_NAME)
107
+ if (hit?.kbId) ctx.kv.set('kb.id', hit.kbId)
108
+ }
109
+ else {
110
+ ctx.logger.warn(`catalog 不可达(${cat.error}),跳过查找直接尝试建库`)
111
+ }
112
+ // ② 无则建库(响应 {success,knowledgeBase:{id,name,path,...}})
113
+ if (!kbId()) {
114
+ const created = state.outbound
115
+ ? await ragCall('POST', `${web()}/api/kb/create`, { name: KB_NAME, description: 'AgentWorkShop 工业知识库(诊断报告/经验教训/操作规范)' }, { timeoutMs: 15000 })
116
+ : { ok: false, error: '出站已禁用' }
117
+ if (!created.ok) throw new Error(`创建知识库 ${KB_NAME} 失败:${created.error}`)
118
+ const id = created.body?.knowledgeBase?.id
119
+ if (!id) throw new Error(`建库响应缺少 knowledgeBase.id:${JSON.stringify(created.body).slice(0, 200)}`)
120
+ ctx.kv.set('kb.id', id)
121
+ }
122
+ // ③ 经验文件夹初始化(容忍已初始化/失败:仅告警)
123
+ const init = state.outbound
124
+ ? await ragCall('POST', `${base()}/api/v1/experience/${kbId()}/init`, {}, { timeoutMs: 15000 })
125
+ : { ok: false, error: '出站已禁用' }
126
+ if (!init.ok) ctx.logger.warn(`experience init 未成功(可忽略或稍后手动重试):${init.error}`)
127
+ }
128
+
129
+ /** 工具侧兜底:kv 无 kb.id 时按需重跑 ensureKB */
130
+ async function requireKbId() {
131
+ if (kbId()) return kbId()
132
+ await ensureKB()
133
+ if (kbId()) return kbId()
134
+ return null
135
+ }
136
+
137
+ // ================= 工具 ×3(omp host 工具,lead/worker 全员可用) =================
138
+
139
+ ctx.omp.registerTool({
140
+ name: 'kb_search',
141
+ label: '全库检索',
142
+ description: '检索工业知识库(诊断报告/经验教训/操作规范),作业前先查历史经验,避免重复踩坑。',
143
+ parameters: {
144
+ type: 'object',
145
+ properties: {
146
+ query: { type: 'string', description: '检索问题(自然语言,中英文均可)' },
147
+ kb_id: { type: 'string', description: '限定知识库 ID(缺省为 aw-industrial)' },
148
+ top_k: { type: 'number', description: '返回条数上限(默认 5,经 stage2 精筛)' },
149
+ },
150
+ required: ['query'],
151
+ },
152
+ roles: ['lead', 'worker'],
153
+ handler: async (args) => {
154
+ if (!state.outbound) {
155
+ return { text: `知识库检索不可用:${outboundOff().error}。修复后重启服务。`, isError: true }
156
+ }
157
+ const query = String(args.query ?? '').trim()
158
+ if (!query) return { text: 'query 必填(要查什么问题)。', isError: true }
159
+ const kb = String(args.kb_id ?? '').trim() || kbId() || undefined
160
+ const topK = Math.min(Math.max(Math.round(Number(args.top_k) || 5), 1), 20)
161
+ const r = await ragCall('POST', `${base()}/api/v1/search/two-stage`,
162
+ { query, kb_id: kb, stage2_top_k: topK }, { timeoutMs: 30000 })
163
+ if (!r.ok) {
164
+ return { text: `检索失败:${r.error}。请确认 rag 后端(${base()})已启动(rag-knowledge 目录 start.bat / ragctl),稍后重试。`, isError: true }
165
+ }
166
+ const results = Array.isArray(r.body?.stage2?.results) ? r.body.stage2.results : []
167
+ if (results.length === 0) {
168
+ return { text: `未检索到相关经验/文档(查询:「${query}」)。可尝试更换关键词,或确认资料是否已用 kb_index 入库。` }
169
+ }
170
+ const top = results.slice(0, 5)
171
+ const lines = top.map((h, i) => {
172
+ const score = Number(h?.score ?? 0).toFixed(4)
173
+ const path = String(h?.doc_path ?? '(无路径)')
174
+ const brief = String(h?.content ?? '').replace(/\s+/g, ' ').trim().slice(0, 160)
175
+ return `${i + 1}. [score=${score}] ${path}\n ${brief}${String(h?.content ?? '').length > 160 ? '…' : ''}`
176
+ })
177
+ return { text: `检索到 ${results.length} 条(展示前 ${top.length} 条):\n${lines.join('\n')}` }
178
+ },
179
+ })
180
+
181
+ ctx.omp.registerTool({
182
+ name: 'kb_store',
183
+ label: '经验沉淀',
184
+ description: '把本次作业中值得复用的经验(最佳实践/踩坑教训/操作要点)写入知识库,供团队后续检索。',
185
+ parameters: {
186
+ type: 'object',
187
+ properties: {
188
+ title: { type: 'string', description: '经验标题(一句话概括)' },
189
+ category: { type: 'string', enum: CATEGORIES, description: '经验类别' },
190
+ problem: { type: 'string', description: '遇到的问题/场景' },
191
+ solution: { type: 'string', description: '解决方案/操作步骤' },
192
+ key_lessons: { type: 'array', items: { type: 'string' }, description: '关键教训(条目列表,可选)' },
193
+ tags: { type: 'array', items: { type: 'string' }, description: '标签(可选)' },
194
+ severity: { type: 'string', description: '严重程度(如 info/normal/critical,可选)' },
195
+ },
196
+ required: ['title', 'category'],
197
+ },
198
+ roles: ['lead', 'worker'],
199
+ handler: async (args) => {
200
+ if (!state.outbound) {
201
+ return { text: `经验沉淀不可用:${outboundOff().error}。修复后重启服务。`, isError: true }
202
+ }
203
+ const title = String(args.title ?? '').trim()
204
+ if (!title) return { text: 'title 必填(经验标题)。', isError: true }
205
+ const category = String(args.category ?? '').trim()
206
+ if (!CATEGORIES.includes(category)) {
207
+ return { text: `category 必须是以下之一:${CATEGORIES.join('/')}`, isError: true }
208
+ }
209
+ const kb = await requireKbId()
210
+ if (!kb) {
211
+ return { text: `经验沉淀失败:知识库 ${KB_NAME} 不存在且自动建库失败(检查 web ${web()} 是否启动)。`, isError: true }
212
+ }
213
+ const body = {
214
+ title,
215
+ category,
216
+ problem: String(args.problem ?? ''),
217
+ solution: String(args.solution ?? ''),
218
+ }
219
+ const lessons = (Array.isArray(args.key_lessons) ? args.key_lessons : []).map(s => String(s).trim()).filter(Boolean)
220
+ if (lessons.length) body.key_lessons = lessons
221
+ const tags = (Array.isArray(args.tags) ? args.tags : []).map(s => String(s).trim()).filter(Boolean)
222
+ if (tags.length) body.tags = tags
223
+ const severity = String(args.severity ?? '').trim()
224
+ if (severity) body.severity = severity
225
+ const r = await ragCall('POST', `${base()}/api/v1/experience/${kb}`, body, { timeoutMs: 30000 })
226
+ if (!r.ok) {
227
+ return { text: `经验沉淀失败:${r.error}。请确认 rag 后端(${base()})已启动后重试。`, isError: true }
228
+ }
229
+ const expId = String(r.body?.experience?.id ?? '(未返回 id)')
230
+ ctx.kv.bump('store.count')
231
+ return { text: `经验已沉淀:${title}(id=${expId},category=${category},kb=${KB_NAME})。` }
232
+ },
233
+ })
234
+
235
+ ctx.omp.registerTool({
236
+ name: 'kb_index',
237
+ label: '文档入库',
238
+ description: '把一份 markdown 文档写入知识库并建立向量/图谱索引,供 kb_search 日后检索。',
239
+ parameters: {
240
+ type: 'object',
241
+ properties: {
242
+ title: { type: 'string', description: '文档标题(同时作为文件名)' },
243
+ content: { type: 'string', description: '文档正文(markdown)' },
244
+ tags: { type: 'array', items: { type: 'string' }, description: '标签(可选)' },
245
+ },
246
+ required: ['title', 'content'],
247
+ },
248
+ roles: ['lead', 'worker'],
249
+ handler: async (args) => {
250
+ if (!state.outbound) {
251
+ return { text: `文档入库不可用:${outboundOff().error}。修复后重启服务。`, isError: true }
252
+ }
253
+ const title = String(args.title ?? '').trim()
254
+ const content = String(args.content ?? '')
255
+ if (!title) return { text: 'title 必填(文档标题)。', isError: true }
256
+ if (!content.trim()) return { text: 'content 必填(markdown 正文,不能为空)。', isError: true }
257
+ const kb = await requireKbId()
258
+ if (!kb) {
259
+ return { text: `文档入库失败:知识库 ${KB_NAME} 不存在且自动建库失败(检查 web ${web()} 是否启动)。`, isError: true }
260
+ }
261
+ const tags = (Array.isArray(args.tags) ? args.tags : []).map(s => String(s).trim()).filter(Boolean)
262
+ // 第 1 步:web 写盘(响应 {success,document:{path,...}})
263
+ const docName = safeFileName(title)
264
+ const w = await ragCall('POST', `${web()}/api/kb/documents/create`,
265
+ { kbId: kb, name: docName, content, description: title }, { timeoutMs: 30000 })
266
+ if (!w.ok) {
267
+ return { text: `文档入库卡在第 1 步(web 写盘 ${web()}/api/kb/documents/create):${w.error}。未产生索引,可直接重试。`, isError: true }
268
+ }
269
+ const docPath = String(w.body?.document?.path ?? '')
270
+ if (!docPath) {
271
+ return { text: '文档入库卡在第 1 步:写盘成功但响应缺少 document.path,无法继续索引。', isError: true }
272
+ }
273
+ // 第 2 步:backend 索引(content 直传,doc_path 用写盘返回路径)
274
+ const r = await ragCall('POST', `${base()}/api/v1/search/index-document`,
275
+ { kb_id: kb, doc_path: docPath, doc_name: docName, description: title, content, tags }, { timeoutMs: 60000 })
276
+ if (!r.ok) {
277
+ return { text: `文档入库卡在第 2 步(backend 索引 ${base()}/api/v1/search/index-document):${r.error}。文档已写盘(${docPath}),服务恢复后可重试入库(同名会生成新文件)。`, isError: true }
278
+ }
279
+ const chunks = Number(r.body?.vector_index?.total_chunks ?? 0)
280
+ ctx.kv.bump('index.count')
281
+ return { text: `文档已入库:${docPath}(向量分块 ${chunks},kb=${KB_NAME}),可立即用 kb_search 检索。` }
282
+ },
283
+ })
284
+
285
+ // ================= 插件 API ×3(/api/plugins/rag-bridge/**) =================
286
+
287
+ /** 从 h3 event 取查询参数(转发层只预挂 awBody;query 在 event.path 上) */
288
+ function queryOf(event) {
289
+ const raw = String(event?.path ?? event?.node?.req?.url ?? '')
290
+ const q = {}
291
+ try {
292
+ const u = new URL(raw, 'http://local')
293
+ for (const [k, v] of u.searchParams.entries()) q[k] = v
294
+ }
295
+ catch { /* 忽略,返回空 */ }
296
+ return q
297
+ }
298
+
299
+ // 健康:后端 + web 存活、kb.id、出站开关
300
+ ctx.route('GET', '/health', async () => {
301
+ const backend = state.outbound
302
+ ? await callJson('GET', `${base()}/api/v1/health`, null, { timeoutMs: 5000, retries: 0 })
303
+ : { ok: false, error: '出站已禁用' }
304
+ const webR = state.outbound
305
+ ? await callJson('GET', `${web()}/api/kb/catalog`, null, { timeoutMs: 5000, retries: 0 })
306
+ : { ok: false, error: '出站已禁用' }
307
+ return {
308
+ plugin: 'rag-bridge',
309
+ outbound: state.outbound,
310
+ kb: { name: KB_NAME, id: kbId() || null },
311
+ backend: { url: base(), ok: backend.ok, ...(backend.ok ? { status: backend.body?.status ?? null } : { error: backend.error }) },
312
+ web: { url: web(), ok: webR.ok, ...(webR.ok ? { knowledgeBases: webR.body?.count ?? null } : { error: webR.error }) },
313
+ counters: { store: ctx.kv.get('store.count') ?? 0, index: ctx.kv.get('index.count') ?? 0 },
314
+ }
315
+ })
316
+
317
+ // 检索:复用 two-stage(?q=&kb_id=&top_k=)
318
+ ctx.route('GET', '/search', async (event) => {
319
+ const q = queryOf(event)
320
+ const query = String(q.q ?? '').trim()
321
+ if (!query) return { success: false, error: '缺少参数 q(检索词)' }
322
+ if (!state.outbound) return { success: false, error: outboundOff().error }
323
+ const kb = String(q.kb_id ?? '').trim() || kbId() || undefined
324
+ const topK = Math.min(Math.max(Math.round(Number(q.top_k) || 5), 1), 20)
325
+ const r = await ragCall('POST', `${base()}/api/v1/search/two-stage`,
326
+ { query, kb_id: kb, stage2_top_k: topK }, { timeoutMs: 30000 })
327
+ if (!r.ok) return { success: false, error: r.error }
328
+ return { success: true, query, total_results: r.body?.total_results ?? null, results: r.body?.stage2?.results ?? [] }
329
+ })
330
+
331
+ // 经验列表:GET {base}/api/v1/experience/{kb_id} → {success,count,experiences:[...]}(?limit= 截取)
332
+ ctx.route('GET', '/experience', async (event) => {
333
+ const q = queryOf(event)
334
+ if (!state.outbound) return { success: false, error: outboundOff().error }
335
+ const kb = await requireKbId()
336
+ if (!kb) return { success: false, error: `知识库 ${KB_NAME} 不存在且自动建库失败(检查 web ${web()})` }
337
+ const limit = Math.min(Math.max(Math.round(Number(q.limit) || 20), 1), 100)
338
+ const r = await ragCall('GET', `${base()}/api/v1/experience/${kb}`, null, { timeoutMs: 15000 })
339
+ if (!r.ok) return { success: false, error: `经验列表不可用:${r.error}` }
340
+ const all = Array.isArray(r.body?.experiences) ? r.body.experiences : []
341
+ return {
342
+ success: true,
343
+ kb: { name: KB_NAME, id: kb },
344
+ count: all.length,
345
+ experiences: all.slice(0, limit),
346
+ }
347
+ })
348
+ },
349
+ }
350
+
351
+ // ================= 纯函数小工具 =================
352
+
353
+ function trimSlash(s) {
354
+ return s.replace(/\/+$/, '')
355
+ }
356
+
357
+ /** 标题 → 安全文件名(剔除路径非法字符;确保 .md 后缀) */
358
+ function safeFileName(title) {
359
+ // eslint-disable-next-line no-control-regex -- 文件名净化:必须剔除控制字符
360
+ let name = String(title).replace(/[\\/:*?"<>|\u0000-\u001f]/g, '-').replace(/\s+/g, ' ').trim().replace(/^[.\s]+|[.\s]+$/g, '')
361
+ if (!name) name = 'untitled'
362
+ if (name.length > 80) name = name.slice(0, 80).trim()
363
+ return name.toLowerCase().endsWith('.md') ? name : `${name}.md`
364
+ }