agentworkshop 0.7.6 → 0.7.8

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 (538) hide show
  1. package/.AgentWorkShop/prompts/host-tools.json +1 -1
  2. package/.output/.AgentWorkShop/prompts/host-tools.json +1 -1
  3. package/.output/nitro.json +1 -1
  4. package/.output/public/_nuxt/{rzGB_ojX.js → 3612gD2V.js} +2 -2
  5. package/.output/public/_nuxt/8eIQAVlb.js +1 -0
  6. package/.output/public/_nuxt/Ah9qOv1m.js +1 -0
  7. package/.output/public/_nuxt/{DdPeifHR.js → B4Fia4FB.js} +1 -1
  8. package/.output/public/_nuxt/B7aqqzkY.js +1 -0
  9. package/.output/public/_nuxt/BJ-fxrSw.js +1 -0
  10. package/.output/public/_nuxt/{DPDqAD1e.js → BSXx2vqR.js} +1 -1
  11. package/.output/public/_nuxt/{CdSgfcYR.js → BVZjSVs2.js} +1 -1
  12. package/.output/public/_nuxt/{DP6bdyIp.js → BVzDoF8t.js} +1 -1
  13. package/.output/public/_nuxt/BYL0Rjqj.js +7 -0
  14. package/.output/public/_nuxt/{CXmkVXS5.js → BjVLsC3M.js} +1 -1
  15. package/.output/public/_nuxt/{7ZABjMRh2.js → BkfchkK62.js} +1 -1
  16. package/.output/public/_nuxt/BnVoQ74r.js +1 -0
  17. package/.output/public/_nuxt/Bnp4vIAf.js +1 -0
  18. package/.output/public/_nuxt/BsMpJf7S.js +70 -0
  19. package/.output/public/_nuxt/{Z8k0uMSI.js → Bt_HDizI.js} +1 -1
  20. package/.output/public/_nuxt/Bu-P92Pe.js +18 -0
  21. package/.output/public/_nuxt/ButLXkjo.js +2 -0
  22. package/.output/public/_nuxt/{D8DDDzV62.js → C2iWjzEC2.js} +1 -1
  23. package/.output/public/_nuxt/{HWXLx5Hz.js → C8dxXc6K.js} +5 -5
  24. package/.output/public/_nuxt/CGdPdJPP.js +1 -0
  25. package/.output/public/_nuxt/{CN7Zh8GQ.js → CRGlf1Gb.js} +1 -1
  26. package/.output/public/_nuxt/{DSBfvCi5.js → CblLEiCZ.js} +7 -7
  27. package/.output/public/_nuxt/Cd15nPnG2.js +1 -0
  28. package/.output/public/_nuxt/{OwJ1LJkF.js → CsCpu2Zh.js} +1 -1
  29. package/.output/public/_nuxt/CvbHIGQY2.js +1 -0
  30. package/.output/public/_nuxt/Cyk3du4K2.js +1 -0
  31. package/.output/public/_nuxt/{DVQAz9WI.js → D4qXvjuV.js} +2 -2
  32. package/.output/public/_nuxt/{CfIXY-ET.js → DCEyMaN-.js} +1 -1
  33. package/.output/public/_nuxt/{BFYNhG9S.js → DCXIGxzT.js} +1 -1
  34. package/.output/public/_nuxt/{B9aPoQvt.js → DM8DS9MA.js} +1 -1
  35. package/.output/public/_nuxt/{ChnfyQHz.js → DNzaswei.js} +1 -1
  36. package/.output/public/_nuxt/{CrFGZYVB2.js → DYZBdSSg2.js} +1 -1
  37. package/.output/public/_nuxt/{dObsRdSQ.js → DZk24ego.js} +1 -1
  38. package/.output/public/_nuxt/{CyygA0q4.js → Dc46i75T.js} +4 -4
  39. package/.output/public/_nuxt/DeYsUzhr.js +1 -0
  40. package/.output/public/_nuxt/Dk6pq9JB2.js +1 -0
  41. package/.output/public/_nuxt/{ByGNWgAr.js → Do88WZG2.js} +3 -3
  42. package/.output/public/_nuxt/{R_WxTozV2.js → Du-eSpo2.js} +1 -1
  43. package/.output/public/_nuxt/OmpTerminalPanel.B_Pl5Ynm.css +1 -0
  44. package/.output/public/_nuxt/R_Wv_Nd9.js +1 -0
  45. package/.output/public/_nuxt/{Bsc69G4x.js → VnIWJ0ts.js} +3 -3
  46. package/.output/public/_nuxt/_id_.BzKMZnLe.css +1 -0
  47. package/.output/public/_nuxt/_id_.CbpDAWRh.css +1 -0
  48. package/.output/public/_nuxt/{_wsId_.DET_GinP.css → _wsId_.COUzMXpP.css} +1 -1
  49. package/.output/public/_nuxt/agents.BlejnOOC.css +1 -0
  50. package/.output/public/_nuxt/builds/latest.json +1 -1
  51. package/.output/public/_nuxt/builds/meta/e5bb1803-86d9-43b3-85be-dc787dc9a978.json +1 -0
  52. package/.output/public/_nuxt/daq.zZ8GR433.css +1 -0
  53. package/.output/public/_nuxt/{default.D17kXlD6.css → default.V3_hUJq1.css} +1 -1
  54. package/.output/public/_nuxt/{entry.DvlXlPwx.css → entry.5qf6EqfN.css} +1 -1
  55. package/.output/public/_nuxt/{B4GHHF6d2.js → fQUs58kX2.js} +1 -1
  56. package/.output/public/_nuxt/p7wSGMtc.js +1 -0
  57. package/.output/public/_nuxt/tRBT-plo.js +1 -0
  58. package/.output/public/_nuxt/workshop.3kAcLB_M.css +1 -0
  59. package/.output/server/chunks/_/SearchOutlined.mjs +4 -4
  60. package/.output/server/chunks/_/SearchOutlined.mjs.map +1 -1
  61. package/.output/server/chunks/_/character-asset.repo.mjs +3 -6
  62. package/.output/server/chunks/_/character-asset.repo.mjs.map +1 -1
  63. package/.output/server/chunks/_/host-bindings.mjs +1 -1
  64. package/.output/server/chunks/_/nitro.mjs +12807 -9814
  65. package/.output/server/chunks/_/nitro.mjs.map +1 -1
  66. package/.output/server/chunks/_/scene-layout.repo.mjs +4 -10
  67. package/.output/server/chunks/_/scene-layout.repo.mjs.map +1 -1
  68. package/.output/server/chunks/build/{Col-D7fjGDF6.mjs → Col-biaNnEPf.mjs} +2 -2
  69. package/.output/server/chunks/build/{Col-D7fjGDF6.mjs.map → Col-biaNnEPf.mjs.map} +1 -1
  70. package/.output/server/chunks/build/{OmpTerminalPanel-B_SYhmgb.mjs → OmpTerminalPanel-COphA1br.mjs} +20 -19
  71. package/.output/server/chunks/build/OmpTerminalPanel-COphA1br.mjs.map +1 -0
  72. package/.output/server/chunks/build/{TownView-Bl8Gkcxi.mjs → TownView-B5KifIaT.mjs} +5 -5
  73. package/.output/server/chunks/build/{TownView-Bl8Gkcxi.mjs.map → TownView-B5KifIaT.mjs.map} +1 -1
  74. package/.output/server/chunks/build/{_id_-GnRJPykX.mjs → _id_-C-ewLgfl.mjs} +120 -120
  75. package/.output/server/chunks/build/{_id_-GnRJPykX.mjs.map → _id_-C-ewLgfl.mjs.map} +1 -1
  76. package/.output/server/chunks/build/{_id_-CWLFGZjV.mjs → _id_-Ct4Jhvl1.mjs} +43 -39
  77. package/.output/server/chunks/build/_id_-Ct4Jhvl1.mjs.map +1 -0
  78. package/.output/server/chunks/build/{_wsId_-BhQMjyHG.mjs → _wsId_-CanI_6Su.mjs} +591 -53
  79. package/.output/server/chunks/build/{_wsId_-BhQMjyHG.mjs.map → _wsId_-CanI_6Su.mjs.map} +1 -1
  80. package/.output/server/chunks/build/{agents-D4l1icvn.mjs → agents-DSOptxXA.mjs} +146 -91
  81. package/.output/server/chunks/build/agents-DSOptxXA.mjs.map +1 -0
  82. package/.output/server/chunks/build/{alert-gH-s7yIh.mjs → alert-qJnjyRcP.mjs} +3 -3
  83. package/.output/server/chunks/build/{alert-gH-s7yIh.mjs.map → alert-qJnjyRcP.mjs.map} +1 -1
  84. package/.output/server/chunks/build/{button-BhbX5ACI.mjs → button-DEcZFcqN.mjs} +3 -3
  85. package/.output/server/chunks/build/{button-BhbX5ACI.mjs.map → button-DEcZFcqN.mjs.map} +1 -1
  86. package/.output/server/chunks/build/{card-l4BbX67w.mjs → card-Dipvaykh.mjs} +5 -5
  87. package/.output/server/chunks/build/{card-l4BbX67w.mjs.map → card-Dipvaykh.mjs.map} +1 -1
  88. package/.output/server/chunks/build/{channel-templates-DqjtC-R0.mjs → channel-templates-BK0KuPOd.mjs} +13 -12
  89. package/.output/server/chunks/build/channel-templates-BK0KuPOd.mjs.map +1 -0
  90. package/.output/server/chunks/build/{checkbox-BF11p3dH.mjs → checkbox-dzcpU_Cd.mjs} +4 -4
  91. package/.output/server/chunks/build/{checkbox-BF11p3dH.mjs.map → checkbox-dzcpU_Cd.mjs.map} +1 -1
  92. package/.output/server/chunks/build/{daq-BOgpn9sl.mjs → daq-D9RA_uze.mjs} +103 -103
  93. package/.output/server/chunks/build/{daq-BOgpn9sl.mjs.map → daq-D9RA_uze.mjs.map} +1 -1
  94. package/.output/server/chunks/build/dcw-BTM5YU-B.mjs +2 -2
  95. package/.output/server/chunks/build/{default-CKJWhkot.mjs → default-BfWGTlbj.mjs} +81 -23
  96. package/.output/server/chunks/build/{default-CKJWhkot.mjs.map → default-BfWGTlbj.mjs.map} +1 -1
  97. package/.output/server/chunks/build/{drawer-CVValqoh.mjs → drawer-Cmh90erI.mjs} +3 -3
  98. package/.output/server/chunks/build/{drawer-CVValqoh.mjs.map → drawer-Cmh90erI.mjs.map} +1 -1
  99. package/.output/server/chunks/build/{dropdown-ByCsEWlQ.mjs → dropdown-CGQ0KAzA.mjs} +2 -2
  100. package/.output/server/chunks/build/{dropdown-ByCsEWlQ.mjs.map → dropdown-CGQ0KAzA.mjs.map} +1 -1
  101. package/.output/server/chunks/build/{dropdown-Dex8PXu6.mjs → dropdown-vhn1NPFs.mjs} +4 -4
  102. package/.output/server/chunks/build/{dropdown-Dex8PXu6.mjs.map → dropdown-vhn1NPFs.mjs.map} +1 -1
  103. package/.output/server/chunks/build/{input-number-BBlRoAJ7.mjs → input-number-Bd55elNN.mjs} +5 -5
  104. package/.output/server/chunks/build/{input-number-BBlRoAJ7.mjs.map → input-number-Bd55elNN.mjs.map} +1 -1
  105. package/.output/server/chunks/build/{input--KMeLYqZ.mjs → input-sf_BT6o6.mjs} +3 -3
  106. package/.output/server/chunks/build/{input--KMeLYqZ.mjs.map → input-sf_BT6o6.mjs.map} +1 -1
  107. package/.output/server/chunks/build/logs-Dyk0I2I9.mjs +1 -1
  108. package/.output/server/chunks/build/{menu-xN-SXb9Q.mjs → menu-WCrlpYVh.mjs} +3 -3
  109. package/.output/server/chunks/build/{menu-xN-SXb9Q.mjs.map → menu-WCrlpYVh.mjs.map} +1 -1
  110. package/.output/server/chunks/build/{modal-DrCOcjrl.mjs → modal-yvUquPj5.mjs} +4 -4
  111. package/.output/server/chunks/build/{modal-DrCOcjrl.mjs.map → modal-yvUquPj5.mjs.map} +1 -1
  112. package/.output/server/chunks/build/{monitor-KW8WLOJd.mjs → monitor-MIOvsyLa.mjs} +21 -21
  113. package/.output/server/chunks/build/{monitor-KW8WLOJd.mjs.map → monitor-MIOvsyLa.mjs.map} +1 -1
  114. package/.output/server/chunks/build/pages-DR2bzczM.mjs +1 -1
  115. package/.output/server/chunks/build/{plugins-B-ZNey0Z.mjs → plugins-DnOBIWGg.mjs} +7 -7
  116. package/.output/server/chunks/build/{plugins-B-ZNey0Z.mjs.map → plugins-DnOBIWGg.mjs.map} +1 -1
  117. package/.output/server/chunks/build/{popconfirm-C5H1Qoh3.mjs → popconfirm-CRaHcz5O.mjs} +4 -4
  118. package/.output/server/chunks/build/{popconfirm-C5H1Qoh3.mjs.map → popconfirm-CRaHcz5O.mjs.map} +1 -1
  119. package/.output/server/chunks/build/{useWorkshopApi-Bh5VUHWu.mjs → segmented-DPe9ZzLO.mjs} +7 -78
  120. package/.output/server/chunks/build/segmented-DPe9ZzLO.mjs.map +1 -0
  121. package/.output/server/chunks/build/{select-D7H2ysgT.mjs → select-D-CeE5vY.mjs} +3 -3
  122. package/.output/server/chunks/build/{select-D7H2ysgT.mjs.map → select-D-CeE5vY.mjs.map} +1 -1
  123. package/.output/server/chunks/build/{settings-Cr06lbRy.mjs → settings-DA8IkGLo.mjs} +11 -11
  124. package/.output/server/chunks/build/{settings-Cr06lbRy.mjs.map → settings-DA8IkGLo.mjs.map} +1 -1
  125. package/.output/server/chunks/build/{space-DCwIlnkI.mjs → space-CCBYAkXt.mjs} +2 -2
  126. package/.output/server/chunks/build/{space-DCwIlnkI.mjs.map → space-CCBYAkXt.mjs.map} +1 -1
  127. package/.output/server/chunks/build/{switch-VC0m9ede.mjs → switch-CelRXpcy.mjs} +3 -3
  128. package/.output/server/chunks/build/{switch-VC0m9ede.mjs.map → switch-CelRXpcy.mjs.map} +1 -1
  129. package/.output/server/chunks/build/{table-BksLg3Q_.mjs → table-Cswq-l2r.mjs} +10 -10
  130. package/.output/server/chunks/build/{table-BksLg3Q_.mjs.map → table-Cswq-l2r.mjs.map} +1 -1
  131. package/.output/server/chunks/build/{tabs-CzUfD3iX.mjs → tabs-BM3tAh_J.mjs} +5 -5
  132. package/.output/server/chunks/build/{tabs-CzUfD3iX.mjs.map → tabs-BM3tAh_J.mjs.map} +1 -1
  133. package/.output/server/chunks/build/{tag-oQI3VtqM.mjs → tag-NO9jEqKy.mjs} +4 -4
  134. package/.output/server/chunks/build/{tag-oQI3VtqM.mjs.map → tag-NO9jEqKy.mjs.map} +1 -1
  135. package/.output/server/chunks/build/{teams-QR3BBF7A.mjs → teams-BhSKBBBM.mjs} +15 -14
  136. package/.output/server/chunks/build/teams-BhSKBBBM.mjs.map +1 -0
  137. package/.output/server/chunks/build/{tokens-DFvr_TLj.mjs → tokens-D_eyxmcv.mjs} +16 -16
  138. package/.output/server/chunks/build/{tokens-DFvr_TLj.mjs.map → tokens-D_eyxmcv.mjs.map} +1 -1
  139. package/.output/server/chunks/build/town-BUqRobze.mjs +1 -1
  140. package/.output/server/chunks/build/{town-_4tEEEVW.mjs → town-DPtOPRRO.mjs} +4 -4
  141. package/.output/server/chunks/build/{town-_4tEEEVW.mjs.map → town-DPtOPRRO.mjs.map} +1 -1
  142. package/.output/server/chunks/build/useDaqStream-hwkhJHFU.mjs +1 -1
  143. package/.output/server/chunks/build/useDcwStream-Bdew_yrr.mjs +1 -1
  144. package/.output/server/chunks/build/useLocalTime-9a4B-aHv.mjs +42 -0
  145. package/.output/server/chunks/build/useLocalTime-9a4B-aHv.mjs.map +1 -0
  146. package/.output/server/chunks/build/useWorkshopApi-D2gq06N2.mjs +81 -0
  147. package/.output/server/chunks/build/useWorkshopApi-D2gq06N2.mjs.map +1 -0
  148. package/.output/server/chunks/build/useWorkshopWs-B3j5wIAK.mjs +1 -1
  149. package/.output/server/chunks/build/user-Dk-ytEUV.mjs +1 -1
  150. package/.output/server/chunks/build/{users-4FZ0yFUO.mjs → users-CmVvb1oq.mjs} +16 -16
  151. package/.output/server/chunks/build/{users-4FZ0yFUO.mjs.map → users-CmVvb1oq.mjs.map} +1 -1
  152. package/.output/server/chunks/build/{workshop-k0XZTFKg.mjs → workshop-D5CQj2A8.mjs} +53 -47
  153. package/.output/server/chunks/build/workshop-D5CQj2A8.mjs.map +1 -0
  154. package/.output/server/chunks/build/workspaces-IfORCDJE.mjs +1 -1
  155. package/.output/server/chunks/routes/api/health.get.mjs +1 -1
  156. package/.output/server/chunks/routes/api/index.get.mjs +1 -1
  157. package/.output/server/chunks/routes/api/index.post.mjs +1 -1
  158. package/.output/server/chunks/routes/api/mcp/workshop.mjs +1 -1
  159. package/.output/server/chunks/routes/api/metrics.mjs +1 -1
  160. package/.output/server/chunks/routes/api/plugins/_name/_...path_.mjs +1 -1
  161. package/.output/server/chunks/routes/api/plugins/client/_name_.get.mjs +1 -1
  162. package/.output/server/chunks/routes/api/plugins/manifest.get.mjs +1 -1
  163. package/.output/server/chunks/routes/api/system/config.get.mjs +1 -1
  164. package/.output/server/chunks/routes/api/system/index.get.mjs +3 -3
  165. package/.output/server/chunks/routes/api/system/index.get.mjs.map +1 -1
  166. package/.output/server/chunks/routes/api/system/index.patch.mjs +1 -1
  167. package/.output/server/chunks/routes/api/system/monitor/terminal/ws.mjs +1 -1
  168. package/.output/server/chunks/routes/api/system/monitor/terminate.post.mjs +1 -1
  169. package/.output/server/chunks/routes/api/system/monitor.get.mjs +1 -1
  170. package/.output/server/chunks/routes/api/system/settings/events.get.mjs +1 -1
  171. package/.output/server/chunks/routes/api/system/settings/reset.post.mjs +1 -1
  172. package/.output/server/chunks/routes/api/users/_id_.delete.mjs +1 -1
  173. package/.output/server/chunks/routes/api/users/_id_.get.mjs +1 -1
  174. package/.output/server/chunks/routes/api/users/_id_.put.mjs +1 -1
  175. package/.output/server/chunks/routes/api/users/index.get.mjs +1 -1
  176. package/.output/server/chunks/routes/api/users/index.post.mjs +1 -1
  177. package/.output/server/chunks/routes/api/users/login.post.mjs +1 -1
  178. package/.output/server/chunks/routes/api/users/logout.post.mjs +1 -1
  179. package/.output/server/chunks/routes/api/users/me.get.mjs +1 -1
  180. package/.output/server/chunks/routes/api/users/register.post.mjs +1 -1
  181. package/.output/server/chunks/routes/api/users/setup-status.get.mjs +25 -0
  182. package/.output/server/chunks/routes/api/users/setup-status.get.mjs.map +1 -0
  183. package/.output/server/chunks/routes/api/users/tokens/_id/token.get.mjs +1 -1
  184. package/.output/server/chunks/routes/api/users/tokens/_id_.delete.mjs +1 -1
  185. package/.output/server/chunks/routes/api/users/tokens/_id_.patch.mjs +1 -1
  186. package/.output/server/chunks/routes/api/workshop/_...path_.mjs +1 -1
  187. package/.output/server/chunks/routes/api/workshop/a2a/_agentId/index.get.mjs +1 -1
  188. package/.output/server/chunks/routes/api/workshop/a2a/_agentId/index.post.mjs +1 -1
  189. package/.output/server/chunks/routes/api/workshop/a2a/send.post.mjs +1 -1
  190. package/.output/server/chunks/routes/api/workshop/agent-tools/approvals/_id/decide.post.mjs +1 -1
  191. package/.output/server/chunks/routes/api/workshop/agent-tools/bindings/_id_.delete.mjs +1 -1
  192. package/.output/server/chunks/routes/api/workshop/agent-tools/bindings/_id_.patch.mjs +1 -1
  193. package/.output/server/chunks/routes/api/workshop/agent-tools/index.get.mjs +1 -1
  194. package/.output/server/chunks/routes/api/workshop/agent-tools/index.post.mjs +1 -1
  195. package/.output/server/chunks/routes/api/workshop/agent-tools/index2.get.mjs +1 -1
  196. package/.output/server/chunks/routes/api/workshop/agent-tools/invoke.post.mjs +6 -14
  197. package/.output/server/chunks/routes/api/workshop/agent-tools/invoke.post.mjs.map +1 -1
  198. package/.output/server/chunks/routes/api/workshop/agent-tools/list.get.mjs +39 -0
  199. package/.output/server/chunks/routes/api/workshop/agent-tools/list.get.mjs.map +1 -0
  200. package/.output/server/chunks/routes/api/workshop/agents/_id_.delete.mjs +1 -1
  201. package/.output/server/chunks/routes/api/workshop/agents/_id_.get.mjs +1 -1
  202. package/.output/server/chunks/routes/api/workshop/agents/_id_.patch.mjs +1 -1
  203. package/.output/server/chunks/routes/api/workshop/agents/subscribe.post.mjs +1 -1
  204. package/.output/server/chunks/routes/api/workshop/approvals/_id/decide.post.mjs +1 -1
  205. package/.output/server/chunks/routes/api/workshop/assets/character/_id_.delete.mjs +1 -1
  206. package/.output/server/chunks/routes/api/workshop/assets/devices/_id_.delete.mjs +1 -1
  207. package/.output/server/chunks/routes/api/workshop/assets/index.get.mjs +1 -1
  208. package/.output/server/chunks/routes/api/workshop/assets/index.post.mjs +2 -2
  209. package/.output/server/chunks/routes/api/workshop/assets/index2.get.mjs +1 -1
  210. package/.output/server/chunks/routes/api/workshop/assets/index2.post.mjs +2 -2
  211. package/.output/server/chunks/routes/api/workshop/audit.get.mjs +1 -1
  212. package/.output/server/chunks/routes/api/workshop/caller.mjs +2 -2
  213. package/.output/server/chunks/routes/api/workshop/channel-templates/_id/instantiate.post.mjs +3 -3
  214. package/.output/server/chunks/routes/api/workshop/channel-templates/_id_.delete.mjs +1 -1
  215. package/.output/server/chunks/routes/api/workshop/channel-templates/_id_.get.mjs +1 -1
  216. package/.output/server/chunks/routes/api/workshop/channel-templates/_id_.patch.mjs +1 -1
  217. package/.output/server/chunks/routes/api/workshop/channel-templates/from-channel.post.mjs +1 -1
  218. package/.output/server/chunks/routes/api/workshop/channels/_id/activate.post.mjs +2 -2
  219. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId/index.get.mjs +1 -1
  220. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId/index.post.mjs +1 -1
  221. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId/memories/_memoryId_.delete.mjs +1 -1
  222. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId/memories/search.post.mjs +1 -1
  223. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId/model.patch.mjs +1 -1
  224. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId/position.patch.mjs +1 -1
  225. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId/range.patch.mjs +1 -1
  226. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId/stop.post.mjs +1 -1
  227. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId_.delete.mjs +1 -1
  228. package/.output/server/chunks/routes/api/workshop/channels/_id/agents/_agentId_.patch.mjs +1 -1
  229. package/.output/server/chunks/routes/api/workshop/channels/_id/events.get.mjs +1 -1
  230. package/.output/server/chunks/routes/api/workshop/channels/_id/index.get.mjs +1 -1
  231. package/.output/server/chunks/routes/api/workshop/channels/_id/index.post.mjs +2 -2
  232. package/.output/server/chunks/routes/api/workshop/channels/_id/index2.get.mjs +1 -1
  233. package/.output/server/chunks/routes/api/workshop/channels/_id/index2.post.mjs +1 -1
  234. package/.output/server/chunks/routes/api/workshop/channels/_id/index3.get.mjs +1 -1
  235. package/.output/server/chunks/routes/api/workshop/channels/_id/index3.post.mjs +1 -1
  236. package/.output/server/chunks/routes/api/workshop/channels/_id/index4.get.mjs +1 -1
  237. package/.output/server/chunks/routes/api/workshop/channels/_id/index4.post.mjs +1 -1
  238. package/.output/server/chunks/routes/api/workshop/channels/_id/memories/_memoryId_.delete.mjs +1 -1
  239. package/.output/server/chunks/routes/api/workshop/channels/_id/queue.get.mjs +1 -1
  240. package/.output/server/chunks/routes/api/workshop/channels/_id/terminals.get.mjs +2 -2
  241. package/.output/server/chunks/routes/api/workshop/channels/_id_.delete.mjs +1 -1
  242. package/.output/server/chunks/routes/api/workshop/channels/index.get.mjs +2 -2
  243. package/.output/server/chunks/routes/api/workshop/channels/index.patch.mjs +9 -2
  244. package/.output/server/chunks/routes/api/workshop/channels/index.patch.mjs.map +1 -1
  245. package/.output/server/chunks/routes/api/workshop/channels.get.mjs +1 -1
  246. package/.output/server/chunks/routes/api/workshop/channels.post.mjs +3 -3
  247. package/.output/server/chunks/routes/api/workshop/daq/_id/bind.post.mjs +2 -2
  248. package/.output/server/chunks/routes/api/workshop/daq/_id/frames/content.get.mjs +2 -2
  249. package/.output/server/chunks/routes/api/workshop/daq/_id/frames.get.mjs +2 -2
  250. package/.output/server/chunks/routes/api/workshop/daq/_id/samples.get.mjs +7 -4
  251. package/.output/server/chunks/routes/api/workshop/daq/_id/samples.get.mjs.map +1 -1
  252. package/.output/server/chunks/routes/api/workshop/daq/_id/test.post.mjs +2 -2
  253. package/.output/server/chunks/routes/api/workshop/daq/_id_.delete.mjs +2 -2
  254. package/.output/server/chunks/routes/api/workshop/daq/_id_.patch.mjs +2 -2
  255. package/.output/server/chunks/routes/api/workshop/daq/alarms/_id/ack.post.mjs +2 -2
  256. package/.output/server/chunks/routes/api/workshop/daq/alarms.get.mjs +2 -2
  257. package/.output/server/chunks/routes/api/workshop/daq/controller.post.mjs +2 -2
  258. package/.output/server/chunks/routes/api/workshop/daq/index.post.mjs +2 -2
  259. package/.output/server/chunks/routes/api/workshop/daq/infra/reconnect.post.mjs +2 -2
  260. package/.output/server/chunks/routes/api/workshop/daq/infra.get.mjs +2 -2
  261. package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.delete.mjs +2 -2
  262. package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.patch.mjs +2 -2
  263. package/.output/server/chunks/routes/api/workshop/daq/test-driver.post.mjs +2 -2
  264. package/.output/server/chunks/routes/api/workshop/dcw/_id/bind.post.mjs +2 -2
  265. package/.output/server/chunks/routes/api/workshop/dcw/_id/param-ledger.get.mjs +2 -2
  266. package/.output/server/chunks/routes/api/workshop/dcw/_id/read.post.mjs +2 -2
  267. package/.output/server/chunks/routes/api/workshop/dcw/_id/test.post.mjs +2 -2
  268. package/.output/server/chunks/routes/api/workshop/dcw/_id/write.post.mjs +2 -2
  269. package/.output/server/chunks/routes/api/workshop/dcw/_id_.delete.mjs +2 -2
  270. package/.output/server/chunks/routes/api/workshop/dcw/_id_.patch.mjs +2 -2
  271. package/.output/server/chunks/routes/api/workshop/dcw/controller.post.mjs +2 -2
  272. package/.output/server/chunks/routes/api/workshop/dcw/index.get.mjs +2 -2
  273. package/.output/server/chunks/routes/api/workshop/dcw/index.post.mjs +2 -2
  274. package/.output/server/chunks/routes/api/workshop/dcw/index2.get.mjs +2 -2
  275. package/.output/server/chunks/routes/api/workshop/dcw/index2.post.mjs +2 -2
  276. package/.output/server/chunks/routes/api/workshop/dcw/index3.get.mjs +2 -2
  277. package/.output/server/chunks/routes/api/workshop/dcw/index3.post.mjs +2 -2
  278. package/.output/server/chunks/routes/api/workshop/dcw/index4.get.mjs +2 -2
  279. package/.output/server/chunks/routes/api/workshop/dcw/index4.post.mjs +2 -2
  280. package/.output/server/chunks/routes/api/workshop/dcw/index5.get.mjs +2 -2
  281. package/.output/server/chunks/routes/api/workshop/dcw/journal/node/_nodeId/rollback.post.mjs +2 -2
  282. package/.output/server/chunks/routes/api/workshop/dcw/line/query.get.mjs +2 -2
  283. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/start.post.mjs +2 -2
  284. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/stop.post.mjs +2 -2
  285. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id_.delete.mjs +2 -2
  286. package/.output/server/chunks/routes/api/workshop/dcw/lines/_id_.patch.mjs +2 -2
  287. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/judge.post.mjs +2 -2
  288. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/rollback.post.mjs +2 -2
  289. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id/series.get.mjs +2 -2
  290. package/.output/server/chunks/routes/api/workshop/dcw/optimizations/_id_.get.mjs +2 -2
  291. package/.output/server/chunks/routes/api/workshop/dcw/products/_id_.delete.mjs +2 -2
  292. package/.output/server/chunks/routes/api/workshop/dcw/products/_id_.patch.mjs +2 -2
  293. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/apply.post.mjs +2 -2
  294. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/mark-good.post.mjs +2 -2
  295. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id/rollback-good.post.mjs +2 -2
  296. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id_.delete.mjs +2 -2
  297. package/.output/server/chunks/routes/api/workshop/dcw/recipes/_id_.patch.mjs +2 -2
  298. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/close.post.mjs +2 -2
  299. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/data.get.mjs +2 -2
  300. package/.output/server/chunks/routes/api/workshop/dcw/runs/_id/rollback.post.mjs +2 -2
  301. package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.delete.mjs +2 -2
  302. package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.patch.mjs +2 -2
  303. package/.output/server/chunks/routes/api/workshop/dcw/test-driver.post.mjs +2 -2
  304. package/.output/server/chunks/routes/api/workshop/device-twins/_id/control.post.mjs +1 -1
  305. package/.output/server/chunks/routes/api/workshop/device-twins/_id/telemetry.post.mjs +1 -1
  306. package/.output/server/chunks/routes/api/workshop/device-twins/_id_.delete.mjs +2 -2
  307. package/.output/server/chunks/routes/api/workshop/device-twins/_id_.patch.mjs +2 -2
  308. package/.output/server/chunks/routes/api/workshop/fs/dirs.get.mjs +1 -1
  309. package/.output/server/chunks/routes/api/workshop/harnesses/_id/providers.get.mjs +247 -0
  310. package/.output/server/chunks/routes/api/workshop/harnesses/_id/providers.get.mjs.map +1 -0
  311. package/.output/server/chunks/routes/api/workshop/harnesses.get.mjs +27 -0
  312. package/.output/server/chunks/routes/api/workshop/harnesses.get.mjs.map +1 -0
  313. package/.output/server/chunks/routes/api/workshop/hitl/pending.get.mjs +2 -2
  314. package/.output/server/chunks/routes/api/workshop/hitl/respond.post.mjs +20 -8
  315. package/.output/server/chunks/routes/api/workshop/hitl/respond.post.mjs.map +1 -1
  316. package/.output/server/chunks/routes/api/workshop/index.get.mjs +1 -1
  317. package/.output/server/chunks/routes/api/workshop/index.post.mjs +1 -1
  318. package/.output/server/chunks/routes/api/workshop/index10.get.mjs +1 -1
  319. package/.output/server/chunks/routes/api/workshop/index2.get.mjs +1 -1
  320. package/.output/server/chunks/routes/api/workshop/index2.post.mjs +1 -1
  321. package/.output/server/chunks/routes/api/workshop/index3.get.mjs +1 -1
  322. package/.output/server/chunks/routes/api/workshop/index3.post.mjs +2 -2
  323. package/.output/server/chunks/routes/api/workshop/index4.get.mjs +2 -2
  324. package/.output/server/chunks/routes/api/workshop/index4.post.mjs +2 -2
  325. package/.output/server/chunks/routes/api/workshop/index5.get.mjs +2 -2
  326. package/.output/server/chunks/routes/api/workshop/index5.post.mjs +2 -2
  327. package/.output/server/chunks/routes/api/workshop/index6.get.mjs +1 -1
  328. package/.output/server/chunks/routes/api/workshop/index6.post.mjs +2 -2
  329. package/.output/server/chunks/routes/api/workshop/index7.get.mjs +1 -1
  330. package/.output/server/chunks/routes/api/workshop/index7.post.mjs +1 -1
  331. package/.output/server/chunks/routes/api/workshop/index8.get.mjs +1 -1
  332. package/.output/server/chunks/routes/api/workshop/index8.post.mjs +1 -1
  333. package/.output/server/chunks/routes/api/workshop/index9.get.mjs +1 -1
  334. package/.output/server/chunks/routes/api/workshop/mailbox/all.get.mjs +1 -1
  335. package/.output/server/chunks/routes/api/workshop/mailbox.get.mjs +1 -1
  336. package/.output/server/chunks/routes/api/workshop/memories/maintenance.post.mjs +1 -1
  337. package/.output/server/chunks/routes/api/workshop/plugins/_name/disable.post.mjs +2 -2
  338. package/.output/server/chunks/routes/api/workshop/plugins/_name/enable.post.mjs +2 -2
  339. package/.output/server/chunks/routes/api/workshop/plugins/index.get.mjs +1 -1
  340. package/.output/server/chunks/routes/api/workshop/runtime.get.mjs +1 -1
  341. package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.delete.mjs +2 -2
  342. package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.put.mjs +2 -2
  343. package/.output/server/chunks/routes/api/workshop/scene/layouts.get.mjs +1 -1
  344. package/.output/server/chunks/routes/api/workshop/tasks/_id/complete.post.mjs +1 -1
  345. package/.output/server/chunks/routes/api/workshop/tasks/_id/dispatch.post.mjs +1 -1
  346. package/.output/server/chunks/routes/api/workshop/tasks/_id/index.post.mjs +1 -1
  347. package/.output/server/chunks/routes/api/workshop/tasks/_id/report.post.mjs +1 -1
  348. package/.output/server/chunks/routes/api/workshop/tasks/_id/retry.post.mjs +1 -1
  349. package/.output/server/chunks/routes/api/workshop/tasks/_id_.get.mjs +1 -1
  350. package/.output/server/chunks/routes/api/workshop/tasks.get.mjs +1 -1
  351. package/.output/server/chunks/routes/api/workshop/teams/_id/deploy.post.mjs +2 -2
  352. package/.output/server/chunks/routes/api/workshop/teams/_id/index.get.mjs +1 -1
  353. package/.output/server/chunks/routes/api/workshop/teams/_id/index.post.mjs +1 -1
  354. package/.output/server/chunks/routes/api/workshop/teams/_id/members/_agentId_.delete.mjs +1 -1
  355. package/.output/server/chunks/routes/api/workshop/teams/_id_.delete.mjs +1 -1
  356. package/.output/server/chunks/routes/api/workshop/teams/_id_.get.mjs +1 -1
  357. package/.output/server/chunks/routes/api/workshop/teams/_id_.patch.mjs +1 -1
  358. package/.output/server/chunks/routes/api/workshop/users/me.get.mjs +1 -1
  359. package/.output/server/chunks/routes/api/workshop/users/register.post.mjs +1 -1
  360. package/.output/server/chunks/routes/api/workshop/workspaces/_id/channel-templates/_tplId_.post.mjs +3 -3
  361. package/.output/server/chunks/routes/api/workshop/workspaces/_id/channels/_channelId_.delete.mjs +1 -1
  362. package/.output/server/chunks/routes/api/workshop/workspaces/_id/channels/_channelId_.post.mjs +1 -1
  363. package/.output/server/chunks/routes/api/workshop/workspaces/index.delete.mjs +1 -1
  364. package/.output/server/chunks/routes/renderer.mjs +2 -2
  365. package/.output/server/chunks/virtual/entry.mjs +132 -114
  366. package/.output/server/chunks/virtual/entry.mjs.map +1 -1
  367. package/.output/server/chunks/virtual/precomputed.mjs +1 -1
  368. package/.output/server/index.mjs +1 -1
  369. package/.output/server/package.json +1 -1
  370. package/README-zh.md +27 -7
  371. package/README.md +455 -435
  372. package/app/components/AppHeader.vue +56 -2
  373. package/app/components/workshop/ChannelSessionList.vue +703 -593
  374. package/app/components/workshop/terminal/OmpTerminalPanel.vue +2 -1
  375. package/app/composables/workshop/useLocalTime.ts +16 -0
  376. package/app/composables/workshop/useSceneLayouts.ts +2 -1
  377. package/app/composables/workshop/useWorkshopApi.ts +249 -224
  378. package/app/pages/daq/[id].vue +7 -6
  379. package/app/pages/daq/index.vue +2 -2
  380. package/app/pages/dcw/[id].vue +3 -3
  381. package/app/pages/workshop/agents.vue +432 -382
  382. package/app/pages/workshop/index.vue +25 -6
  383. package/bin/aw.mjs +0 -0
  384. package/cli/aw.mjs +8 -1
  385. package/cli/commands/stop.mjs +7 -4
  386. package/cli/commands/tui.mjs +10 -1
  387. package/cli/core/registry.mjs +5 -3
  388. package/config.yml +144 -134
  389. package/docs/tui.md +1 -1
  390. package/i18n/dicts/settings.json +4 -0
  391. package/i18n/locales/en.ts +9 -0
  392. package/i18n/locales/zh-CN.ts +9 -0
  393. package/package.json +148 -140
  394. package/scripts/_dbg-catalog-smoke.ts +20 -0
  395. package/scripts/_dbg-codex-handshake.ts +30 -0
  396. package/scripts/_dbg-codex-probe.mjs +58 -0
  397. package/scripts/_dbg-codex-sandbox.ts +58 -0
  398. package/scripts/_dbg-codex-turn.ts +65 -0
  399. package/scripts/_dbg-dsh-probe.mjs +31 -0
  400. package/scripts/_dbg-interval-config.mjs +145 -0
  401. package/scripts/_dbg-interval-scenario.mjs +126 -0
  402. package/scripts/_dbg-line-spawn.ts +31 -0
  403. package/scripts/_dbg-live-engine-probe.mjs +80 -0
  404. package/scripts/_dbg-mcp-bridge-probe.mjs +147 -0
  405. package/scripts/_dbg-opencode-sse.mjs +101 -0
  406. package/scripts/_dbg-opencode-start.ts +57 -0
  407. package/scripts/_dbg-plugin-matrix.mjs +212 -0
  408. package/scripts/_dbg-protocol-matrix.mjs +425 -0
  409. package/scripts/_dbg-real-scenario-timeline.log +123 -0
  410. package/scripts/_dbg-registry-smoke.ts +14 -0
  411. package/scripts/_dbg-setup-e2e.mjs +88 -0
  412. package/scripts/_dbg-sim-keeper.mjs +100 -0
  413. package/scripts/_dbg-team-drill.mjs +173 -0
  414. package/scripts/dev-guard.mjs +11 -3
  415. package/scripts/dev-protocol-simulators.mjs +28 -1
  416. package/scripts/e2e-harness-provider-task.mjs +126 -0
  417. package/scripts/e2e-multi-harness.ts +374 -0
  418. package/scripts/e2e-multiharness-team.mjs +319 -0
  419. package/scripts/e2e-plc-scenario.mjs +292 -0
  420. package/scripts/e2e-real-scenario.mjs +452 -0
  421. package/scripts/migrate-local-time.mjs +123 -0
  422. package/scripts/start.mjs +30 -2
  423. package/server/api/system/settings/index.get.ts +3 -3
  424. package/server/api/users/setup-status.get.ts +8 -0
  425. package/server/api/workshop/agent-tools/invoke.post.ts +27 -41
  426. package/server/api/workshop/agent-tools/list.get.ts +25 -0
  427. package/server/api/workshop/channels/[id]/index.patch.ts +38 -30
  428. package/server/api/workshop/daq/[id]/samples.get.ts +8 -3
  429. package/server/api/workshop/harnesses/[id]/providers.get.ts +16 -0
  430. package/server/api/workshop/harnesses.get.ts +12 -0
  431. package/server/api/workshop/hitl/respond.post.ts +87 -67
  432. package/server/api/workshop/ws.ts +13 -0
  433. package/server/data/daqs.json +1421 -19
  434. package/server/data/dcw-lines.json +273 -0
  435. package/server/data/dcw-products.json +224 -0
  436. package/server/data/dcw-recipes.json +868 -0
  437. package/server/data/dcw-rollback.json +1177 -1
  438. package/server/data/dcw-runs.json +3032 -2834
  439. package/server/data/dcw-writes.json +1116 -0
  440. package/server/data/dcws.json +3447 -297
  441. package/server/data/line-runs.json +52 -2
  442. package/server/harness/aw-mcp-bridge.mjs +153 -0
  443. package/server/plugins/00-local-time.ts +10 -0
  444. package/server/plugins/aw-plugins.ts +3 -0
  445. package/server/plugins/backup.ts +116 -97
  446. package/server/plugins/dev-stability-guard.ts +24 -15
  447. package/server/plugins/retention.ts +1 -0
  448. package/server/plugins/security.ts +46 -29
  449. package/server/plugins/workshop.ts +156 -153
  450. package/server/repositories/user.repository.ts +15 -22
  451. package/server/services/system-config.ts +32 -6
  452. package/server/services/user.service.ts +8 -3
  453. package/server/services/workshop/.mimosa/hook-state/sess_fed429fb-c8b7-4a50-bbd6-45afc580893f.json +1 -0
  454. package/server/services/workshop/.mimosa/hook-status/sess_fed429fb-c8b7-4a50-bbd6-45afc580893f-e6b75bbfe6.json +14 -0
  455. package/server/services/workshop/agents/adapters/line-spawn.ts +111 -0
  456. package/server/services/workshop/agents/adapters/stdio-jsonrpc.ts +316 -0
  457. package/server/services/workshop/agents/agent-interface.ts +17 -0
  458. package/server/services/workshop/agents/codex-agent.ts +822 -0
  459. package/server/services/workshop/agents/dsh-agent.ts +670 -0
  460. package/server/services/workshop/agents/factory.ts +4 -16
  461. package/server/services/workshop/agents/harness-env.ts +54 -0
  462. package/server/services/workshop/agents/harness-models.ts +270 -0
  463. package/server/services/workshop/agents/host-tool-bridge.ts +612 -0
  464. package/server/services/workshop/agents/industrial-tools.ts +7 -1
  465. package/server/services/workshop/agents/node-bindings.repo.ts +4 -5
  466. package/server/services/workshop/agents/omp-agent.ts +1178 -1957
  467. package/server/services/workshop/agents/opencode-agent.ts +987 -0
  468. package/server/services/workshop/agents/prompt-builder.ts +393 -0
  469. package/server/services/workshop/agents/registry.ts +125 -0
  470. package/server/services/workshop/assets/character-asset.repo.ts +3 -5
  471. package/server/services/workshop/assets/device-twin.repo.ts +3 -5
  472. package/server/services/workshop/daq/daq-controller.ts +38 -6
  473. package/server/services/workshop/daq/daq-node.repo.ts +3 -5
  474. package/server/services/workshop/daq/daq-node.ts +3 -3
  475. package/server/services/workshop/daq/daq-runtime.ts +4 -3
  476. package/server/services/workshop/daq/daq-templates.ts +3 -5
  477. package/server/services/workshop/daq/drivers.ts +41 -12
  478. package/server/services/workshop/daq/storage/sqlite.adapter.ts +313 -309
  479. package/server/services/workshop/db/backup-registry.ts +33 -0
  480. package/server/services/workshop/db/channel.repo.ts +104 -101
  481. package/server/services/workshop/db/database.ts +956 -949
  482. package/server/services/workshop/dcw/dcw-controller.ts +5 -1
  483. package/server/services/workshop/dcw/dcw-line.repo.ts +4 -11
  484. package/server/services/workshop/dcw/dcw-node.repo.ts +3 -5
  485. package/server/services/workshop/dcw/dcw-node.ts +13 -1
  486. package/server/services/workshop/dcw/dcw-product.repo.ts +3 -4
  487. package/server/services/workshop/dcw/dcw-recipe.repo.ts +3 -19
  488. package/server/services/workshop/dcw/dcw-templates.ts +3 -5
  489. package/server/services/workshop/dcw/drivers.ts +37 -13
  490. package/server/services/workshop/dcw/line-run.ts +3 -5
  491. package/server/services/workshop/dcw/recipe-rollback.repo.ts +4 -10
  492. package/server/services/workshop/json-store.mjs +72 -0
  493. package/server/services/workshop/plugins/host.mjs +2 -1
  494. package/server/services/workshop/runtime/agent-runtime.ts +44 -0
  495. package/server/services/workshop/runtime/manager.ts +2953 -2868
  496. package/server/services/workshop/scene/scene-layout.repo.ts +4 -11
  497. package/server/services/workshop/settings.ts +30 -0
  498. package/shared/config/schema.json +9 -0
  499. package/shared/config/single-instance.mjs +5 -1
  500. package/shared/local-time.mjs +36 -0
  501. package/shared/workshop-protocol.ts +11 -5
  502. package/tui/aw-tui.mjs +28 -10
  503. package/tui/components/hitl-card.mjs +47 -36
  504. package/tui/lib/ws.mjs +2 -1
  505. package/.output/public/_nuxt/9X0fVBD7.js +0 -57
  506. package/.output/public/_nuxt/B6M2WJWm2.js +0 -1
  507. package/.output/public/_nuxt/B9Yie5HN.js +0 -2
  508. package/.output/public/_nuxt/BF9XPEuw.js +0 -1
  509. package/.output/public/_nuxt/BbQornXa.js +0 -1
  510. package/.output/public/_nuxt/Bxgaym6j.js +0 -1
  511. package/.output/public/_nuxt/Bxh5nf8j.js +0 -1
  512. package/.output/public/_nuxt/CXLI50Sq.js +0 -1
  513. package/.output/public/_nuxt/CdfAP_IH2.js +0 -1
  514. package/.output/public/_nuxt/Ce1zyNYu.js +0 -1
  515. package/.output/public/_nuxt/D-Ne4C9a.js +0 -1
  516. package/.output/public/_nuxt/DEHNjlTq2.js +0 -1
  517. package/.output/public/_nuxt/DFnGFEav.js +0 -18
  518. package/.output/public/_nuxt/DYWgGHNo.js +0 -7
  519. package/.output/public/_nuxt/OmpTerminalPanel.Bc9GjNU5.css +0 -1
  520. package/.output/public/_nuxt/W1E3-5ML.js +0 -14
  521. package/.output/public/_nuxt/XVB9_zwP.js +0 -1
  522. package/.output/public/_nuxt/Xaf_HIR3.js +0 -1
  523. package/.output/public/_nuxt/_id_.BeqSLvl_.css +0 -1
  524. package/.output/public/_nuxt/_id_.DN3U6EF9.css +0 -1
  525. package/.output/public/_nuxt/agents.BJwgTLFZ.css +0 -1
  526. package/.output/public/_nuxt/builds/meta/55c10854-ee0e-4be4-924b-a1b0e100fe11.json +0 -1
  527. package/.output/public/_nuxt/daq.BXsnevQv.css +0 -1
  528. package/.output/public/_nuxt/workshop.B98sHiJq.css +0 -1
  529. package/.output/public/_nuxt/yIKY_V1P.js +0 -1
  530. package/.output/server/chunks/build/OmpTerminalPanel-B_SYhmgb.mjs.map +0 -1
  531. package/.output/server/chunks/build/_id_-CWLFGZjV.mjs.map +0 -1
  532. package/.output/server/chunks/build/agents-D4l1icvn.mjs.map +0 -1
  533. package/.output/server/chunks/build/channel-templates-DqjtC-R0.mjs.map +0 -1
  534. package/.output/server/chunks/build/interval-WlxgjTzO.mjs +0 -9
  535. package/.output/server/chunks/build/interval-WlxgjTzO.mjs.map +0 -1
  536. package/.output/server/chunks/build/teams-QR3BBF7A.mjs.map +0 -1
  537. package/.output/server/chunks/build/useWorkshopApi-Bh5VUHWu.mjs.map +0 -1
  538. package/.output/server/chunks/build/workshop-k0XZTFKg.mjs.map +0 -1
@@ -0,0 +1,822 @@
1
+ /**
2
+ * CodexAgentImpl — OpenAI Codex CLI(app-server)harness 的 AgentInterface 实现。
3
+ *
4
+ * 进程模型:每 Agent 一个 `codex app-server` 子进程(stdio NDJSON JSON-RPC v2,
5
+ * lazy spawn 跨消息复用);thread/start 建会话,turn/start 驱动回合。
6
+ *
7
+ * - prompt/工具面与 omp 全引擎同源(prompt-builder / host-tool-bridge);
8
+ * 工具经 stdio MCP 桥注入(config.toml 由 impl 装配 [mcp_servers.aw])
9
+ * - 事件映射:item/agentMessage/delta → delta;item/started → 🔧 status;
10
+ * turn/completed → artifact + done / error(codexErrorInfo 结构化)
11
+ * - HITL:item/commandExecution|fileChange/requestApproval(server→client 请求)
12
+ * → hitl-registry 登记 → respondHitl 应答(decision: accept/decline/cancel)
13
+ * - steer:turn 运行中 → turn/steer;无 active turn → 'deferred'
14
+ * - 上下文治理:thread/tokenUsage/updated 被动跟踪;越阈值 → thread/compact/start
15
+ *
16
+ * 协议权威:github.com/openai/codex codex-rs/app-server/README.md(v0.149 实测)。
17
+ */
18
+ import { createLogger } from '../logger'
19
+ import { randomUUID } from 'node:crypto'
20
+ import { join } from 'node:path'
21
+ import { mkdirSync, writeFileSync, existsSync, readFileSync, copyFileSync } from 'node:fs'
22
+ import { tmpdir } from 'node:os'
23
+ import type {
24
+ AgentEvent,
25
+ AgentInterface,
26
+ AgentInfo,
27
+ AgentRunContext,
28
+ AgentRunRequest,
29
+ SupervisionDecision,
30
+ SupervisionSnapshot,
31
+ } from './agent-interface'
32
+ import type { AgentContextStats } from '../types/task'
33
+ import { registerHarnessProcess, bindHarnessProcess, markHarnessProcessExit, killHarnessProcess } from './harness-process'
34
+ import { createSessionState, dispatchHostTool } from './host-tool-bridge'
35
+ import {
36
+ contextPrefix as buildContextPrefix,
37
+ createRosterCache,
38
+ extractJsonArray,
39
+ peerPrompt,
40
+ supervisePrompt,
41
+ systemManual,
42
+ toolArgsPreview,
43
+ workerPrompt,
44
+ } from './prompt-builder'
45
+ import { getHitlRegistry } from './hitl-registry'
46
+ import { harnessSettings } from '../settings'
47
+ import { StdioJsonRpcClient } from './adapters/stdio-jsonrpc'
48
+ import { generateMcpBridgeEnv } from './harness-env'
49
+
50
+ const log = createLogger('workshop.codex')
51
+
52
+ export interface CodexAgentConfig {
53
+ /** codex 可执行文件(默认取 harness.codex_command 设置) */
54
+ command?: string
55
+ /** 额外 CLI 参数(app-server 之前) */
56
+ args?: string[]
57
+ cwd?: string
58
+ /** 模型(如 gpt-5.2) */
59
+ model?: string
60
+ /** 审批策略(默认 on-request:沙箱内自由,越界请求审批 → HITL) */
61
+ approvalPolicy?: 'untrusted' | 'on-request' | 'never'
62
+ /** 沙箱(默认 workspace-write) */
63
+ sandbox?: 'read-only' | 'workspace-write' | 'danger-full-access'
64
+ /** CODEX_HOME(缺省进程环境;配置隔离/多账户时按 agent 指定;effort 未指定 home 时自动种子化) */
65
+ codexHome?: string
66
+ /** 思考 effort(model_reasoning_effort;需 CODEX_HOME 配置面,未指定 home 时自动种子化) */
67
+ effort?: string
68
+ /** 上下文窗口(usage 百分比计算) */
69
+ contextWindow?: number
70
+ /** 压缩阈值(0-1,默认 0.7) */
71
+ compactThreshold?: number
72
+ promptTimeoutMs?: number
73
+ superviseTimeoutMs?: number
74
+ systemPromptPrefix?: string
75
+ scenarioPrompt?: string
76
+ agentId?: string
77
+ name?: string
78
+ role?: 'lead' | 'worker'
79
+ channelId?: string
80
+ token?: string
81
+ baseUrl?: string
82
+ mcpBridgePath?: string
83
+ }
84
+
85
+ export class CodexAgentImpl implements AgentInterface {
86
+ private readonly config: CodexAgentConfig
87
+ private workspace: AgentRunContext['workspace'] | null = null
88
+ private agentInfo: AgentInfo | null = null
89
+ private readonly toolState = createSessionState()
90
+ private readonly bridgeCtx = {
91
+ identity: { agentId: '', channelId: '', role: 'worker' as 'lead' | 'worker', name: 'agent' },
92
+ state: this.toolState,
93
+ getWorkspace: () => this.workspace,
94
+ }
95
+
96
+ private roster = createRosterCache({ selfAgentId: '', listAgents: async () => [] })
97
+
98
+ private selfAgentId = ''
99
+ private agentName = 'agent'
100
+ private agentRole: 'lead' | 'worker' = 'worker'
101
+ private channelId = ''
102
+
103
+ private client: StdioJsonRpcClient | null = null
104
+ private clientStarting: Promise<void> | null = null
105
+ private threadId: string | null = null
106
+ private turnId: string | null = null
107
+
108
+ // 回合状态
109
+ private turnActive = false
110
+ private deltaBuf = ''
111
+ private deltaTimer: ReturnType<typeof setTimeout> | null = null
112
+ private lastUsage: { input: number, at: number } | null = null
113
+ private compacting = false
114
+ private lastCompactAt = 0
115
+ /** 待应答审批(approval request id → JSON-RPC id) */
116
+ private pendingApprovals = new Map<string, { rpcId: string | number, timer: ReturnType<typeof setTimeout> | null }>()
117
+
118
+ constructor(config: Record<string, unknown> = {}) {
119
+ this.config = config as CodexAgentConfig
120
+ this.selfAgentId = this.config.agentId ?? ''
121
+ this.agentName = this.config.name ?? 'agent'
122
+ this.agentRole = this.config.role ?? 'worker'
123
+ this.channelId = this.config.channelId ?? ''
124
+ this.refreshIdentity()
125
+ }
126
+
127
+ private refreshIdentity(): void {
128
+ this.bridgeCtx.identity = { agentId: this.selfAgentId, channelId: this.channelId, role: this.agentRole, name: this.agentName }
129
+ this.roster = createRosterCache({
130
+ selfAgentId: this.selfAgentId,
131
+ listAgents: async () => this.workspace?.listAgents() ?? [],
132
+ })
133
+ }
134
+
135
+ async init(input: { agent: AgentInfo, channelId: string }): Promise<void> {
136
+ this.agentInfo = input.agent
137
+ this.channelId = input.channelId
138
+ this.agentName = input.agent.name
139
+ this.agentRole = input.agent.role
140
+ this.selfAgentId = input.agent.id
141
+ this.refreshIdentity()
142
+ }
143
+
144
+ async dispose(): Promise<void> {
145
+ const client = this.client
146
+ this.client = null
147
+ this.threadId = null
148
+ if (client) {
149
+ const pid = client.pid
150
+ await client.dispose().catch(() => {})
151
+ if (pid) markHarnessProcessExit(pid, null)
152
+ }
153
+ for (const [id, p] of this.pendingApprovals) {
154
+ if (p.timer) clearTimeout(p.timer)
155
+ this.pendingApprovals.delete(id)
156
+ }
157
+ }
158
+
159
+ getProcessInfo(): { pid: number, alive: boolean, command: string } | null {
160
+ const client = this.client
161
+ const pid = client?.pid
162
+ if (!pid || !client) return null
163
+ return { pid, alive: client.alive, command: 'codex app-server' }
164
+ }
165
+
166
+ killProcess(): void {
167
+ const pid = this.client?.pid
168
+ if (pid) killHarnessProcess(pid)
169
+ else this.client?.kill()
170
+ }
171
+
172
+ reconcileProcess(): void {
173
+ this.client?.reconcile()
174
+ }
175
+
176
+ dispatchHostTool(toolName: string, args: Record<string, unknown>): Promise<{ text: string, isError?: boolean }> {
177
+ return dispatchHostTool(this.bridgeCtx, { toolName, arguments: args })
178
+ }
179
+
180
+ getContextStats(): AgentContextStats | null {
181
+ if (!this.lastUsage) return null
182
+ const window = this.config.contextWindow ?? null
183
+ return {
184
+ usedTokens: this.lastUsage.input,
185
+ contextWindow: window,
186
+ percent: window && window > 0 ? Math.min(1, this.lastUsage.input / window) : null,
187
+ compacting: this.compacting,
188
+ }
189
+ }
190
+
191
+ /** 实时注入:turn 运行中 → turn/steer;否则 'deferred'(消息保持 pending) */
192
+ async steer(text: string): Promise<'steer' | 'deferred'> {
193
+ const client = this.client
194
+ if (!client?.alive || !this.threadId || !this.turnActive) return 'deferred'
195
+ try {
196
+ await client.request('turn/steer', {
197
+ threadId: this.threadId,
198
+ input: [{ type: 'text', text }],
199
+ }, 15_000)
200
+ return 'steer'
201
+ }
202
+ catch {
203
+ // 无 active turn / 引擎拒绝 → 消息保持 pending 由消费循环处理
204
+ return 'deferred'
205
+ }
206
+ }
207
+
208
+ /** HITL 应答:审批请求 → JSON-RPC 应答(decision) */
209
+ async respondHitl(kind: string, id: string, outcome: {
210
+ confirmed?: boolean
211
+ cancelled?: boolean
212
+ value?: string
213
+ response?: string
214
+ comment?: string
215
+ }): Promise<void> {
216
+ if (kind !== 'codex-approval') return
217
+ const pending = this.pendingApprovals.get(id)
218
+ if (!pending) throw new Error(`待办不存在或已处理: ${id}`)
219
+ const client = this.client
220
+ if (!client) throw new Error('codex 会话已关闭')
221
+ const decision = outcome.cancelled === true
222
+ ? 'cancel'
223
+ : outcome.confirmed === true ? 'accept' : 'decline'
224
+ client.respond(pending.rpcId, { decision })
225
+ if (pending.timer) clearTimeout(pending.timer)
226
+ this.pendingApprovals.delete(id)
227
+ getHitlRegistry().resolve(kind, id, decision === 'cancel' ? 'cancelled' : 'answered')
228
+ }
229
+
230
+ /** 上下文治理(post-settle):越阈值 → thread/compact/start */
231
+ async onTurnSettled(): Promise<void> {
232
+ const client = this.client
233
+ if (!client?.alive || !this.threadId || this.compacting) return
234
+ const stats = this.getContextStats()
235
+ const threshold = this.config.compactThreshold ?? 0.7
236
+ if (!stats?.percent || stats.percent < threshold) return
237
+ if (Date.now() - this.lastCompactAt < 5 * 60_000) return
238
+ this.compacting = true
239
+ this.lastCompactAt = Date.now()
240
+ try {
241
+ await client.request('thread/compact/start', { threadId: this.threadId }, 30_000)
242
+ log.info(`[CodexAgent:${this.selfAgentId}] 上下文压缩已触发(percent=${(stats.percent * 100).toFixed(0)}%)`)
243
+ }
244
+ catch (err) {
245
+ log.warn(`[CodexAgent:${this.selfAgentId}] compact 发起失败(放行):`, err instanceof Error ? err.message : err)
246
+ }
247
+ finally {
248
+ this.compacting = false
249
+ }
250
+ }
251
+
252
+ // ===== run / supervise =====
253
+
254
+ async* run(request: AgentRunRequest, ctx: AgentRunContext): AsyncIterable<AgentEvent> {
255
+ const kind = request.message.metadata?.['x-aw-task-kind']
256
+ if (kind === 'assign' && ctx.role === 'worker') {
257
+ yield* this.workerRun(request, ctx)
258
+ return
259
+ }
260
+ if (!kind && (request.fromAgentId || request.message.metadata?.['x-aw-from-label'])) {
261
+ yield* this.peerMessageRun(request, ctx)
262
+ return
263
+ }
264
+ }
265
+
266
+ private supervising = false
267
+
268
+ async supervise(snapshot: SupervisionSnapshot, ctx: AgentRunContext, opts?: { signal?: AbortSignal }): Promise<SupervisionDecision[]> {
269
+ await this.ensureClient(ctx)
270
+ if (!this.client || !this.threadId) return []
271
+ if (this.supervising) return []
272
+ const prompt = supervisePrompt({
273
+ snapshot,
274
+ agentName: this.agentName,
275
+ channelId: this.channelId,
276
+ ctxPrefix: await this.contextPrefix(),
277
+ manual: systemManual(),
278
+ memory: ctx.memory,
279
+ })
280
+ this.supervising = true
281
+ try {
282
+ const events = await this.collectTurn(prompt, this.config.superviseTimeoutMs ?? 150_000, opts?.signal)
283
+ let text = ''
284
+ for (const e of events) {
285
+ if (e.kind === 'artifact') {
286
+ text += e.artifact.parts.map(p => 'text' in p ? p.text : '').join('')
287
+ }
288
+ }
289
+ const parsed = extractJsonArray(text)
290
+ return parsed && parsed.length > 0 ? parsed as SupervisionDecision[] : []
291
+ }
292
+ catch {
293
+ return []
294
+ }
295
+ finally {
296
+ this.supervising = false
297
+ }
298
+ }
299
+
300
+ private async* workerRun(request: AgentRunRequest, ctx: AgentRunContext): AsyncGenerator<AgentEvent, void, unknown> {
301
+ const taskId = request.taskId ?? (request.message.metadata?.['x-aw-task-id'] as string | undefined)
302
+ if (!taskId) return
303
+ this.toolState.currentTaskId = taskId
304
+ try {
305
+ await this.ensureClient(ctx)
306
+ const taskText = request.message.parts.map((p) => {
307
+ if ('text' in p) return p.text
308
+ if ('data' in p) return JSON.stringify(p.data)
309
+ if ('url' in p) return p.url
310
+ if ('raw' in p) return p.raw
311
+ return ''
312
+ }).join('\n')
313
+ const prompt = workerPrompt({
314
+ agentName: this.agentName,
315
+ channelId: this.channelId,
316
+ taskId,
317
+ taskText,
318
+ memory: request.memory,
319
+ ctxPrefix: await this.contextPrefix(),
320
+ manual: systemManual(),
321
+ })
322
+ yield* this.streamTurn(prompt, taskId, this.config.promptTimeoutMs ?? 600_000, ctx.signal)
323
+ }
324
+ finally {
325
+ this.toolState.currentTaskId = null
326
+ }
327
+ }
328
+
329
+ private async* peerMessageRun(request: AgentRunRequest, ctx: AgentRunContext): AsyncGenerator<AgentEvent, void, unknown> {
330
+ await this.ensureClient(ctx)
331
+ const msg = request.message
332
+ const fromId = request.fromAgentId
333
+ ?? (typeof msg.metadata?.['x-aw-from-label'] === 'string' ? msg.metadata['x-aw-from-label'] : undefined)
334
+ ?? 'unknown'
335
+ const requireReply = msg.metadata?.['x-aw-require-reply'] === 'true'
336
+ const crossChannel = msg.metadata?.['x-aw-cross-channel'] === 'true'
337
+ this.toolState.replyContext = requireReply && request.fromAgentId && !crossChannel
338
+ ? { fromId: request.fromAgentId, messageId: msg.messageId }
339
+ : null
340
+ const msgText = msg.parts.map((p) => {
341
+ if ('text' in p) return p.text
342
+ if ('data' in p) return JSON.stringify(p.data)
343
+ if ('url' in p) return p.url
344
+ if ('raw' in p) return p.raw
345
+ return ''
346
+ }).join('\n')
347
+ const prompt = peerPrompt({
348
+ agentName: this.agentName,
349
+ role: this.agentRole,
350
+ channelId: this.channelId,
351
+ ctxPrefix: await this.contextPrefix(),
352
+ manual: systemManual(),
353
+ memory: request.memory,
354
+ fromId,
355
+ messageId: msg.messageId,
356
+ requireReply,
357
+ isReply: typeof msg.metadata?.['x-aw-in-reply-to'] === 'string',
358
+ crossChannel,
359
+ fromChannel: typeof msg.metadata?.['x-aw-from-channel'] === 'string' ? String(msg.metadata['x-aw-from-channel']) : '',
360
+ msgText,
361
+ })
362
+ yield* this.streamTurn(prompt, undefined, this.config.promptTimeoutMs ?? 600_000, ctx.signal)
363
+ }
364
+
365
+ private async contextPrefix(): Promise<string> {
366
+ return buildContextPrefix({
367
+ scenarioPrompt: this.config.scenarioPrompt,
368
+ systemPromptPrefix: this.config.systemPromptPrefix,
369
+ agentId: this.selfAgentId,
370
+ roster: await this.roster.roster(),
371
+ })
372
+ }
373
+
374
+ // ===== 回合执行 =====
375
+
376
+ /**
377
+ * 流式回合:turn/start → 逐事件产出(delta/status)→ turn/completed 收口。
378
+ * artifact 在 done 前注入(item/completed agentMessage 聚合文本)。
379
+ */
380
+ private async* streamTurn(prompt: string, taskId: string | undefined, timeoutMs: number, signal?: AbortSignal): AsyncGenerator<AgentEvent, void, unknown> {
381
+ const client = this.client
382
+ if (!client || !this.threadId) {
383
+ yield { kind: 'error', error: { code: 'CODEX_NOT_READY', message: 'codex 会话未就绪' } }
384
+ return
385
+ }
386
+ const queue: AgentEvent[] = []
387
+ let isDone = false
388
+ let resolveWait: (() => void) | null = null
389
+ let lastActivity = Date.now()
390
+ let agentText = ''
391
+ this.turnActive = true
392
+ this.turnId = null
393
+
394
+ const enqueue = (e: AgentEvent): void => {
395
+ if (e.kind === 'done' && !isDone) {
396
+ if (agentText.trim()) {
397
+ queue.push({
398
+ kind: 'artifact',
399
+ artifact: { artifactId: randomUUID(), name: 'output', parts: [{ text: agentText.trim() }] },
400
+ lastChunk: true,
401
+ totalChunks: 1,
402
+ })
403
+ }
404
+ this.turnActive = false
405
+ }
406
+ if (e.kind === 'done' || e.kind === 'error') {
407
+ isDone = true
408
+ this.turnActive = false
409
+ flushDelta()
410
+ }
411
+ queue.push(e)
412
+ lastActivity = Date.now()
413
+ resolveWait?.()
414
+ resolveWait = null
415
+ }
416
+
417
+ const flushDelta = (): void => {
418
+ if (this.deltaTimer) {
419
+ clearTimeout(this.deltaTimer)
420
+ this.deltaTimer = null
421
+ }
422
+ if (!this.deltaBuf) return
423
+ const text = this.deltaBuf
424
+ this.deltaBuf = ''
425
+ queue.push({ kind: 'delta', delta: { text } })
426
+ }
427
+ const pushDelta = (text: string): void => {
428
+ this.deltaBuf += text
429
+ this.deltaTimer ??= setTimeout(() => {
430
+ this.deltaTimer = null
431
+ flushDelta()
432
+ }, 50)
433
+ }
434
+
435
+ // 通知订阅(审批请求处理器已在 startClient 挂接,此处只处理回合通知)
436
+ const unsub = client.onNotification((method, params) => {
437
+ const p = (params ?? {}) as Record<string, unknown>
438
+ lastActivity = Date.now()
439
+ if (method === 'item/agentMessage/delta') {
440
+ const delta = typeof p.delta === 'string' ? p.delta : ''
441
+ if (delta) {
442
+ this.turnActive = true
443
+ pushDelta(delta)
444
+ }
445
+ return
446
+ }
447
+ if (method === 'turn/started') {
448
+ const turn = p.turn as Record<string, unknown> | undefined
449
+ this.turnId = typeof turn?.id === 'string' ? turn.id : this.turnId
450
+ this.turnActive = true
451
+ enqueue({ kind: 'status', status: { state: 'WORKING', timestamp: new Date().toISOString() } })
452
+ return
453
+ }
454
+ if (method === 'item/started') {
455
+ const item = p.item as Record<string, unknown> | undefined
456
+ const t = String(item?.type ?? '')
457
+ if (['commandExecution', 'mcpToolCall', 'fileChange', 'dynamicToolCall', 'webSearch', 'collabToolCall'].includes(t)) {
458
+ const label = t === 'commandExecution'
459
+ ? String(item?.command ?? 'command')
460
+ : String(item?.tool ?? item?.title ?? t)
461
+ enqueue({
462
+ kind: 'status',
463
+ status: {
464
+ state: 'WORKING',
465
+ message: {
466
+ messageId: randomUUID(),
467
+ contextId: this.channelId,
468
+ role: 'ROLE_AGENT',
469
+ parts: [{ text: `🔧 ${label}${toolArgsPreview(item?.input ?? item?.arguments ?? item?.command)}` }],
470
+ },
471
+ timestamp: new Date().toISOString(),
472
+ },
473
+ })
474
+ }
475
+ if (t === 'contextCompaction') this.compacting = true
476
+ return
477
+ }
478
+ if (method === 'item/completed') {
479
+ const item = p.item as Record<string, unknown> | undefined
480
+ if (String(item?.type ?? '') === 'agentMessage' && typeof item?.text === 'string') {
481
+ agentText += item.text
482
+ }
483
+ if (String(item?.type ?? '') === 'contextCompaction') this.compacting = false
484
+ return
485
+ }
486
+ if (method === 'thread/tokenUsage/updated') {
487
+ const usage = (p.usage ?? p.tokenUsage ?? p) as Record<string, unknown>
488
+ const input = Number(usage.input_tokens ?? usage.inputTokens ?? usage.total_tokens ?? usage.totalTokens)
489
+ if (Number.isFinite(input) && input > 0) this.lastUsage = { input, at: Date.now() }
490
+ return
491
+ }
492
+ if (method === 'turn/completed') {
493
+ const turn = (p.turn ?? {}) as Record<string, unknown>
494
+ const status = String(turn.status ?? 'completed')
495
+ if (status === 'failed') {
496
+ const err = (turn.error ?? {}) as Record<string, unknown>
497
+ const info = String(err.codexErrorInfo ?? '')
498
+ enqueue({
499
+ kind: 'error',
500
+ error: {
501
+ code: info ? `CODEX_${info}` : 'CODEX_LLM_ERROR',
502
+ message: String(err.message ?? 'codex 回合失败'),
503
+ },
504
+ })
505
+ }
506
+ else {
507
+ // completed / interrupted:中断按 done 收口(消息按已处理落账)
508
+ enqueue({ kind: 'done', final: taskId ? { taskId } : undefined })
509
+ }
510
+ return
511
+ }
512
+ if (method === 'error') {
513
+ enqueue({
514
+ kind: 'error',
515
+ error: { code: 'CODEX_ERROR', message: String(p.message ?? p.error ?? JSON.stringify(params).slice(0, 300)) },
516
+ })
517
+ }
518
+ })
519
+
520
+ // abort 传导
521
+ const onAbort = (): void => {
522
+ log.warn(`[CodexAgent:${this.selfAgentId}] run 被 abort → turn/interrupt,taskId=${taskId ?? '-'}`)
523
+ void client.request('turn/interrupt', { threadId: this.threadId, ...(this.turnId ? { turnId: this.turnId } : {}) }, 15_000).catch(() => {})
524
+ setTimeout(() => {
525
+ if (!isDone) enqueue({ kind: 'done', final: taskId ? { taskId } : undefined })
526
+ }, 5000)
527
+ }
528
+ if (signal?.aborted) onAbort()
529
+ else signal?.addEventListener('abort', onAbort, { once: true })
530
+
531
+ // 投递 turn
532
+ try {
533
+ await client.request('turn/start', {
534
+ threadId: this.threadId,
535
+ input: [{ type: 'text', text: prompt }],
536
+ }, 60_000)
537
+ }
538
+ catch (err) {
539
+ unsub()
540
+ signal?.removeEventListener('abort', onAbort)
541
+ this.turnActive = false
542
+ yield {
543
+ kind: 'error',
544
+ error: {
545
+ code: 'CODEX_PROMPT_FAILED',
546
+ message: `codex turn/start 失败: ${err instanceof Error ? err.message : String(err)}`,
547
+ },
548
+ }
549
+ return
550
+ }
551
+
552
+ try {
553
+ while (!isDone || queue.length > 0) {
554
+ if (queue.length === 0 && !isDone) {
555
+ const remaining = timeoutMs - (Date.now() - lastActivity)
556
+ if (remaining <= 0) {
557
+ void client.request('turn/interrupt', { threadId: this.threadId }, 15_000).catch(() => {})
558
+ enqueue({
559
+ kind: 'error',
560
+ error: { code: 'CODEX_TURN_STALLED', message: `回合停滞 ${Math.round(timeoutMs / 1000)}s 无事件,已中止` },
561
+ })
562
+ continue
563
+ }
564
+ await new Promise<void>((r) => {
565
+ resolveWait = r
566
+ setTimeout(() => {
567
+ resolveWait = null
568
+ r()
569
+ }, remaining + 100)
570
+ })
571
+ }
572
+ while (queue.length > 0) {
573
+ yield queue.shift()!
574
+ }
575
+ }
576
+ }
577
+ finally {
578
+ flushDelta()
579
+ unsub()
580
+ signal?.removeEventListener('abort', onAbort)
581
+ this.turnActive = false
582
+ this.turnId = null
583
+ }
584
+ }
585
+
586
+ /** supervise 用:收齐整个回合的事件流(supervise 决策解析在调用方) */
587
+ private async collectTurn(prompt: string, timeoutMs: number, signal?: AbortSignal): Promise<AgentEvent[]> {
588
+ const events: AgentEvent[] = []
589
+ for await (const e of this.streamTurn(prompt, undefined, timeoutMs, signal)) {
590
+ events.push(e)
591
+ if (e.kind === 'error') break
592
+ }
593
+ return events
594
+ }
595
+
596
+ // ===== HITL 登记 =====
597
+
598
+ private registerApprovalHitl(rpcId: string | number, itemId: string, kindLabel: 'command' | 'file', p: Record<string, unknown>): void {
599
+ const id = `codex-${itemId}`
600
+ if (this.pendingApprovals.has(id)) return
601
+ const title = kindLabel === 'command'
602
+ ? `codex 命令审批:${String(p.command ?? '(未知命令)').slice(0, 200)}`
603
+ : `codex 文件变更审批:${String(p.cwd ?? p.grantRoot ?? '')}`
604
+ const registry = getHitlRegistry()
605
+ registry.register({
606
+ kind: 'codex-approval',
607
+ id,
608
+ agentId: this.selfAgentId,
609
+ agentName: this.agentName,
610
+ channelId: this.channelId,
611
+ pid: this.client?.pid,
612
+ method: 'confirm',
613
+ title,
614
+ detail: typeof p.reason === 'string' ? p.reason : undefined,
615
+ createdAt: new Date().toISOString(),
616
+ expiresAt: null,
617
+ })
618
+ const timeoutMs = harnessSettings().hitl_timeout_ms
619
+ const timer = timeoutMs > 0
620
+ ? setTimeout(() => {
621
+ void this.respondHitl('codex-approval', id, { cancelled: true }).catch(() => {})
622
+ registry.resolve('codex-approval', id, 'expired')
623
+ }, timeoutMs)
624
+ : null
625
+ this.pendingApprovals.set(id, { rpcId, timer })
626
+ }
627
+
628
+ private registerUserInputHitl(rpcId: string | number, p: Record<string, unknown>): void {
629
+ const id = `codex-input-${randomUUID().slice(0, 8)}`
630
+ const questions = Array.isArray(p.questions) ? p.questions : []
631
+ const first = (questions[0] ?? {}) as Record<string, unknown>
632
+ const registry = getHitlRegistry()
633
+ registry.register({
634
+ kind: 'codex-approval',
635
+ id,
636
+ agentId: this.selfAgentId,
637
+ agentName: this.agentName,
638
+ channelId: this.channelId,
639
+ pid: this.client?.pid,
640
+ method: 'input',
641
+ title: String(first.question ?? first.header ?? 'codex 提问'),
642
+ detail: typeof p.reason === 'string' ? p.reason : undefined,
643
+ createdAt: new Date().toISOString(),
644
+ expiresAt: null,
645
+ })
646
+ const timeoutMs = harnessSettings().hitl_timeout_ms
647
+ const timer = timeoutMs > 0
648
+ ? setTimeout(() => {
649
+ void this.respondUserInput(rpcId, id, { cancelled: true }).catch(() => {})
650
+ }, timeoutMs)
651
+ : null
652
+ this.pendingApprovals.set(id, { rpcId, timer })
653
+ }
654
+
655
+ private async respondUserInput(rpcId: string | number, id: string, outcome: { cancelled?: boolean, value?: string }): Promise<void> {
656
+ const pending = this.pendingApprovals.get(id)
657
+ if (!pending) return
658
+ const client = this.client
659
+ if (!client) return
660
+ if (outcome.cancelled) {
661
+ client.respondError(rpcId, -32800, '人工取消')
662
+ getHitlRegistry().resolve('codex-approval', id, 'cancelled')
663
+ }
664
+ else {
665
+ client.respond(rpcId, { answers: [{ answer: outcome.value ?? '' }] })
666
+ getHitlRegistry().resolve('codex-approval', id, 'answered')
667
+ }
668
+ if (pending.timer) clearTimeout(pending.timer)
669
+ this.pendingApprovals.delete(id)
670
+ }
671
+
672
+ // ===== 客户端管理 =====
673
+
674
+ private async ensureClient(ctx: AgentRunContext): Promise<void> {
675
+ if (!this.workspace) this.workspace = ctx.workspace
676
+ if (!this.agentInfo) {
677
+ this.channelId = ctx.channelId
678
+ this.agentRole = ctx.role
679
+ this.refreshIdentity()
680
+ }
681
+ if (this.client?.alive && this.threadId) return
682
+ if (this.client && !this.client.alive) {
683
+ this.client = null
684
+ this.threadId = null
685
+ }
686
+ this.clientStarting ??= this.startClient().finally(() => {
687
+ this.clientStarting = null
688
+ })
689
+ await this.clientStarting
690
+ }
691
+
692
+ private async startClient(): Promise<void> {
693
+ const command = this.config.command ?? harnessSettings().codex_command
694
+ const client = new StdioJsonRpcClient({
695
+ name: 'codex',
696
+ command,
697
+ args: [...(this.config.args ?? []), 'app-server'],
698
+ cwd: this.config.cwd ?? process.cwd(),
699
+ env: generateMcpBridgeEnv({
700
+ agentId: this.selfAgentId,
701
+ token: this.config.token,
702
+ baseUrl: this.config.baseUrl,
703
+ bridgePath: this.config.mcpBridgePath,
704
+ extra: this.config.codexHome ? { CODEX_HOME: this.config.codexHome } : {},
705
+ }).engineEnv,
706
+ requestTimeoutMs: 60_000,
707
+ })
708
+ const pidRef = { pid: undefined as number | undefined }
709
+ client.onExit((code) => {
710
+ if (pidRef.pid) markHarnessProcessExit(pidRef.pid, code)
711
+ this.threadId = null
712
+ log.warn(`[CodexAgent:${this.selfAgentId}] codex app-server 退出(code=${code});下回合自动重生`)
713
+ })
714
+ await client.start()
715
+ pidRef.pid = client.pid
716
+ if (client.pid) {
717
+ registerHarnessProcess(client.pid, { harness: 'codex', command, args: ['app-server'] })
718
+ bindHarnessProcess(client.pid, { agentId: this.selfAgentId, channelId: this.channelId, name: this.agentName, role: this.agentRole })
719
+ }
720
+
721
+ // 握手
722
+ await client.request('initialize', {
723
+ clientInfo: { name: 'agentworkshop', title: 'AgentWorkShop', version: '0.8.0' },
724
+ }, 30_000)
725
+ client.notify('initialized', {})
726
+
727
+ // MCP 桥装配(per-agent CODEX_HOME 的 config.toml [mcp_servers.aw])
728
+ this.writeCodexHomeConfig()
729
+
730
+ // 建会话
731
+ const result = await client.request('thread/start', {
732
+ ...(this.config.model ? { model: this.config.model } : {}),
733
+ cwd: this.config.cwd ?? process.cwd(),
734
+ approvalPolicy: this.config.approvalPolicy ?? 'on-request',
735
+ sandbox: this.config.sandbox ?? 'workspace-write',
736
+ }, 60_000) as Record<string, unknown>
737
+ const thread = (result?.thread ?? result) as Record<string, unknown>
738
+ this.threadId = typeof thread?.id === 'string' ? thread.id : null
739
+ if (!this.threadId) throw new Error('codex thread/start 未返回 thread id')
740
+
741
+ // 事件监听挂接(通知在 streamTurn 内按回合订阅;此处仅挂请求处理器)
742
+ client.onRequest((req) => {
743
+ if (req.method === 'item/commandExecution/requestApproval' || req.method === 'item/fileChange/requestApproval') {
744
+ const p = (req.params ?? {}) as Record<string, unknown>
745
+ this.registerApprovalHitl(req.id, String(p.itemId ?? randomUUID()), req.method === 'item/fileChange/requestApproval' ? 'file' : 'command', p)
746
+ }
747
+ else if (req.method === 'tool/requestUserInput') {
748
+ const p = (req.params ?? {}) as Record<string, unknown>
749
+ this.registerUserInputHitl(req.id, p)
750
+ }
751
+ else {
752
+ client.respondError(req.id, -32601, `方法不存在: ${req.method}`)
753
+ }
754
+ })
755
+
756
+ this.client = client
757
+ }
758
+
759
+ /**
760
+ * per-agent CODEX_HOME config.toml:注册 MCP 桥(required=true,桥挂了宁可失败)。
761
+ * 已有 config.toml(从全局目录种子化复制)→ 追加本段(保留用户的 provider/model
762
+ * 配置,自定义网关/密钥不丢失);全新目录 → 独立写入。
763
+ */
764
+ private writeCodexHomeConfig(): void {
765
+ let home = this.config.codexHome
766
+ if (!home && this.config.effort) {
767
+ // effort 需要配置文件面(model_reasoning_effort):自动种子化 per-agent CODEX_HOME
768
+ // (拷贝全局凭据/网关配置,保登录与自定义 provider;追加 MCP 段 + 顶部 effort)
769
+ home = join(tmpdir(), `aw-codex-${this.selfAgentId.slice(0, 8)}`)
770
+ this.config.codexHome = home
771
+ for (const f of ['auth.json', 'config.toml', 'cc-switch-model-catalog.json']) {
772
+ try {
773
+ const src = join(process.env.HOME ?? process.env.USERPROFILE ?? '', '.codex', f)
774
+ if (existsSync(src)) copyFileSync(src, join(home, f))
775
+ }
776
+ catch { /* 单文件缺失忽略 */ }
777
+ }
778
+ }
779
+ if (!home) return
780
+ try {
781
+ mkdirSync(home, { recursive: true })
782
+ const configFile = join(home, 'config.toml')
783
+ const env = generateMcpBridgeEnv({ agentId: this.selfAgentId, token: this.config.token, baseUrl: this.config.baseUrl, bridgePath: this.config.mcpBridgePath })
784
+ const envLines = Object.entries(env.bridgeEnv).map(([k, v]) => ` ${k} = "${v}"`).join('\n')
785
+ const section = [
786
+ ``,
787
+ `[mcp_servers.aw]`,
788
+ `command = ${JSON.stringify(process.execPath)}`,
789
+ `args = [${JSON.stringify(join(process.env.AW_PACKAGE_ROOT ?? process.cwd(), 'server', 'harness', 'aw-mcp-bridge.mjs'))}]`,
790
+ `required = true`,
791
+ ``,
792
+ `[mcp_servers.aw.env]`,
793
+ envLines,
794
+ ``,
795
+ ].join('\n')
796
+ // effort 走 TOML 顶层键(model_reasoning_effort):必须位于任何 [table] 之前 → 顶部插入
797
+ const effortLine = this.config.effort
798
+ ? `model_reasoning_effort = ${JSON.stringify(this.config.effort)}
799
+ `
800
+ : ''
801
+ if (existsSync(configFile)) {
802
+ const existing = readFileSync(configFile, 'utf-8')
803
+ const withoutDup = this.config.effort
804
+ ? existing.replace(/^model_reasoning_effort = .*\n?/m, '')
805
+ : existing
806
+ if (withoutDup.includes('[mcp_servers.aw]')) {
807
+ if (effortLine && !withoutDup.startsWith(effortLine.trim())) {
808
+ writeFileSync(configFile, effortLine + withoutDup, 'utf-8')
809
+ }
810
+ return
811
+ }
812
+ writeFileSync(configFile, effortLine + withoutDup + section, 'utf-8')
813
+ }
814
+ else {
815
+ writeFileSync(configFile, effortLine + section, 'utf-8')
816
+ }
817
+ }
818
+ catch (err) {
819
+ log.warn(`[CodexAgent:${this.selfAgentId}] CODEX_HOME config 写入失败(信任全局配置):`, err instanceof Error ? err.message : err)
820
+ }
821
+ }
822
+ }