botmux 3.7.1 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (622) hide show
  1. package/dist/.runtime-build-id +1 -1
  2. package/dist/adapters/backend/capabilities.d.ts +17 -0
  3. package/dist/adapters/backend/capabilities.d.ts.map +1 -0
  4. package/dist/adapters/backend/capabilities.js +22 -0
  5. package/dist/adapters/backend/capabilities.js.map +1 -0
  6. package/dist/adapters/backend/critical-control-key.d.ts +19 -0
  7. package/dist/adapters/backend/critical-control-key.d.ts.map +1 -0
  8. package/dist/adapters/backend/critical-control-key.js +34 -0
  9. package/dist/adapters/backend/critical-control-key.js.map +1 -0
  10. package/dist/adapters/backend/herdr-backend.d.ts +9 -0
  11. package/dist/adapters/backend/herdr-backend.d.ts.map +1 -1
  12. package/dist/adapters/backend/herdr-backend.js +23 -4
  13. package/dist/adapters/backend/herdr-backend.js.map +1 -1
  14. package/dist/adapters/backend/riff-backend.d.ts.map +1 -1
  15. package/dist/adapters/backend/riff-backend.js +3 -2
  16. package/dist/adapters/backend/riff-backend.js.map +1 -1
  17. package/dist/adapters/backend/session-backend-selector.d.ts +61 -6
  18. package/dist/adapters/backend/session-backend-selector.d.ts.map +1 -1
  19. package/dist/adapters/backend/session-backend-selector.js +173 -9
  20. package/dist/adapters/backend/session-backend-selector.js.map +1 -1
  21. package/dist/adapters/backend/tmux-backend.d.ts +10 -3
  22. package/dist/adapters/backend/tmux-backend.d.ts.map +1 -1
  23. package/dist/adapters/backend/tmux-backend.js +25 -8
  24. package/dist/adapters/backend/tmux-backend.js.map +1 -1
  25. package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -1
  26. package/dist/adapters/backend/tmux-pipe-backend.js +3 -2
  27. package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -1
  28. package/dist/adapters/backend/types.d.ts +45 -4
  29. package/dist/adapters/backend/types.d.ts.map +1 -1
  30. package/dist/adapters/backend/types.js +11 -0
  31. package/dist/adapters/backend/types.js.map +1 -1
  32. package/dist/adapters/backend/zellij-backend.d.ts.map +1 -1
  33. package/dist/adapters/backend/zellij-backend.js +3 -2
  34. package/dist/adapters/backend/zellij-backend.js.map +1 -1
  35. package/dist/adapters/backend/zmx-backend.d.ts +286 -0
  36. package/dist/adapters/backend/zmx-backend.d.ts.map +1 -0
  37. package/dist/adapters/backend/zmx-backend.js +2396 -0
  38. package/dist/adapters/backend/zmx-backend.js.map +1 -0
  39. package/dist/adapters/cli/claude-code.d.ts.map +1 -1
  40. package/dist/adapters/cli/claude-code.js +3 -0
  41. package/dist/adapters/cli/claude-code.js.map +1 -1
  42. package/dist/adapters/cli/codex-app.d.ts.map +1 -1
  43. package/dist/adapters/cli/codex-app.js +5 -1
  44. package/dist/adapters/cli/codex-app.js.map +1 -1
  45. package/dist/adapters/cli/codex.d.ts.map +1 -1
  46. package/dist/adapters/cli/codex.js +26 -1
  47. package/dist/adapters/cli/codex.js.map +1 -1
  48. package/dist/adapters/cli/fs-policy.d.ts +79 -1
  49. package/dist/adapters/cli/fs-policy.d.ts.map +1 -1
  50. package/dist/adapters/cli/fs-policy.js +290 -13
  51. package/dist/adapters/cli/fs-policy.js.map +1 -1
  52. package/dist/adapters/cli/grok.d.ts.map +1 -1
  53. package/dist/adapters/cli/grok.js +4 -1
  54. package/dist/adapters/cli/grok.js.map +1 -1
  55. package/dist/adapters/cli/oh-my-pi.d.ts.map +1 -1
  56. package/dist/adapters/cli/oh-my-pi.js +5 -3
  57. package/dist/adapters/cli/oh-my-pi.js.map +1 -1
  58. package/dist/adapters/cli/shared-hints.d.ts +7 -4
  59. package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
  60. package/dist/adapters/cli/shared-hints.js +52 -35
  61. package/dist/adapters/cli/shared-hints.js.map +1 -1
  62. package/dist/adapters/cli/strict-input-handle.d.ts +13 -0
  63. package/dist/adapters/cli/strict-input-handle.d.ts.map +1 -0
  64. package/dist/adapters/cli/strict-input-handle.js +39 -0
  65. package/dist/adapters/cli/strict-input-handle.js.map +1 -0
  66. package/dist/adapters/cli/traex.d.ts.map +1 -1
  67. package/dist/adapters/cli/traex.js +6 -4
  68. package/dist/adapters/cli/traex.js.map +1 -1
  69. package/dist/adapters/cli/types.d.ts +16 -0
  70. package/dist/adapters/cli/types.d.ts.map +1 -1
  71. package/dist/bot-registry.d.ts +137 -8
  72. package/dist/bot-registry.d.ts.map +1 -1
  73. package/dist/bot-registry.js +298 -12
  74. package/dist/bot-registry.js.map +1 -1
  75. package/dist/cli/session-list-liveness.d.ts +1 -1
  76. package/dist/cli/session-list-liveness.js +1 -1
  77. package/dist/cli/zmx-managed-attach.d.ts +41 -0
  78. package/dist/cli/zmx-managed-attach.d.ts.map +1 -0
  79. package/dist/cli/zmx-managed-attach.js +72 -0
  80. package/dist/cli/zmx-managed-attach.js.map +1 -0
  81. package/dist/cli.d.ts.map +1 -1
  82. package/dist/cli.js +780 -131
  83. package/dist/cli.js.map +1 -1
  84. package/dist/codex-app-runner.js +90 -2
  85. package/dist/codex-app-runner.js.map +1 -1
  86. package/dist/codex-rpc-engine.d.ts.map +1 -1
  87. package/dist/codex-rpc-engine.js +22 -6
  88. package/dist/codex-rpc-engine.js.map +1 -1
  89. package/dist/config.d.ts +5 -0
  90. package/dist/config.d.ts.map +1 -1
  91. package/dist/config.js +29 -1
  92. package/dist/config.js.map +1 -1
  93. package/dist/core/ask-broker.d.ts +22 -1
  94. package/dist/core/ask-broker.d.ts.map +1 -1
  95. package/dist/core/ask-broker.js +12 -5
  96. package/dist/core/ask-broker.js.map +1 -1
  97. package/dist/core/botmux-wrapper.d.ts +18 -0
  98. package/dist/core/botmux-wrapper.d.ts.map +1 -1
  99. package/dist/core/botmux-wrapper.js +25 -1
  100. package/dist/core/botmux-wrapper.js.map +1 -1
  101. package/dist/core/chat-rename.d.ts +27 -0
  102. package/dist/core/chat-rename.d.ts.map +1 -0
  103. package/dist/core/chat-rename.js +53 -0
  104. package/dist/core/chat-rename.js.map +1 -0
  105. package/dist/core/command-handler.d.ts.map +1 -1
  106. package/dist/core/command-handler.js +160 -12
  107. package/dist/core/command-handler.js.map +1 -1
  108. package/dist/core/cost-calculator.d.ts +25 -1
  109. package/dist/core/cost-calculator.d.ts.map +1 -1
  110. package/dist/core/cost-calculator.js +102 -4
  111. package/dist/core/cost-calculator.js.map +1 -1
  112. package/dist/core/dashboard-ipc-server.d.ts +16 -2
  113. package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
  114. package/dist/core/dashboard-ipc-server.js +611 -62
  115. package/dist/core/dashboard-ipc-server.js.map +1 -1
  116. package/dist/core/dashboard-rows.d.ts +22 -1
  117. package/dist/core/dashboard-rows.d.ts.map +1 -1
  118. package/dist/core/dashboard-rows.js +61 -0
  119. package/dist/core/dashboard-rows.js.map +1 -1
  120. package/dist/core/dashboard-url.d.ts +6 -0
  121. package/dist/core/dashboard-url.d.ts.map +1 -1
  122. package/dist/core/dashboard-url.js +11 -1
  123. package/dist/core/dashboard-url.js.map +1 -1
  124. package/dist/core/device-isolation-daemon.d.ts +28 -6
  125. package/dist/core/device-isolation-daemon.d.ts.map +1 -1
  126. package/dist/core/device-isolation-daemon.js +96 -13
  127. package/dist/core/device-isolation-daemon.js.map +1 -1
  128. package/dist/core/host-overload-alert.d.ts +75 -0
  129. package/dist/core/host-overload-alert.d.ts.map +1 -1
  130. package/dist/core/host-overload-alert.js +103 -0
  131. package/dist/core/host-overload-alert.js.map +1 -1
  132. package/dist/core/idle-worker-sweeper.js +1 -1
  133. package/dist/core/idle-worker-sweeper.js.map +1 -1
  134. package/dist/core/inflight-input-tracker.d.ts +3 -0
  135. package/dist/core/inflight-input-tracker.d.ts.map +1 -1
  136. package/dist/core/inflight-input-tracker.js +9 -0
  137. package/dist/core/inflight-input-tracker.js.map +1 -1
  138. package/dist/core/passthrough-commands.d.ts.map +1 -1
  139. package/dist/core/passthrough-commands.js +10 -0
  140. package/dist/core/passthrough-commands.js.map +1 -1
  141. package/dist/core/persistent-backend.d.ts +32 -4
  142. package/dist/core/persistent-backend.d.ts.map +1 -1
  143. package/dist/core/persistent-backend.js +75 -6
  144. package/dist/core/persistent-backend.js.map +1 -1
  145. package/dist/core/plugins/mcp/gateway.js +2 -2
  146. package/dist/core/plugins/mcp/gateway.js.map +1 -1
  147. package/dist/core/plugins/runtime.d.ts +3 -0
  148. package/dist/core/plugins/runtime.d.ts.map +1 -1
  149. package/dist/core/plugins/runtime.js.map +1 -1
  150. package/dist/core/plugins/service-manager.d.ts +4 -1
  151. package/dist/core/plugins/service-manager.d.ts.map +1 -1
  152. package/dist/core/plugins/service-manager.js +11 -6
  153. package/dist/core/plugins/service-manager.js.map +1 -1
  154. package/dist/core/role-library.d.ts +48 -1
  155. package/dist/core/role-library.d.ts.map +1 -1
  156. package/dist/core/role-library.js +111 -3
  157. package/dist/core/role-library.js.map +1 -1
  158. package/dist/core/role-resolver.d.ts +14 -2
  159. package/dist/core/role-resolver.d.ts.map +1 -1
  160. package/dist/core/role-resolver.js +47 -4
  161. package/dist/core/role-resolver.js.map +1 -1
  162. package/dist/core/session-activity.d.ts +14 -0
  163. package/dist/core/session-activity.d.ts.map +1 -1
  164. package/dist/core/session-activity.js +46 -1
  165. package/dist/core/session-activity.js.map +1 -1
  166. package/dist/core/session-board.d.ts +5 -2
  167. package/dist/core/session-board.d.ts.map +1 -1
  168. package/dist/core/session-board.js +5 -2
  169. package/dist/core/session-board.js.map +1 -1
  170. package/dist/core/session-liveness.d.ts +6 -5
  171. package/dist/core/session-liveness.d.ts.map +1 -1
  172. package/dist/core/session-liveness.js +34 -13
  173. package/dist/core/session-liveness.js.map +1 -1
  174. package/dist/core/session-manager.d.ts +3 -2
  175. package/dist/core/session-manager.d.ts.map +1 -1
  176. package/dist/core/session-manager.js +397 -103
  177. package/dist/core/session-manager.js.map +1 -1
  178. package/dist/core/session-marker.d.ts +11 -2
  179. package/dist/core/session-marker.d.ts.map +1 -1
  180. package/dist/core/session-marker.js +50 -11
  181. package/dist/core/session-marker.js.map +1 -1
  182. package/dist/core/session-message-preview.d.ts +20 -0
  183. package/dist/core/session-message-preview.d.ts.map +1 -0
  184. package/dist/core/session-message-preview.js +188 -0
  185. package/dist/core/session-message-preview.js.map +1 -0
  186. package/dist/core/session-title.d.ts +5 -1
  187. package/dist/core/session-title.d.ts.map +1 -1
  188. package/dist/core/session-title.js +20 -3
  189. package/dist/core/session-title.js.map +1 -1
  190. package/dist/core/startup-commands.d.ts +1 -1
  191. package/dist/core/startup-commands.js +1 -1
  192. package/dist/core/terminal-url.d.ts.map +1 -1
  193. package/dist/core/terminal-url.js +3 -2
  194. package/dist/core/terminal-url.js.map +1 -1
  195. package/dist/core/trigger-session.d.ts.map +1 -1
  196. package/dist/core/trigger-session.js +75 -12
  197. package/dist/core/trigger-session.js.map +1 -1
  198. package/dist/core/types.d.ts +35 -0
  199. package/dist/core/types.d.ts.map +1 -1
  200. package/dist/core/types.js +23 -0
  201. package/dist/core/types.js.map +1 -1
  202. package/dist/core/worker-ipc.d.ts +11 -0
  203. package/dist/core/worker-ipc.d.ts.map +1 -0
  204. package/dist/core/worker-ipc.js +26 -0
  205. package/dist/core/worker-ipc.js.map +1 -0
  206. package/dist/core/worker-pool.d.ts +179 -29
  207. package/dist/core/worker-pool.d.ts.map +1 -1
  208. package/dist/core/worker-pool.js +2118 -331
  209. package/dist/core/worker-pool.js.map +1 -1
  210. package/dist/daemon.d.ts +132 -3
  211. package/dist/daemon.d.ts.map +1 -1
  212. package/dist/daemon.js +1327 -449
  213. package/dist/daemon.js.map +1 -1
  214. package/dist/dashboard/auth.d.ts +2 -0
  215. package/dist/dashboard/auth.d.ts.map +1 -1
  216. package/dist/dashboard/auth.js +9 -0
  217. package/dist/dashboard/auth.js.map +1 -1
  218. package/dist/dashboard/bot-payload.d.ts +4 -0
  219. package/dist/dashboard/bot-payload.d.ts.map +1 -1
  220. package/dist/dashboard/bot-payload.js +5 -0
  221. package/dist/dashboard/bot-payload.js.map +1 -1
  222. package/dist/dashboard/federation-api.d.ts.map +1 -1
  223. package/dist/dashboard/federation-api.js +4 -0
  224. package/dist/dashboard/federation-api.js.map +1 -1
  225. package/dist/dashboard/federation-spoke-api.d.ts.map +1 -1
  226. package/dist/dashboard/federation-spoke-api.js +32 -5
  227. package/dist/dashboard/federation-spoke-api.js.map +1 -1
  228. package/dist/dashboard/public-redact.d.ts +8 -2
  229. package/dist/dashboard/public-redact.d.ts.map +1 -1
  230. package/dist/dashboard/public-redact.js +34 -7
  231. package/dist/dashboard/public-redact.js.map +1 -1
  232. package/dist/dashboard/session-card-model.d.ts.map +1 -1
  233. package/dist/dashboard/session-card-model.js +10 -2
  234. package/dist/dashboard/session-card-model.js.map +1 -1
  235. package/dist/dashboard/settings-write-applier.d.ts +35 -1
  236. package/dist/dashboard/settings-write-applier.d.ts.map +1 -1
  237. package/dist/dashboard/settings-write-applier.js +88 -1
  238. package/dist/dashboard/settings-write-applier.js.map +1 -1
  239. package/dist/dashboard/web/app.d.ts.map +1 -1
  240. package/dist/dashboard/web/app.js +0 -1
  241. package/dist/dashboard/web/app.js.map +1 -1
  242. package/dist/dashboard/web/bot-defaults-page.d.ts +15 -0
  243. package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
  244. package/dist/dashboard/web/bot-defaults-page.js +212 -58
  245. package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
  246. package/dist/dashboard/web/bot-defaults.d.ts +3 -0
  247. package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
  248. package/dist/dashboard/web/bot-defaults.js.map +1 -1
  249. package/dist/dashboard/web/bot-onboarding.d.ts +2 -1
  250. package/dist/dashboard/web/bot-onboarding.d.ts.map +1 -1
  251. package/dist/dashboard/web/bot-onboarding.js.map +1 -1
  252. package/dist/dashboard/web/clipboard.d.ts +2 -0
  253. package/dist/dashboard/web/clipboard.d.ts.map +1 -0
  254. package/dist/dashboard/web/clipboard.js +42 -0
  255. package/dist/dashboard/web/clipboard.js.map +1 -0
  256. package/dist/dashboard/web/connectors-page.d.ts.map +1 -1
  257. package/dist/dashboard/web/connectors-page.js +12 -8
  258. package/dist/dashboard/web/connectors-page.js.map +1 -1
  259. package/dist/dashboard/web/dashboard-components.d.ts +17 -16
  260. package/dist/dashboard/web/dashboard-components.d.ts.map +1 -1
  261. package/dist/dashboard/web/dashboard-components.js.map +1 -1
  262. package/dist/dashboard/web/groups-page.d.ts.map +1 -1
  263. package/dist/dashboard/web/groups-page.js +7 -3
  264. package/dist/dashboard/web/groups-page.js.map +1 -1
  265. package/dist/dashboard/web/i18n.d.ts.map +1 -1
  266. package/dist/dashboard/web/i18n.js +205 -12
  267. package/dist/dashboard/web/i18n.js.map +1 -1
  268. package/dist/dashboard/web/icon-tooltip.d.ts.map +1 -1
  269. package/dist/dashboard/web/icon-tooltip.js +16 -1
  270. package/dist/dashboard/web/icon-tooltip.js.map +1 -1
  271. package/dist/dashboard/web/listener-filters.d.ts +23 -0
  272. package/dist/dashboard/web/listener-filters.d.ts.map +1 -0
  273. package/dist/dashboard/web/listener-filters.js +36 -0
  274. package/dist/dashboard/web/listener-filters.js.map +1 -0
  275. package/dist/dashboard/web/overview-page.d.ts.map +1 -1
  276. package/dist/dashboard/web/overview-page.js.map +1 -1
  277. package/dist/dashboard/web/plugin-page.d.ts.map +1 -1
  278. package/dist/dashboard/web/plugin-page.js.map +1 -1
  279. package/dist/dashboard/web/preview-markdown.d.ts +5 -0
  280. package/dist/dashboard/web/preview-markdown.d.ts.map +1 -0
  281. package/dist/dashboard/web/preview-markdown.js +52 -0
  282. package/dist/dashboard/web/preview-markdown.js.map +1 -0
  283. package/dist/dashboard/web/roles-page.d.ts.map +1 -1
  284. package/dist/dashboard/web/roles-page.js +535 -10
  285. package/dist/dashboard/web/roles-page.js.map +1 -1
  286. package/dist/dashboard/web/roles.d.ts +77 -0
  287. package/dist/dashboard/web/roles.d.ts.map +1 -1
  288. package/dist/dashboard/web/roles.js +98 -0
  289. package/dist/dashboard/web/roles.js.map +1 -1
  290. package/dist/dashboard/web/session-terminal.d.ts.map +1 -1
  291. package/dist/dashboard/web/session-terminal.js +6 -4
  292. package/dist/dashboard/web/session-terminal.js.map +1 -1
  293. package/dist/dashboard/web/sessions-kanban.d.ts +4 -1
  294. package/dist/dashboard/web/sessions-kanban.d.ts.map +1 -1
  295. package/dist/dashboard/web/sessions-kanban.js +1 -1
  296. package/dist/dashboard/web/sessions-kanban.js.map +1 -1
  297. package/dist/dashboard/web/sessions-page.d.ts +3 -2
  298. package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
  299. package/dist/dashboard/web/sessions-page.js +163 -28
  300. package/dist/dashboard/web/sessions-page.js.map +1 -1
  301. package/dist/dashboard/web/sessions.d.ts +25 -0
  302. package/dist/dashboard/web/sessions.d.ts.map +1 -1
  303. package/dist/dashboard/web/sessions.js +58 -7
  304. package/dist/dashboard/web/sessions.js.map +1 -1
  305. package/dist/dashboard/web/settings-page.d.ts +28 -3
  306. package/dist/dashboard/web/settings-page.d.ts.map +1 -1
  307. package/dist/dashboard/web/settings-page.js +61 -1
  308. package/dist/dashboard/web/settings-page.js.map +1 -1
  309. package/dist/dashboard/web/skills-page.d.ts +6 -5
  310. package/dist/dashboard/web/skills-page.d.ts.map +1 -1
  311. package/dist/dashboard/web/skills-page.js +2 -0
  312. package/dist/dashboard/web/skills-page.js.map +1 -1
  313. package/dist/dashboard/web/v3-components.d.ts +3 -2
  314. package/dist/dashboard/web/v3-components.d.ts.map +1 -1
  315. package/dist/dashboard/web/v3-components.js.map +1 -1
  316. package/dist/dashboard/web/vc-consumer-profiles-section.d.ts +12 -2
  317. package/dist/dashboard/web/vc-consumer-profiles-section.d.ts.map +1 -1
  318. package/dist/dashboard/web/vc-consumer-profiles-section.js +0 -9
  319. package/dist/dashboard/web/vc-consumer-profiles-section.js.map +1 -1
  320. package/dist/dashboard/web/webhook-logs-page.d.ts +2 -1
  321. package/dist/dashboard/web/webhook-logs-page.d.ts.map +1 -1
  322. package/dist/dashboard/web/webhook-logs-page.js +4 -1
  323. package/dist/dashboard/web/webhook-logs-page.js.map +1 -1
  324. package/dist/dashboard-web/app.js +1 -1
  325. package/dist/dashboard-web/chunks/bot-defaults-page-FAPIMQV3.js +10 -0
  326. package/dist/dashboard-web/chunks/{chunk-QFMH6ITB.js → chunk-5CJMHTT4.js} +1 -1
  327. package/dist/dashboard-web/chunks/{chunk-KQB42ML5.js → chunk-DLZK52JU.js} +14 -12
  328. package/dist/dashboard-web/chunks/chunk-FDZ7WOBW.js +16 -0
  329. package/dist/dashboard-web/chunks/{chunk-3QAUJXAS.js → chunk-GTAJV5YC.js} +1 -1
  330. package/dist/dashboard-web/chunks/{chunk-FNPGOZMX.js → chunk-IHNG6KE6.js} +1 -1
  331. package/dist/dashboard-web/chunks/{chunk-FLGXZJTD.js → chunk-VA6QWSGQ.js} +1 -1
  332. package/dist/dashboard-web/chunks/chunk-XJ7BGPJH.js +1 -0
  333. package/dist/dashboard-web/chunks/chunk-ZJVTGU5X.js +1 -0
  334. package/dist/dashboard-web/chunks/connectors-page-LKWRT3GS.js +1 -0
  335. package/dist/dashboard-web/chunks/groups-page-V6654ICQ.js +8 -0
  336. package/dist/dashboard-web/chunks/insights-page-237RMFQ5.js +7 -0
  337. package/dist/dashboard-web/chunks/{monitor-room-7IVIS75W.js → monitor-room-OO5Y4FRQ.js} +1 -1
  338. package/dist/dashboard-web/chunks/{monitoring-page-5SSJRQZF.js → monitoring-page-OUEITM5P.js} +1 -1
  339. package/dist/dashboard-web/chunks/{office-page-EOND3L5D.js → office-page-4KNAHQ4Q.js} +1 -1
  340. package/dist/dashboard-web/chunks/{overview-page-NISBVBBJ.js → overview-page-QDP4YK2S.js} +1 -1
  341. package/dist/dashboard-web/chunks/{plugin-page-JXC5F5YV.js → plugin-page-VEGTCEAS.js} +1 -1
  342. package/dist/dashboard-web/chunks/roles-page-PGXNZZNP.js +1 -0
  343. package/dist/dashboard-web/chunks/{schedules-page-AVOOKLUH.js → schedules-page-BJNC5TID.js} +1 -1
  344. package/dist/dashboard-web/chunks/sessions-page-M2ZYYCMO.js +6 -0
  345. package/dist/dashboard-web/chunks/settings-page-IJFZKUUW.js +2 -0
  346. package/dist/dashboard-web/chunks/{skills-page-5MW54PCC.js → skills-page-YRAIRZOQ.js} +3 -3
  347. package/dist/dashboard-web/chunks/{team-federation-page-2SNIMVXI.js → team-federation-page-DEU27GRU.js} +1 -1
  348. package/dist/dashboard-web/chunks/{v3-page-W6SBXXQC.js → v3-page-6KHEW2YL.js} +5 -5
  349. package/dist/dashboard-web/chunks/{whiteboards-page-STC54KTP.js → whiteboards-page-VDECAALH.js} +1 -1
  350. package/dist/dashboard-web/style.css +12545 -11432
  351. package/dist/dashboard.js +215 -36
  352. package/dist/dashboard.js.map +1 -1
  353. package/dist/global-config.d.ts +41 -2
  354. package/dist/global-config.d.ts.map +1 -1
  355. package/dist/global-config.js +47 -0
  356. package/dist/global-config.js.map +1 -1
  357. package/dist/i18n/en.d.ts.map +1 -1
  358. package/dist/i18n/en.js +71 -19
  359. package/dist/i18n/en.js.map +1 -1
  360. package/dist/i18n/zh.d.ts.map +1 -1
  361. package/dist/i18n/zh.js +71 -19
  362. package/dist/i18n/zh.js.map +1 -1
  363. package/dist/im/lark/callback-button-marker.d.ts +34 -0
  364. package/dist/im/lark/callback-button-marker.d.ts.map +1 -0
  365. package/dist/im/lark/callback-button-marker.js +99 -0
  366. package/dist/im/lark/callback-button-marker.js.map +1 -0
  367. package/dist/im/lark/card-builder.d.ts +46 -10
  368. package/dist/im/lark/card-builder.d.ts.map +1 -1
  369. package/dist/im/lark/card-builder.js +299 -78
  370. package/dist/im/lark/card-builder.js.map +1 -1
  371. package/dist/im/lark/card-handler.d.ts +3 -4
  372. package/dist/im/lark/card-handler.d.ts.map +1 -1
  373. package/dist/im/lark/card-handler.js +380 -148
  374. package/dist/im/lark/card-handler.js.map +1 -1
  375. package/dist/im/lark/client.d.ts +24 -1
  376. package/dist/im/lark/client.d.ts.map +1 -1
  377. package/dist/im/lark/client.js +101 -8
  378. package/dist/im/lark/client.js.map +1 -1
  379. package/dist/im/lark/doc-comment.d.ts.map +1 -1
  380. package/dist/im/lark/doc-comment.js +6 -1
  381. package/dist/im/lark/doc-comment.js.map +1 -1
  382. package/dist/im/lark/event-dispatcher.d.ts +115 -3
  383. package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
  384. package/dist/im/lark/event-dispatcher.js +534 -147
  385. package/dist/im/lark/event-dispatcher.js.map +1 -1
  386. package/dist/im/lark/grant-command.d.ts +16 -12
  387. package/dist/im/lark/grant-command.d.ts.map +1 -1
  388. package/dist/im/lark/grant-command.js +48 -151
  389. package/dist/im/lark/grant-command.js.map +1 -1
  390. package/dist/im/lark/grant-pending.d.ts +12 -4
  391. package/dist/im/lark/grant-pending.d.ts.map +1 -1
  392. package/dist/im/lark/grant-pending.js +31 -8
  393. package/dist/im/lark/grant-pending.js.map +1 -1
  394. package/dist/im/lark/invite-command.d.ts +20 -0
  395. package/dist/im/lark/invite-command.d.ts.map +1 -0
  396. package/dist/im/lark/invite-command.js +239 -0
  397. package/dist/im/lark/invite-command.js.map +1 -0
  398. package/dist/im/lark/md-card.d.ts +66 -4
  399. package/dist/im/lark/md-card.d.ts.map +1 -1
  400. package/dist/im/lark/md-card.js +201 -31
  401. package/dist/im/lark/md-card.js.map +1 -1
  402. package/dist/im/lark/mention-targets.d.ts +43 -0
  403. package/dist/im/lark/mention-targets.d.ts.map +1 -0
  404. package/dist/im/lark/mention-targets.js +190 -0
  405. package/dist/im/lark/mention-targets.js.map +1 -0
  406. package/dist/im/lark/message-parser.d.ts +31 -0
  407. package/dist/im/lark/message-parser.d.ts.map +1 -1
  408. package/dist/im/lark/message-parser.js +305 -32
  409. package/dist/im/lark/message-parser.js.map +1 -1
  410. package/dist/im/lark/reply-card-footer-signature.d.ts +7 -0
  411. package/dist/im/lark/reply-card-footer-signature.d.ts.map +1 -0
  412. package/dist/im/lark/reply-card-footer-signature.js +7 -0
  413. package/dist/im/lark/reply-card-footer-signature.js.map +1 -0
  414. package/dist/im/lark/sessions-card.d.ts.map +1 -1
  415. package/dist/im/lark/sessions-card.js +4 -1
  416. package/dist/im/lark/sessions-card.js.map +1 -1
  417. package/dist/im/lark/substitute-command.d.ts.map +1 -1
  418. package/dist/im/lark/substitute-command.js +8 -0
  419. package/dist/im/lark/substitute-command.js.map +1 -1
  420. package/dist/im/lark/topic-root-context.d.ts +35 -0
  421. package/dist/im/lark/topic-root-context.d.ts.map +1 -0
  422. package/dist/im/lark/topic-root-context.js +37 -0
  423. package/dist/im/lark/topic-root-context.js.map +1 -0
  424. package/dist/im/lark/v3-blocked-card.d.ts.map +1 -1
  425. package/dist/im/lark/v3-blocked-card.js +2 -1
  426. package/dist/im/lark/v3-blocked-card.js.map +1 -1
  427. package/dist/im/lark/v3-gate-card.d.ts.map +1 -1
  428. package/dist/im/lark/v3-gate-card.js +2 -1
  429. package/dist/im/lark/v3-gate-card.js.map +1 -1
  430. package/dist/im/lark/v3-loop-grant-card.d.ts.map +1 -1
  431. package/dist/im/lark/v3-loop-grant-card.js +2 -1
  432. package/dist/im/lark/v3-loop-grant-card.js.map +1 -1
  433. package/dist/im/lark/v3-progress-card.d.ts.map +1 -1
  434. package/dist/im/lark/v3-progress-card.js +2 -1
  435. package/dist/im/lark/v3-progress-card.js.map +1 -1
  436. package/dist/im/lark/v3-revisit-grant-card.d.ts.map +1 -1
  437. package/dist/im/lark/v3-revisit-grant-card.js +2 -1
  438. package/dist/im/lark/v3-revisit-grant-card.js.map +1 -1
  439. package/dist/index-core-only.d.ts +3 -0
  440. package/dist/index-core-only.d.ts.map +1 -0
  441. package/dist/index-core-only.js +107 -0
  442. package/dist/index-core-only.js.map +1 -0
  443. package/dist/services/async-trigger-state.d.ts +8 -0
  444. package/dist/services/async-trigger-state.d.ts.map +1 -1
  445. package/dist/services/async-trigger-state.js +3 -2
  446. package/dist/services/async-trigger-state.js.map +1 -1
  447. package/dist/services/async-trigger-store.d.ts +10 -2
  448. package/dist/services/async-trigger-store.d.ts.map +1 -1
  449. package/dist/services/async-trigger-store.js +3 -2
  450. package/dist/services/async-trigger-store.js.map +1 -1
  451. package/dist/services/backend-availability.d.ts +3 -1
  452. package/dist/services/backend-availability.d.ts.map +1 -1
  453. package/dist/services/backend-availability.js +14 -1
  454. package/dist/services/backend-availability.js.map +1 -1
  455. package/dist/services/backend-type-store.d.ts.map +1 -1
  456. package/dist/services/backend-type-store.js +1 -1
  457. package/dist/services/backend-type-store.js.map +1 -1
  458. package/dist/services/bot-config-store.d.ts.map +1 -1
  459. package/dist/services/bot-config-store.js +2 -1
  460. package/dist/services/bot-config-store.js.map +1 -1
  461. package/dist/services/bridge-fallback-gate.d.ts +14 -1
  462. package/dist/services/bridge-fallback-gate.d.ts.map +1 -1
  463. package/dist/services/bridge-fallback-gate.js +65 -1
  464. package/dist/services/bridge-fallback-gate.js.map +1 -1
  465. package/dist/services/card-prefs-store.d.ts +7 -2
  466. package/dist/services/card-prefs-store.d.ts.map +1 -1
  467. package/dist/services/card-prefs-store.js +30 -4
  468. package/dist/services/card-prefs-store.js.map +1 -1
  469. package/dist/services/codex-app-runner-protocol.d.ts +9 -0
  470. package/dist/services/codex-app-runner-protocol.d.ts.map +1 -1
  471. package/dist/services/codex-app-runner-protocol.js +17 -0
  472. package/dist/services/codex-app-runner-protocol.js.map +1 -1
  473. package/dist/services/codex-app-token-usage.d.ts +93 -0
  474. package/dist/services/codex-app-token-usage.d.ts.map +1 -0
  475. package/dist/services/codex-app-token-usage.js +190 -0
  476. package/dist/services/codex-app-token-usage.js.map +1 -0
  477. package/dist/services/codex-transcript.d.ts +6 -1
  478. package/dist/services/codex-transcript.d.ts.map +1 -1
  479. package/dist/services/codex-transcript.js +103 -32
  480. package/dist/services/codex-transcript.js.map +1 -1
  481. package/dist/services/federation-roster.d.ts +4 -0
  482. package/dist/services/federation-roster.d.ts.map +1 -1
  483. package/dist/services/federation-roster.js +3 -0
  484. package/dist/services/federation-roster.js.map +1 -1
  485. package/dist/services/federation-store.d.ts +6 -0
  486. package/dist/services/federation-store.d.ts.map +1 -1
  487. package/dist/services/federation-store.js.map +1 -1
  488. package/dist/services/grant-policy.d.ts +13 -0
  489. package/dist/services/grant-policy.d.ts.map +1 -0
  490. package/dist/services/grant-policy.js +40 -0
  491. package/dist/services/grant-policy.js.map +1 -0
  492. package/dist/services/grant-store.d.ts +24 -3
  493. package/dist/services/grant-store.d.ts.map +1 -1
  494. package/dist/services/grant-store.js +196 -12
  495. package/dist/services/grant-store.js.map +1 -1
  496. package/dist/services/groups-store.d.ts +36 -0
  497. package/dist/services/groups-store.d.ts.map +1 -1
  498. package/dist/services/groups-store.js +123 -1
  499. package/dist/services/groups-store.js.map +1 -1
  500. package/dist/services/jsonl-cursor.d.ts.map +1 -1
  501. package/dist/services/jsonl-cursor.js +8 -2
  502. package/dist/services/jsonl-cursor.js.map +1 -1
  503. package/dist/services/local-cli-opener.d.ts.map +1 -1
  504. package/dist/services/local-cli-opener.js +32 -0
  505. package/dist/services/local-cli-opener.js.map +1 -1
  506. package/dist/services/message-listener-run-preview-store.d.ts +43 -0
  507. package/dist/services/message-listener-run-preview-store.d.ts.map +1 -0
  508. package/dist/services/message-listener-run-preview-store.js +152 -0
  509. package/dist/services/message-listener-run-preview-store.js.map +1 -0
  510. package/dist/services/message-listener-store.d.ts +26 -0
  511. package/dist/services/message-listener-store.d.ts.map +1 -0
  512. package/dist/services/message-listener-store.js +138 -0
  513. package/dist/services/message-listener-store.js.map +1 -0
  514. package/dist/services/message-listener.d.ts +112 -0
  515. package/dist/services/message-listener.d.ts.map +1 -0
  516. package/dist/services/message-listener.js +391 -0
  517. package/dist/services/message-listener.js.map +1 -0
  518. package/dist/services/overload-alert-migration.d.ts +15 -0
  519. package/dist/services/overload-alert-migration.d.ts.map +1 -0
  520. package/dist/services/overload-alert-migration.js +115 -0
  521. package/dist/services/overload-alert-migration.js.map +1 -0
  522. package/dist/services/send-policy.d.ts +38 -0
  523. package/dist/services/send-policy.d.ts.map +1 -1
  524. package/dist/services/send-policy.js +34 -0
  525. package/dist/services/send-policy.js.map +1 -1
  526. package/dist/services/session-store.d.ts +12 -1
  527. package/dist/services/session-store.d.ts.map +1 -1
  528. package/dist/services/session-store.js +44 -2
  529. package/dist/services/session-store.js.map +1 -1
  530. package/dist/services/skill-registry-store.d.ts.map +1 -1
  531. package/dist/services/skill-registry-store.js +87 -12
  532. package/dist/services/skill-registry-store.js.map +1 -1
  533. package/dist/services/substitute-mode-normalize.d.ts +3 -0
  534. package/dist/services/substitute-mode-normalize.d.ts.map +1 -1
  535. package/dist/services/substitute-mode-normalize.js +8 -0
  536. package/dist/services/substitute-mode-normalize.js.map +1 -1
  537. package/dist/services/substitute-mode-store.d.ts.map +1 -1
  538. package/dist/services/substitute-mode-store.js +8 -1
  539. package/dist/services/substitute-mode-store.js.map +1 -1
  540. package/dist/services/transcript-resolver.d.ts +6 -1
  541. package/dist/services/transcript-resolver.d.ts.map +1 -1
  542. package/dist/services/transcript-resolver.js +145 -29
  543. package/dist/services/transcript-resolver.js.map +1 -1
  544. package/dist/services/trigger-types.d.ts +16 -0
  545. package/dist/services/trigger-types.d.ts.map +1 -1
  546. package/dist/services/trigger-types.js +6 -0
  547. package/dist/services/trigger-types.js.map +1 -1
  548. package/dist/setup/bot-config-editor.js +2 -2
  549. package/dist/setup/bot-config-editor.js.map +1 -1
  550. package/dist/setup/ensure-zmx.d.ts +31 -0
  551. package/dist/setup/ensure-zmx.d.ts.map +1 -0
  552. package/dist/setup/ensure-zmx.js +161 -0
  553. package/dist/setup/ensure-zmx.js.map +1 -0
  554. package/dist/setup/index.d.ts +1 -1
  555. package/dist/setup/index.js +1 -1
  556. package/dist/setup/open-platform-automation.d.ts +9 -0
  557. package/dist/setup/open-platform-automation.d.ts.map +1 -1
  558. package/dist/setup/open-platform-automation.js +15 -2
  559. package/dist/setup/open-platform-automation.js.map +1 -1
  560. package/dist/setup/setup-args.d.ts +1 -1
  561. package/dist/setup/setup-args.d.ts.map +1 -1
  562. package/dist/setup/setup-args.js +1 -1
  563. package/dist/skills/definitions.d.ts.map +1 -1
  564. package/dist/skills/definitions.js +32 -0
  565. package/dist/skills/definitions.js.map +1 -1
  566. package/dist/skills/injection-mode.d.ts +6 -2
  567. package/dist/skills/injection-mode.d.ts.map +1 -1
  568. package/dist/skills/injection-mode.js +10 -5
  569. package/dist/skills/injection-mode.js.map +1 -1
  570. package/dist/types.d.ts +79 -3
  571. package/dist/types.d.ts.map +1 -1
  572. package/dist/utils/child-env.d.ts +1 -1
  573. package/dist/utils/child-env.d.ts.map +1 -1
  574. package/dist/utils/child-env.js +4 -0
  575. package/dist/utils/child-env.js.map +1 -1
  576. package/dist/utils/effort-confirm-dialog.d.ts +40 -0
  577. package/dist/utils/effort-confirm-dialog.d.ts.map +1 -0
  578. package/dist/utils/effort-confirm-dialog.js +74 -0
  579. package/dist/utils/effort-confirm-dialog.js.map +1 -0
  580. package/dist/utils/pending-input-queue.d.ts +56 -0
  581. package/dist/utils/pending-input-queue.d.ts.map +1 -1
  582. package/dist/utils/pending-input-queue.js +80 -0
  583. package/dist/utils/pending-input-queue.js.map +1 -1
  584. package/dist/utils/render-dimensions.d.ts +8 -0
  585. package/dist/utils/render-dimensions.d.ts.map +1 -1
  586. package/dist/utils/render-dimensions.js +10 -0
  587. package/dist/utils/render-dimensions.js.map +1 -1
  588. package/dist/utils/stuck-key-guard.d.ts +3 -2
  589. package/dist/utils/stuck-key-guard.d.ts.map +1 -1
  590. package/dist/utils/stuck-key-guard.js +3 -3
  591. package/dist/utils/stuck-key-guard.js.map +1 -1
  592. package/dist/utils/terminal-renderer.d.ts +6 -0
  593. package/dist/utils/terminal-renderer.d.ts.map +1 -1
  594. package/dist/utils/terminal-renderer.js +15 -0
  595. package/dist/utils/terminal-renderer.js.map +1 -1
  596. package/dist/utils/tui-input-delivery.d.ts +32 -0
  597. package/dist/utils/tui-input-delivery.d.ts.map +1 -0
  598. package/dist/utils/tui-input-delivery.js +53 -0
  599. package/dist/utils/tui-input-delivery.js.map +1 -0
  600. package/dist/utils/xml.d.ts +19 -0
  601. package/dist/utils/xml.d.ts.map +1 -0
  602. package/dist/utils/xml.js +26 -0
  603. package/dist/utils/xml.js.map +1 -0
  604. package/dist/worker.js +1852 -374
  605. package/dist/worker.js.map +1 -1
  606. package/dist/workflows/definition.d.ts +8 -8
  607. package/dist/workflows/events/payloads.d.ts +8 -8
  608. package/dist/workflows/events/schema.d.ts +160 -160
  609. package/dist/workflows/v3/session-relay-client.js +1 -1
  610. package/dist/workflows/v3/session-relay-client.js.map +1 -1
  611. package/dist/workflows/v3/worker-fence.d.ts.map +1 -1
  612. package/dist/workflows/v3/worker-fence.js +15 -10
  613. package/dist/workflows/v3/worker-fence.js.map +1 -1
  614. package/package.json +1 -1
  615. package/dist/dashboard-web/chunks/bot-defaults-page-UKA7K4JV.js +0 -10
  616. package/dist/dashboard-web/chunks/chunk-DFLNXQNT.js +0 -1
  617. package/dist/dashboard-web/chunks/connectors-page-A77YAB5Y.js +0 -1
  618. package/dist/dashboard-web/chunks/groups-page-RUZNVXQB.js +0 -8
  619. package/dist/dashboard-web/chunks/insights-page-RF7U7RTA.js +0 -22
  620. package/dist/dashboard-web/chunks/roles-page-BUMKD7Y4.js +0 -1
  621. package/dist/dashboard-web/chunks/sessions-page-6HLSEAB7.js +0 -2
  622. package/dist/dashboard-web/chunks/settings-page-MJDZHQ4X.js +0 -2
@@ -1,4 +1,4 @@
1
- import{c as K}from"./chunk-FLGXZJTD.js";import{b as Ce,c as je,d as te,h as _e,k as de}from"./chunk-QFMH6ITB.js";import{y as we}from"./chunk-KQB42ML5.js";import{a as He}from"./chunk-SYC6D5XU.js";import{a as bl,b as pl,d as Oe}from"./chunk-5THX4DI2.js";import{c as ce}from"./chunk-7SZRL6FY.js";var i=ce(bl(),1),qe=ce(pl(),1);var e=ce(Oe(),1),hl=2;function Sl(l,s){let o=String(l??"").replace(/\\/g,"/");return o.includes("/.codex/skills/")?s("skills.sourceCodex"):o.includes("/.claude/skills/")?s("skills.sourceClaude"):o.includes("/.trae/skills/")?s("skills.sourceTrae"):o.includes("/.cursor/skills/")?s("skills.sourceCursor"):o.includes("/.gemini/skills/")?s("skills.sourceGemini"):o.includes("/.config/opencode/skills/")?s("skills.sourceOpenCode"):null}function ze(l,s){let o=l.source??{};return o.type==="github"?`github:${o.owner}/${o.repo}/${o.path??""}`:o.type==="git"?`${o.url??"git"}#${o.path??""}`:o.type==="local-link"?Sl(o.path,s)??s("skills.sourceLocalLink"):o.type==="local-copy"?s("skills.sourceBotmuxCopy"):String(o.type??"unknown")}function ke(l){return(l?.include??[]).filter(s=>s.startsWith("skill:")).map(s=>s.slice(6))}function Nl(l){return ke(l).length}function wl(l){return ke(l).length>0}function ue(l){return`${l.cliId}
1
+ import{c as K}from"./chunk-VA6QWSGQ.js";import{b as Ce,c as je,d as te,h as _e,l as de}from"./chunk-5CJMHTT4.js";import{y as we}from"./chunk-DLZK52JU.js";import{a as He}from"./chunk-SYC6D5XU.js";import{a as bl,b as pl,d as Oe}from"./chunk-5THX4DI2.js";import{c as ce}from"./chunk-7SZRL6FY.js";var i=ce(bl(),1),qe=ce(pl(),1);var e=ce(Oe(),1),hl=2;function Sl(l,s){let o=String(l??"").replace(/\\/g,"/");return o.includes("/.codex/skills/")?s("skills.sourceCodex"):o.includes("/.claude/skills/")?s("skills.sourceClaude"):o.includes("/.trae/skills/")?s("skills.sourceTrae"):o.includes("/.cursor/skills/")?s("skills.sourceCursor"):o.includes("/.gemini/skills/")?s("skills.sourceGemini"):o.includes("/.config/opencode/skills/")?s("skills.sourceOpenCode"):null}function ze(l,s){let o=l.source??{};return o.type==="github"?`github:${o.owner}/${o.repo}/${o.path??""}`:o.type==="git"?`${o.url??"git"}#${o.path??""}`:o.type==="local-link"?Sl(o.path,s)??s("skills.sourceLocalLink"):o.type==="local-copy"?s("skills.sourceBotmuxCopy"):String(o.type??"unknown")}function ke(l){return(l?.include??[]).filter(s=>s.startsWith("skill:")).map(s=>s.slice(6))}function Nl(l){return ke(l).length}function wl(l){return ke(l).length>0}function ue(l){return`${l.cliId}
2
2
  ${l.rootDir}`}function Cl(l){return l>=1600?4:l<=620?1:l<=980?2:3}async function O(l,s){let o=await fetch(l,{...s,headers:{"content-type":"application/json",...s.headers??{}}}),k=await o.json().catch(()=>({}));if(!o.ok||k.ok===!1){let f=new Error(k?.error??`HTTP ${o.status}`);throw f.status=o.status,f.body=k,f}return k}function Re(l){return`oncall-status${l?` ${l.ok?"hint-ok":"hint-warn-inline"}`:""}`}function Ge(l){let s=l.options.find(o=>o.value===l.value);return(0,e.jsxs)("div",{className:"skills-segmented-control",children:[(0,e.jsx)("div",{className:"segmented skills-segmented",role:"group",children:l.options.map(o=>(0,e.jsx)("button",{type:"button",className:l.value===o.value?"active":"","aria-pressed":l.value===o.value?"true":"false",title:typeof o.help=="string"?o.help:void 0,disabled:l.disabled,onClick:()=>l.onChange(o.value),children:o.label},o.value))}),s?.help?(0,e.jsx)("span",{className:"skills-setting-hint",children:s.help}):null]})}function Rl(l){let s=K(),o=(0,i.useRef)(null),k=l.installCandidates??[],f=l.selectedInstallSkills??new Set,b=k.length>0&&k.every(r=>f.has(r.name)),y=l.installBusy||l.installDiscovering;return(0,i.useEffect)(()=>{let r=o.current;if(r)if(l.installSelectionOpen&&!r.open)try{r.showModal()}catch{}else!l.installSelectionOpen&&r.open&&r.close()},[l.installSelectionOpen,k.length]),(0,e.jsxs)("article",{className:"bd-card skills-install-panel",children:[l.showTitle===!1?null:(0,e.jsx)("div",{className:"skills-install-title",children:(0,e.jsx)("h3",{className:"bd-section-title",children:(0,e.jsx)(de,{help:s("skills.installInfo"),helpLabel:s("skills.installInfoLabel"),children:s("skills.install")})})}),(0,e.jsxs)("div",{className:"skills-install-grid",children:[(0,e.jsxs)("label",{className:"skills-source-label",children:[(0,e.jsx)(de,{help:(0,e.jsxs)("span",{className:"skills-source-help",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:s("skills.sourceHelpRemoteLabel")}),s("skills.sourceHelpRemote")]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:s("skills.sourceHelpLocalLabel")}),s("skills.sourceHelpLocal")]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:s("skills.sourceHelpAgentbuddyLabel")}),s("skills.sourceHelpAgentbuddy")]})]}),helpLabel:s("skills.source"),children:s("skills.source")}),(0,e.jsx)("div",{className:"skills-source-control",children:(0,e.jsx)("input",{type:"text","data-install":"source","aria-label":s("skills.source"),placeholder:s("skills.sourcePlaceholder"),value:l.installSource,onChange:r=>l.onInstallSourceChange(r.currentTarget.value)})})]}),(0,e.jsxs)("label",{className:"skills-install-field-wide skills-install-path-field",children:[(0,e.jsx)("span",{children:s("skills.path")}),(0,e.jsx)("input",{type:"text","data-install":"path",placeholder:s("skills.pathPlaceholder"),value:l.installPath,onChange:r=>l.onInstallPathChange(r.currentTarget.value)})]}),(0,e.jsxs)("label",{className:"skills-install-field-wide skills-install-ref-field",children:[(0,e.jsx)("span",{children:s("skills.ref")}),(0,e.jsx)("input",{type:"text","data-install":"ref",placeholder:s("skills.refPlaceholder"),value:l.installRef,onChange:r=>l.onInstallRefChange(r.currentTarget.value)})]}),(0,e.jsx)("div",{className:"skills-install-actions",children:(0,e.jsx)("button",{type:"button","data-action":"install",disabled:y,onClick:()=>l.onInstall(),children:l.installDiscovering?s("skills.scanning"):l.installBusy?s("skills.jobRunning"):s("skills.installSubmit")})}),(0,e.jsx)("div",{className:"skills-install-bottom-row",children:(0,e.jsxs)("div",{className:"skills-local-discovery-panel",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("strong",{children:s("skills.localDiscoverTitle")}),(0,e.jsx)("span",{children:s("skills.localDiscoverHelp")})]}),(0,e.jsx)("button",{type:"button","data-action":"open-native-skill-discovery",onClick:()=>l.onOpenNativeDiscovery(),children:s("skills.localDiscover")})]})})]}),l.installStatus?(0,e.jsx)("div",{className:"actions skills-install-status-row",children:(0,e.jsx)("span",{className:Re(l.installStatus),"data-skills-status":!0,children:l.installStatus.text})}):null,(0,e.jsx)("dialog",{className:"skills-discovery-dialog skills-install-selection-dialog","data-install-selection-dialog":!0,ref:o,onClose:()=>l.onCloseInstallSelection?.(),children:(0,e.jsxs)("article",{children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:s("skills.installSelectionTitle")}),(0,e.jsx)("p",{children:s("skills.installSelectionHelp",{count:k.length})})]}),(0,e.jsx)("div",{className:"skills-discovery-body skills-install-selection-body",children:(0,e.jsxs)("div",{className:"skills-candidate-list","data-install-candidates":!0,children:[(0,e.jsxs)("div",{className:"skills-candidate-list-head",children:[(0,e.jsx)("span",{children:s("skills.scanFound",{count:k.length})}),l.onSelectAllInstallSkills?(0,e.jsx)("button",{type:"button","data-action":"toggle-all-source-skills",disabled:l.installBusy,onClick:()=>l.onSelectAllInstallSkills?.(!b),children:s(b?"skills.discoverClearSelection":"skills.discoverSelectAll")}):null]}),k.map(r=>(0,e.jsxs)("label",{className:"skills-candidate-row",children:[(0,e.jsx)("input",{type:"checkbox",checked:f.has(r.name),disabled:l.installBusy,onChange:()=>l.onToggleInstallSkill?.(r.name)}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:r.name}),(0,e.jsxs)("small",{children:[r.path,r.description?` \xB7 ${r.description}`:""]})]})]},`${r.name}:${r.path}`))]})}),(0,e.jsxs)("footer",{className:"actions",children:[(0,e.jsx)("button",{type:"button","data-action":"close-install-selection",disabled:l.installBusy,onClick:()=>l.onCloseInstallSelection?.(),children:s("skills.installSelectionCancel")}),(0,e.jsx)("button",{type:"button",className:"primary","data-action":"confirm-install-selection",disabled:l.installBusy||f.size===0,onClick:()=>l.onConfirmInstallSelection?.(),children:l.installBusy?s("skills.jobRunning"):s("skills.installSelected")})]})]})})]})}function Il(l){let s=K(),o=(0,i.useRef)(null),k=(0,i.useRef)(new Set(l.skills.map(a=>a.name))),f=(0,i.useRef)(""),b=(0,i.useRef)(!1),y=(0,i.useRef)(null),[r,p]=(0,i.useState)(""),[w,R]=(0,i.useState)(!1),[I,D]=(0,i.useState)(()=>new Set),[x,A]=(0,i.useState)(0),[M,j]=(0,i.useState)(()=>typeof window>"u"?1200:window.innerWidth),L=r.trim().toLocaleLowerCase();f.current=r,b.current=w;let h=(0,i.useMemo)(()=>L?l.skills.filter(a=>[a.name,a.displayName,a.description,...a.tags??[],ze(a,s)].filter(Boolean).join(`
3
- `).toLocaleLowerCase().includes(L)):l.skills,[L,l.skills,s]),B=Cl(M)*hl,T=Math.max(1,Math.ceil(h.length/B)),F=h.slice(x*B,x*B+B),q=(0,i.useMemo)(()=>new Set(h.map(a=>a.name)),[h]),_=h.filter(a=>I.has(a.name)).length,z=Math.max(0,I.size-_),c=h.length>0&&_===h.length;(0,i.useEffect)(()=>{if(typeof window>"u")return;let a=()=>j(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),(0,i.useEffect)(()=>A(0),[L,B]),(0,i.useEffect)(()=>{A(a=>Math.min(Math.max(0,a),T-1))},[T]),(0,i.useEffect)(()=>{let a=new Set(l.skills.map(u=>u.name)),C=[...k.current].some(u=>!a.has(u));D(u=>{let P=new Set([...u].filter(H=>a.has(H)));return P.size===u.size?u:P}),C&&(R(!1),D(new Set)),k.current=a},[l.skills]),(0,i.useEffect)(()=>{o.current&&(o.current.indeterminate=_>0&&!c)},[c,_]),(0,i.useEffect)(()=>{if(typeof document>"u")return;let a=u=>{if(u.key!=="Escape"||!b.current)return;let P=f.current;y.current=P,u.preventDefault(),u.stopPropagation(),R(!1),D(new Set),window.setTimeout(()=>{p(H=>H||P),y.current=null},50)},C=u=>{if(u.key!=="Escape"||y.current===null)return;let P=y.current;y.current=null,u.preventDefault(),u.stopPropagation(),p(P)};return document.addEventListener("keydown",a,!0),document.addEventListener("keyup",C,!0),()=>{document.removeEventListener("keydown",a,!0),document.removeEventListener("keyup",C,!0)}},[]);function g(a){D(C=>{let u=new Set(C);return u.has(a)?u.delete(a):u.add(a),u})}function S(){D(a=>{let C=new Set(a);if(c)for(let u of q)C.delete(u);else for(let u of q)C.add(u);return C})}function $(a=!1){let C=r;R(!1),D(new Set),a&&typeof window<"u"&&window.setTimeout(()=>p(C),0)}return(0,e.jsxs)("section",{className:"skills-installed-block",children:[(0,e.jsx)(te,{title:s("skills.installed"),count:s("skills.installedCount",{count:l.skills.length}),hint:s("skills.installedHelp"),children:(0,e.jsx)("div",{className:"skills-installed-header-actions",children:w?(0,e.jsx)("button",{type:"button","data-action":"cancel-installed-selection",onClick:()=>$(),children:s("skills.cancel")}):(0,e.jsx)("button",{type:"button","data-action":"select-installed-skills",disabled:l.skills.length===0,onClick:()=>R(!0),children:s("skills.select")})})}),(0,e.jsxs)("section",{className:"bd-card skills-installed-panel",children:[(0,e.jsxs)("div",{className:"skills-library-toolbar",children:[(0,e.jsxs)("label",{className:"skills-installed-search",children:[(0,e.jsx)("span",{className:"sr-only",children:s("skills.searchLabel")}),(0,e.jsx)("input",{type:"text",role:"searchbox",inputMode:"search","data-action":"search-installed-skills",placeholder:s("skills.searchPlaceholder"),value:r,onChange:a=>p(a.currentTarget.value),onKeyDown:a=>{a.key!=="Escape"||!w||(a.preventDefault(),a.stopPropagation(),$(!0))}}),r?(0,e.jsx)("button",{type:"button","data-action":"clear-installed-search","aria-label":s("skills.clearSearch"),onClick:()=>p(""),children:"\xD7"}):null]}),w?(0,e.jsxs)("label",{className:"skills-select-all-results",children:[(0,e.jsx)("input",{ref:o,type:"checkbox",checked:c,disabled:h.length===0||l.removingNames.size>0,onChange:S}),(0,e.jsx)("span",{children:L?s("skills.selectSearchResults",{count:h.length}):s("skills.selectAllSkills",{count:h.length})})]}):null,L?(0,e.jsx)("span",{className:"skills-filter-count",children:s("skills.resultCount",{count:h.length})}):null,T>1?(0,e.jsxs)("div",{className:"skills-pager",children:[(0,e.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"-1","aria-label":s("skills.prevPage"),title:s("skills.prevPage"),disabled:x===0,onClick:()=>A(a=>Math.max(0,a-1)),children:"\u2039"}),(0,e.jsx)("span",{children:s("skills.pageStatus",{page:x+1,pages:T})}),(0,e.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"1","aria-label":s("skills.nextPage"),title:s("skills.nextPage"),disabled:x>=T-1,onClick:()=>A(a=>Math.min(T-1,a+1)),children:"\u203A"})]}):null]}),(0,e.jsx)("div",{className:"skills-installed-live",role:"status","aria-live":"polite",children:l.status?(0,e.jsx)("span",{className:Re(l.status),children:l.status.text}):null}),l.skills.length===0?(0,e.jsxs)("div",{className:"skills-library-empty",children:[(0,e.jsx)("strong",{children:s("skills.emptyTitle")}),(0,e.jsx)("p",{children:s("skills.emptyHelp")})]}):h.length===0?(0,e.jsxs)("div",{className:"skills-library-empty","data-empty":"search",children:[(0,e.jsx)("strong",{children:s("skills.noResultsTitle",{query:r.trim()})}),(0,e.jsx)("p",{children:s("skills.noResultsHelp")}),(0,e.jsx)("button",{type:"button","data-action":"clear-installed-search-empty",onClick:()=>p(""),children:s("skills.clearSearch")})]}):(0,e.jsx)("div",{className:"skills-list",children:F.map(a=>{let C=I.has(a.name),u=l.removingNames.has(a.name);return(0,e.jsxs)("article",{className:`skills-row skills-installed-card${w?" is-selectable":""}${C?" is-selected":""}${u?" is-removing":""}`,"data-skill":a.name,"data-selection-mode":w?"true":void 0,"aria-busy":u||void 0,onClick:w?()=>g(a.name):void 0,children:[(0,e.jsxs)("div",{className:"skills-row-body",children:[(0,e.jsxs)("div",{className:"skills-row-title",children:[w?(0,e.jsx)("input",{type:"checkbox","aria-label":s("skills.selectNamed",{skill:a.displayName??a.name}),checked:C,disabled:u,onClick:P=>P.stopPropagation(),onChange:()=>g(a.name)}):null,(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:a.displayName??a.name}),a.displayName&&a.displayName!==a.name?(0,e.jsx)("small",{className:"skills-canonical-name",children:a.name}):null]})]}),a.description?(0,e.jsx)("p",{children:a.description}):null,(0,e.jsx)("small",{className:"skills-source-badge",children:ze(a,s)}),u?(0,e.jsx)("span",{className:"skills-removing-label",children:s("skills.removing")}):null]}),w?null:(0,e.jsxs)("div",{className:"skills-card-actions",children:[(0,e.jsx)("button",{type:"button","data-action":"update-skill",disabled:l.busySkill===`${a.name}:update`||u,onClick:()=>l.onUpdate(a.name),children:s("skills.update")}),(0,e.jsx)("button",{type:"button","data-action":"remove-skill",disabled:u,onClick:()=>l.onRequestRemove([a.name]),children:s("skills.remove")})]})]},a.name)})})]}),w?(0,e.jsxs)("div",{className:"skills-bulk-action-bar",role:"toolbar","aria-label":s("skills.bulkActions"),children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:s("skills.selectedCount",{count:I.size})}),z>0?(0,e.jsx)("small",{children:s("skills.selectedHidden",{count:z})}):null]}),(0,e.jsx)("button",{type:"button",className:"danger","data-action":"remove-selected-skills",disabled:I.size===0||l.removingNames.size>0,onClick:()=>l.onRequestRemove([...I]),children:s("skills.removeSelected",{count:I.size})})]}):null]})}function Pl(l){let s=K(),o=(0,i.useRef)(null),k=l.names??[],f=l.references.length>0,b=k.slice(0,3),y=new Set(l.references.flatMap(r=>r.bots)).size;return(0,i.useEffect)(()=>{let r=o.current;if(r)if(l.names&&!r.open)try{r.showModal()}catch{}else!l.names&&r.open&&r.close()},[l.names]),(0,e.jsx)("dialog",{className:"skills-remove-dialog","data-remove-skills-dialog":!0,ref:o,onCancel:r=>{r.preventDefault(),l.busy||l.onCancel()},onClick:r=>{r.target===r.currentTarget&&!l.busy&&l.onCancel()},children:(0,e.jsxs)("article",{children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:f?k.length===1?s("skills.removeInUseOneTitle",{skill:k[0]}):s("skills.removeInUseManyTitle",{count:k.length}):k.length===1?s("skills.removeOneTitle",{skill:k[0]}):s("skills.removeManyTitle",{count:k.length})}),(0,e.jsx)("p",{children:f?k.length===1?s("skills.removeInUseOneHelp",{count:y}):s("skills.removeInUseManyHelp",{count:y}):k.length===1?s("skills.removeOnePermanentHelp"):s("skills.removePermanentHelp")})]}),(0,e.jsxs)("div",{className:"skills-remove-dialog-body",children:[k.length>1?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("ul",{children:b.map(r=>(0,e.jsx)("li",{children:r},r))}),k.length>b.length?(0,e.jsx)("p",{children:s("skills.removeMore",{count:k.length-b.length})}):null]}):null,l.references.length>0?(0,e.jsxs)("div",{className:"skills-remove-reference-warning",role:"alert",children:[(0,e.jsx)("strong",{children:s("skills.removeReferencesDetail")}),(0,e.jsx)("ul",{children:l.references.map(r=>(0,e.jsxs)("li",{children:[(0,e.jsx)("strong",{children:r.name}),(0,e.jsx)("span",{children:r.bots.join(", ")})]},r.name))})]}):null,l.error?(0,e.jsx)("p",{className:"hint-warn",role:"alert",children:l.error}):null]}),(0,e.jsxs)("footer",{className:"actions",children:[(0,e.jsx)("button",{type:"button",autoFocus:!0,disabled:l.busy,onClick:l.onCancel,children:s("skills.cancel")}),(0,e.jsx)("button",{type:"button",className:"danger",disabled:l.busy,onClick:()=>l.onConfirm(f),children:l.busy?s("skills.removing"):f?s("skills.removeAnyway"):k.length===1?s("skills.removeOneConfirm"):s("skills.removeSelected",{count:k.length})})]})]})})}function Tl(){let l=K(),s=(0,i.useRef)(!0),o=(0,i.useRef)(new Set),k=(0,i.useRef)(null),[f,b]=(0,i.useState)([]),[y,r]=(0,i.useState)([]),[p,w]=(0,i.useState)([]),[R,I]=(0,i.useState)("off"),[D,x]=(0,i.useState)("auto"),[A,M]=(0,i.useState)(null),[j,L]=(0,i.useState)(!0),[h,B]=(0,i.useState)(""),[T,F]=(0,i.useState)(""),[q,_]=(0,i.useState)(""),[z,c]=(0,i.useState)(null),[g,S]=(0,i.useState)(!1),[$,a]=(0,i.useState)(!1),[C,u]=(0,i.useState)(!1),[P,H]=(0,i.useState)([]),[Q,U]=(0,i.useState)(()=>new Set),[W,X]=(0,i.useState)(!1),[Je,Ie]=(0,i.useState)(!1),[me,Ke]=(0,i.useState)(null),[ge,fe]=(0,i.useState)(()=>new Set),[Pe,ne]=(0,i.useState)(null),[Ue,Te]=(0,i.useState)(null),[We,De]=(0,i.useState)(null),[Fe,ve]=(0,i.useState)({}),[ye,V]=(0,i.useState)(null),[xe,be]=(0,i.useState)(null),[Qe,Y]=(0,i.useState)(!1),[Xe,ie]=(0,i.useState)([]),[Ve,ae]=(0,i.useState)(null),[Z,Ae]=(0,i.useState)(()=>new Set),ee=(0,i.useMemo)(()=>new Set(f.map(t=>t.name)),[f]),J=(0,i.useMemo)(()=>y.length===0?void 0:(me?y.find(n=>ue(n)===me):void 0)??y.find(n=>n.skills.length>0)??y[0],[me,y]),pe=J?ue(J):"",le=(0,i.useMemo)(()=>J?J.skills.filter(t=>!ee.has(t.name)).map(t=>t.rootDir??t.source?.root??"").filter(Boolean):[],[J,ee]),Me=le.length>0&&le.every(t=>ge.has(t)),Le=(0,i.useCallback)(()=>{for(let t of o.current)window.clearTimeout(t);o.current.clear()},[]),Ye=(0,i.useCallback)(t=>new Promise(n=>{let d=window.setTimeout(()=>{o.current.delete(d),n()},t);o.current.add(d)}),[]),Ee=(0,i.useCallback)(async()=>{let[t,n]=await Promise.all([fetch("/api/skills"),fetch("/api/bots")]),d=await t.json().catch(()=>({})),m=await n.json().catch(()=>({}));if(!t.ok){let v=d?.error??`skills HTTP ${t.status}`;throw new Error(v==="not_found_yet"||v==="not_found"?l("skills.apiUnavailable"):v)}if(!n.ok)throw new Error(m?.error??`bots HTTP ${n.status}`);return{skills:Array.isArray(d.skills)?d.skills:[],nativeSkillGroups:Array.isArray(d.nativeSkillGroups)?d.nativeSkillGroups:[],bots:Array.isArray(m.bots)?m.bots:[],trustProjectSkills:d.trustProjectSkills==="all"?"all":"off",delivery:d.delivery==="prompt"||d.delivery==="native"?d.delivery:"auto"}},[l]),se=(0,i.useCallback)(async()=>{L(!0);try{let t=await Ee();if(!s.current)return;b(t.skills),r(t.nativeSkillGroups),w(t.bots),I(t.trustProjectSkills),x(t.delivery),M(null),fe(n=>{let d=new Set,m=new Set(t.skills.map(v=>v.name));for(let v of t.nativeSkillGroups)for(let N of v.skills){let E=N.rootDir??N.source?.root??"";E&&!m.has(N.name)&&n.has(E)&&d.add(E)}return d})}catch(t){if(!s.current)return;M(t?.message??String(t))}finally{s.current&&L(!1)}},[Ee]);(0,i.useEffect)(()=>(s.current=!0,se(),()=>{s.current=!1,Le()}),[Le,se]),(0,i.useEffect)(()=>{if(!ye||Z.size>0)return;let t=window.setTimeout(()=>{s.current&&V(null)},6e3);return()=>window.clearTimeout(t)},[ye,Z]),(0,i.useEffect)(()=>{let t=k.current;if(t)if(W&&!t.open)try{t.showModal()}catch{}else!W&&t.open&&t.close()},[W,pe]);async function Be(t,n,d=!0){let m=t;for(n({text:l("skills.jobRunning"),ok:!0});;){if(!s.current)return;if(m.status==="succeeded"){n({text:l("skills.saved"),ok:!0}),d&&await se();return}if(m.status==="failed")throw new Error(m.error??"job_failed");if(await Ye(800),!s.current)return;let v=await O(`/api/skills/jobs/${encodeURIComponent(m.id)}`,{method:"GET"});if(!s.current)return;m=v.job}}function Ze(t){return p.filter(n=>ke(n.skills).includes(t)).map(n=>n.botName??n.larkAppId)}function oe(){H([]),U(new Set),u(!1)}function $e(){return{source:h.trim(),path:T.trim()||void 0,ref:q.trim()||void 0}}function el(t){let n=t??[...Q];return{...$e(),skillNames:n.length>0?n:void 0}}async function ll(){a(!0),c({text:l("skills.scanning"),ok:!0});try{let t=await O("/api/skills/discover",{method:"POST",body:JSON.stringify($e())});if(!s.current)return{skills:[],directInstall:!1};let n=t.discovery?.directInstall===!0,d=Array.isArray(t.discovery?.skills)?t.discovery.skills:[];return H(d),U(new Set(d.map(m=>m.name))),{skills:d,directInstall:n}}finally{s.current&&a(!1)}}function G(t){let n=t||"";return n.startsWith("skill_git_command_failed")&&/authentication failed|could not read username|repository not found|unauthor|\b401\b|\b403\b/i.test(n)?l("skills.gitNeedsAuth"):n.startsWith("agentbuddy_not_found")?l("skills.agentbuddyNotFound"):n.startsWith("agentbuddy_command_failed")?/login|credential|unauthor|not logged|401|403/i.test(n)?l("skills.agentbuddyNeedsLogin"):l("skills.agentbuddyCommandFailed"):n.startsWith("agentbuddy_clear_telemetry_failed")||n.startsWith("agentbuddy_telemetry_not_stripped")?l("skills.agentbuddyTelemetryFailed"):n.startsWith("agentbuddy_no_skill_produced")?l("skills.agentbuddyNoSkill"):n.startsWith("invalid_agentbuddy")?l("skills.agentbuddyInvalid"):n}async function he(t){S(!0);try{let n=await O("/api/skills/install",{method:"POST",body:JSON.stringify(el(t))});if(!s.current)return;await Be(n.job,c),s.current&&oe()}catch(n){s.current&&c({text:`${l("skills.failed")}: ${G(n?.message??String(n))}`,ok:!1})}finally{s.current&&S(!1)}}function sl(t){U(n=>{let d=new Set(n);return d.has(t)?d.delete(t):d.add(t),d})}function tl(t){U(t?new Set(P.map(n=>n.name)):new Set)}async function nl(){if(!h.trim()){c({text:l("skills.sourceRequired"),ok:!1});return}try{u(!1);let{skills:t,directInstall:n}=await ll();if(!s.current)return;if(n){await he();return}if(t.length===0){c({text:l("skills.scanEmpty"),ok:!1});return}if(t.length===1){await he([t[0].name]);return}c({text:l("skills.scanFound",{count:t.length}),ok:!0}),u(!0)}catch(t){s.current&&c({text:`${l("skills.failed")}: ${G(t?.message??String(t))}`,ok:!1})}}async function il(){let t=[...Q];if(t.length===0){c({text:l("skills.discoverNothingSelected"),ok:!1});return}await he(t)}async function al(){let t=[...ge].filter(Boolean);if(t.length===0){c({text:l("skills.discoverNothingSelected"),ok:!1});return}Ie(!0);try{if(c({text:l("skills.discoverRegisteringBatch",{total:t.length}),ok:!0}),await O("/api/skills/install-local-links",{method:"POST",body:JSON.stringify({sources:t})}),!s.current)return;X(!1),await se(),s.current&&c({text:l("skills.saved"),ok:!0})}catch(n){s.current&&c({text:`${l("skills.failed")}: ${G(n?.message??String(n))}`,ok:!1})}finally{s.current&&Ie(!1)}}async function ol(t){if(R!==t){ne("project");try{let n=await O("/api/skills/global",{method:"PUT",body:JSON.stringify({trustProjectSkills:t})});if(!s.current)return;I(n.trustProjectSkills==="all"?"all":t)}catch(n){s.current&&window.alert(`${l("skills.failed")}: ${G(n?.message??String(n))}`)}finally{s.current&&ne(null)}}}async function rl(t){if(D!==t){ne("delivery");try{let n=await O("/api/skills/global",{method:"PUT",body:JSON.stringify({delivery:t})});if(!s.current)return;x(n.delivery==="prompt"||n.delivery==="native"?n.delivery:t)}catch(n){s.current&&window.alert(`${l("skills.failed")}: ${G(n?.message??String(n))}`)}finally{s.current&&ne(null)}}}async function cl(t){Te(`${t}:update`);try{let n=await O(`/api/skills/${encodeURIComponent(t)}/update`,{method:"POST",body:"{}"});if(!s.current)return;await Be(n.job,c)}catch(n){s.current&&window.alert(`${l("skills.failed")}: ${G(n?.message??String(n))}`)}finally{s.current&&Te(null)}}function dl(t){let n=[...new Set(t.filter(d=>ee.has(d)))];n.length!==0&&(be(n),Y(!0),ie([]),ae(null))}function ul(){Z.size>0||(Y(!1),be(null),ie([]),ae(null))}async function kl(t){let n=xe??[];if(n.length!==0){Ae(new Set(n)),Y(!1),ae(null),V({text:l("skills.removingCount",{count:n.length}),ok:!0});try{let d=await O("/api/skills",{method:"DELETE",body:JSON.stringify({names:n,force:t})});if(!s.current)return;let m=Array.isArray(d.removed)?d.removed.filter(N=>typeof N=="string"):n,v=new Set(m);b(N=>N.filter(E=>!v.has(E.name))),V({text:m.length===1?l("skills.removedOne",{skill:m[0]}):l("skills.removedMany",{count:m.length}),ok:!0}),be(null),ie([])}catch(d){if(!s.current)return;if(d?.status===409&&d?.body?.error==="skills_in_use"){let v=Array.isArray(d.body.affectedSkills)?d.body.affectedSkills.map(N=>{let E=typeof N?.name=="string"?N.name:"",Se=Array.isArray(N?.affectedBots)?N.affectedBots.map(re=>re?.botName||re?.larkAppId||"").filter(Boolean):Ze(E);return E?{name:E,bots:Se}:null}).filter(N=>N!==null):[];ie(v),Y(!0),V(null);return}let m=l("skills.removeFailed",{detail:G(d?.message??String(d))});ae(m),Y(!0),V({text:m,ok:!1})}finally{s.current&&Ae(new Set)}}}async function ml(t,n){let d=`${t}:set`;De(d),ve(m=>({...m,[t]:null}));try{let m=await O(`/api/bots/${encodeURIComponent(t)}/skills`,{method:"PUT",body:JSON.stringify({action:"set",policy:n.length>0?{include:n.map(v=>`skill:${v}`)}:null})});if(!s.current)return;w(v=>v.map(N=>N.larkAppId===t?{...N,skills:m.skills??null}:N)),ve(v=>({...v,[t]:{text:l("skills.policySaved"),ok:!0}}))}catch(m){throw s.current&&ve(v=>({...v,[t]:{text:`${l("skills.failed")}: ${G(m?.message??String(m))}`,ok:!1}})),m}finally{s.current&&De(null)}}let gl=p.filter(t=>wl(t.skills)).length,fl=p.reduce((t,n)=>t+Nl(n.skills),0),vl=(0,e.jsxs)("div",{className:"page-heading-actions skills-heading-actions",children:[(0,e.jsxs)("div",{className:"skills-metric-strip",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("small",{children:l("skills.metricInstalled")}),(0,e.jsx)("strong",{children:f.length})]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("small",{children:l("skills.metricBots")}),(0,e.jsxs)("strong",{children:[gl,"/",p.length]})]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("small",{children:l("skills.metricAttached")}),(0,e.jsx)("strong",{children:fl})]})]}),(0,e.jsx)(_e,{id:"skills-refresh",label:l("skills.refresh"),busy:j,disabled:j,onClick:()=>{se()}})]}),yl=(0,e.jsx)("div",{className:"skills-page-stack",children:j?(0,e.jsx)(je,{label:l("common.loading")}):A?(0,e.jsx)("p",{className:"hint-warn",children:A}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"skills-config-row",children:[(0,e.jsxs)("section",{className:"skills-config-block",children:[(0,e.jsx)(te,{title:l("skills.globalDefaults")}),(0,e.jsxs)("article",{className:"bd-card skills-defaults-panel skills-config-card",children:[(0,e.jsxs)("div",{className:"skills-control-block",children:[(0,e.jsx)("span",{className:"skills-control-label",children:l("skills.globalProject")}),(0,e.jsx)(Ge,{value:R,disabled:Pe==="project",options:[{value:"off",label:l("skills.globalProjectOff"),help:l("skills.globalProjectOffHelp")},{value:"all",label:l("skills.globalProjectAll"),help:l("skills.globalProjectAllHelp")}],onChange:t=>{ol(t)}})]}),(0,e.jsxs)("div",{className:"skills-control-block",children:[(0,e.jsx)("span",{className:"skills-control-label",children:l("skills.globalDelivery")}),(0,e.jsx)(Ge,{value:D,disabled:Pe==="delivery",options:[{value:"auto",label:l("skills.deliveryAuto"),help:l("skills.deliveryAutoHelp")},{value:"prompt",label:l("skills.deliveryPrompt"),help:l("skills.deliveryPromptHelp")},{value:"native",label:l("skills.deliveryNative"),help:l("skills.deliveryNativeHelp")}],onChange:t=>{rl(t)}})]})]})]}),(0,e.jsxs)("section",{className:"skills-config-block",children:[(0,e.jsx)(te,{title:(0,e.jsx)(de,{help:l("skills.installInfo"),helpLabel:l("skills.installInfoLabel"),children:l("skills.install")})}),(0,e.jsx)(Rl,{showTitle:!1,installSource:h,installPath:T,installRef:q,installStatus:z,installBusy:g,installDiscovering:$,installSelectionOpen:C,installCandidates:P,selectedInstallSkills:Q,onInstallSourceChange:t=>{B(t),oe()},onInstallPathChange:t=>{F(t),oe()},onInstallRefChange:t=>{_(t),oe()},onToggleInstallSkill:sl,onSelectAllInstallSkills:tl,onConfirmInstallSelection:()=>{il()},onCloseInstallSelection:()=>u(!1),onInstall:()=>{nl()},onOpenNativeDiscovery:()=>X(!0)})]}),(0,e.jsxs)("section",{className:"skills-config-block",children:[(0,e.jsx)(te,{title:l("skills.bots"),count:l("skills.botCount",{count:p.length}),hint:l("skills.botsHelp")}),(0,e.jsx)("section",{className:"bd-card skills-bots-panel skills-config-card",children:(0,e.jsx)("div",{className:"skills-bot-grid",children:p.map(t=>(0,e.jsx)(Al,{bot:t,installedNames:ee,skills:f,status:Fe[t.larkAppId]??null,busyKey:We,onSave:ml},t.larkAppId))})})]})]}),(0,e.jsx)(Il,{skills:f,busySkill:Ue,removingNames:Z,status:ye,onUpdate:t=>{cl(t)},onRequestRemove:dl}),(0,e.jsx)(Pl,{names:Qe?xe:null,references:Xe,busy:Z.size>0,error:Ve,onCancel:ul,onConfirm:t=>{kl(t)}}),(0,e.jsx)("dialog",{className:"skills-discovery-dialog",id:"skills-discovery-dialog",ref:k,onClose:()=>X(!1),onClick:t=>{t.target===t.currentTarget&&X(!1)},children:(0,e.jsxs)("article",{children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:l("skills.discoverTitle")}),(0,e.jsx)("p",{children:l("skills.discoverHelp")}),(0,e.jsx)("button",{type:"button",className:"skills-discovery-close","data-action":"close-discovery","aria-label":l("skills.discoverClose"),title:l("skills.discoverClose"),onClick:()=>X(!1)})]}),(0,e.jsx)("div",{className:"skills-discovery-body",children:J?(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"skills-discovery-layout",children:[(0,e.jsx)("div",{className:"skills-discovery-tabs",role:"tablist","aria-label":l("skills.discoverTitle"),children:y.map(t=>{let n=ue(t),d=n===pe;return(0,e.jsxs)("button",{type:"button",role:"tab","data-discovery-tab":n,className:d?"selected":"","aria-selected":d?"true":"false",onClick:()=>Ke(n),children:[(0,e.jsx)("strong",{children:t.label??t.cliId}),(0,e.jsx)("small",{children:l("skills.skillCount",{count:t.skills.length})})]},n)})}),(0,e.jsxs)("div",{className:"skills-discovery-main",children:[(0,e.jsx)("div",{className:"skills-discovery-path",children:(0,e.jsx)("code",{children:J.rootDir})}),y.map(t=>{let n=ue(t);return(0,e.jsx)("section",{className:"skills-discovery-group","data-discovery-panel":n,hidden:!(n===pe),children:t.skills.length===0?(0,e.jsx)("p",{className:"empty",children:l("skills.discoverGroupEmpty")}):(0,e.jsx)("div",{className:"skills-discovery-list",children:t.skills.map(m=>{let v=ee.has(m.name),N=m.rootDir??m.source?.root??"";return(0,e.jsxs)("label",{className:`skills-discovery-row${v?" installed":""}`,children:[(0,e.jsx)("input",{type:"checkbox","data-discovered-skill":!0,value:N,disabled:v,checked:!v&&ge.has(N),onChange:E=>{let Se=E.currentTarget.checked;fe(re=>{let Ne=new Set(re);return Se?Ne.add(N):Ne.delete(N),Ne})}}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:m.name}),m.description?(0,e.jsx)("small",{children:m.description}):null]}),v?(0,e.jsx)("em",{children:l("skills.discoverRegistered")}):null]},`${m.name}:${N}`)})})},n)})]})]})}):(0,e.jsx)("p",{className:"empty",children:l("skills.discoverEmpty")})}),(0,e.jsxs)("footer",{className:"actions",children:[(0,e.jsx)("button",{type:"button","data-action":"toggle-discovered-skills",disabled:le.length===0,onClick:()=>{fe(t=>{let n=new Set(t);return Me?le.forEach(d=>n.delete(d)):le.forEach(d=>n.add(d)),n})},children:l(Me?"skills.discoverClearSelection":"skills.discoverSelectAll")}),(0,e.jsx)("button",{type:"button",className:"primary","data-action":"register-discovered-skills",disabled:Je,onClick:()=>{al()},children:l("skills.discoverRegister")})]})]})})]})});return(0,e.jsxs)("section",{className:"page skills-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:l("nav.skills")}),(0,e.jsx)("h1",{children:l("skills.title")})]}),vl]}),(0,e.jsx)("div",{id:"skills-body",children:yl})]})}function Dl(l,s){return l.size===s.length&&s.every(o=>l.has(o))}function xl(l){let s=K(),o=(0,i.useRef)(null),k=(0,i.useRef)(null),f=(0,i.useRef)(null),[b,y]=(0,i.useState)(!1),[r,p]=(0,i.useState)(""),[w,R]=(0,i.useState)(()=>new Set(l.names)),[I,D]=(0,i.useState)(null),x=l.names.join(`
4
- `),A=r.trim().toLocaleLowerCase(),M=(0,i.useMemo)(()=>{let c=new Map(l.skills.map(g=>[g.name,g]));for(let g of l.names)c.has(g)||c.set(g,{name:g});return[...c.values()].sort((g,S)=>g.name.localeCompare(S.name))},[l.names,l.skills]),j=(0,i.useMemo)(()=>A?M.filter(c=>`${c.name} ${c.description||""}`.toLocaleLowerCase().includes(A)):M,[A,M]),L=!Dl(w,l.names),h=(0,i.useCallback)(()=>{let c=k.current;if(!c||typeof window>"u")return;let g=c.getBoundingClientRect(),S=12,$=7,a=Math.min(370,Math.max(260,window.innerWidth-S*2)),C=Math.min(Math.max(S,g.left),Math.max(S,window.innerWidth-a-S)),u=Math.max(0,g.top-$-S),P=Math.max(0,window.innerHeight-g.bottom-$-S),H=u>P,Q=H?u:P,U=118+Math.min(M.length,5)*42,W=Math.max(180,Math.min(U,Q));D({left:C,top:H?Math.max(S,g.top-$-W):g.bottom+$,width:a,height:W})},[M.length]);(0,i.useEffect)(()=>{b||R(new Set(l.names))},[x,b]),(0,i.useEffect)(()=>{if(!b||typeof document>"u")return;let c=g=>{o.current?.contains(g.target)||f.current?.contains(g.target)||(y(!1),p(""),R(new Set(l.names)))};return document.addEventListener("pointerdown",c),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),h(),()=>{document.removeEventListener("pointerdown",c),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[x,b,h]);function B(){R(new Set(l.names)),p(""),h(),y(!0)}function T(){R(new Set(l.names)),p(""),y(!1)}function F(c){R(g=>{let S=new Set(g);return S.has(c)?S.delete(c):S.add(c),S})}async function q(){let c=[...w].sort((g,S)=>g.localeCompare(S));try{await l.onSave(c),p(""),y(!1)}catch{}}let _=l.names.length===0?s("skills.pickerPlaceholder"):l.names.length===1?l.names[0]:s("skills.pickerSelectedCount",{count:l.names.length}),z=b?(0,e.jsxs)("div",{ref:f,className:"skills-multi-picker-popover",style:I?{left:I.left,top:I.top,width:I.width,height:I.height}:void 0,children:[(0,e.jsxs)("div",{className:"skills-multi-picker-head",children:[(0,e.jsxs)("label",{className:"skills-multi-picker-search",children:[(0,e.jsx)("span",{className:"skills-multi-picker-search-icon","aria-hidden":"true"}),(0,e.jsx)("input",{type:"search","data-action":"search-skills",autoFocus:!0,autoComplete:"off",value:r,placeholder:s("skills.pickerSearchPlaceholder"),onChange:c=>p(c.currentTarget.value),onKeyDown:c=>{c.key==="Escape"&&(c.preventDefault(),T())}})]}),(0,e.jsxs)("div",{className:"skills-multi-picker-meta",children:[(0,e.jsx)("span",{children:s("skills.pickerSelectionMeta",{selected:w.size,total:M.length})}),w.size>0?(0,e.jsx)("button",{type:"button",className:"skills-multi-picker-clear","data-action":"clear-skill-selection",onClick:()=>R(new Set),children:s("skills.pickerClear")}):null]})]}),(0,e.jsxs)("div",{className:"skills-multi-picker-options",role:"listbox","aria-label":s("skills.priority"),"aria-multiselectable":"true",children:[j.map(c=>{let g=w.has(c.name),S=!l.installedNames.has(c.name);return(0,e.jsxs)("button",{type:"button",className:`skills-multi-picker-option${g?" selected":""}${S?" dangling":""}`,role:"option","aria-selected":g,"data-skill-name":c.name,onClick:()=>F(c.name),children:[(0,e.jsx)("span",{className:"skills-multi-picker-check","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"skills-multi-picker-option-copy",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("b",{children:c.name}),S?(0,e.jsx)("em",{children:s("skills.dangling")}):null]}),c.description?(0,e.jsx)("small",{children:c.description}):null]})]},c.name)}),j.length===0?(0,e.jsx)("p",{className:"skills-multi-picker-empty",children:s("skills.pickerNoResults")}):null]}),(0,e.jsxs)("footer",{className:"skills-multi-picker-actions",children:[(0,e.jsx)("button",{type:"button",className:"ghost","data-action":"cancel-skill-selection",disabled:l.busy,onClick:T,children:s("skills.cancel")}),(0,e.jsx)("button",{type:"button",className:"primary","data-action":"save-skill-selection",disabled:!L||l.busy,onClick:()=>{q()},children:l.busy?s("skills.saving"):s("skills.saveSelection")})]})]}):null;return(0,e.jsxs)("div",{ref:o,className:`skills-multi-picker${b?" open":""}`,"data-skill-picker":l.botId,children:[(0,e.jsxs)("button",{ref:k,type:"button",className:"skills-multi-picker-trigger","data-action":"open-skill-picker","aria-haspopup":"listbox","aria-expanded":b,disabled:l.busy,onClick:()=>b?T():B(),children:[(0,e.jsxs)("span",{className:"skills-multi-picker-trigger-copy",children:[(0,e.jsx)("b",{children:_}),(0,e.jsx)("small",{children:s("skills.pickerTriggerHint")})]}),(0,e.jsx)("span",{className:"skills-multi-picker-chevron","aria-hidden":"true"})]}),z&&typeof document<"u"?(0,qe.createPortal)(z,document.body):z]})}function Al(l){let s=K(),{bot:o,installedNames:k,skills:f,status:b,busyKey:y,onSave:r}=l,p=o.botName??o.larkAppId,w=ke(o.skills);return o.error?(0,e.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":o.larkAppId,children:[(0,e.jsxs)("header",{children:[(0,e.jsx)(Ce,{html:we({name:p,larkAppId:o.larkAppId,size:"sm"})}),(0,e.jsx)("strong",{children:p})]}),(0,e.jsx)("p",{className:"hint-warn-inline",children:o.error})]}):(0,e.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":o.larkAppId,children:[(0,e.jsxs)("header",{className:"skills-bot-head",children:[(0,e.jsx)(Ce,{html:we({name:p,larkAppId:o.larkAppId,size:"sm",dot:"ok"})}),(0,e.jsxs)("div",{className:"skills-bot-title-line",children:[(0,e.jsx)("strong",{children:p}),(0,e.jsx)("span",{className:"skills-count-pill",children:s("skills.skillCount",{count:w.length})})]})]}),(0,e.jsxs)("section",{className:"skills-policy-panel",children:[(0,e.jsx)("div",{className:"skills-priority-head",children:(0,e.jsx)("h3",{className:"skills-priority-title",children:s("skills.priority")})}),(0,e.jsx)(xl,{botId:o.larkAppId,names:w,installedNames:k,skills:f,busy:y===`${o.larkAppId}:set`,onSave:R=>r(o.larkAppId,R)})]}),(0,e.jsx)("span",{className:Re(b),"data-bot-status":!0,children:b?.text??""})]})}function $l(l){return He(l,(0,e.jsx)(Tl,{}))}export{Al as BotPolicyCard,Il as InstalledSkillsLibrary,Pl as RemoveSkillsDialog,xl as SkillMultiPicker,Rl as SkillsInstallPanel,$l as renderSkillsPage};
3
+ `).toLocaleLowerCase().includes(L)):l.skills,[L,l.skills,s]),B=Cl(M)*hl,T=Math.max(1,Math.ceil(h.length/B)),F=h.slice(x*B,x*B+B),q=(0,i.useMemo)(()=>new Set(h.map(a=>a.name)),[h]),_=h.filter(a=>I.has(a.name)).length,z=Math.max(0,I.size-_),c=h.length>0&&_===h.length;(0,i.useEffect)(()=>{if(typeof window>"u")return;let a=()=>j(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),(0,i.useEffect)(()=>A(0),[L,B]),(0,i.useEffect)(()=>{A(a=>Math.min(Math.max(0,a),T-1))},[T]),(0,i.useEffect)(()=>{let a=new Set(l.skills.map(u=>u.name)),C=[...k.current].some(u=>!a.has(u));D(u=>{let P=new Set([...u].filter(H=>a.has(H)));return P.size===u.size?u:P}),C&&(R(!1),D(new Set)),k.current=a},[l.skills]),(0,i.useEffect)(()=>{o.current&&(o.current.indeterminate=_>0&&!c)},[c,_]),(0,i.useEffect)(()=>{if(typeof document>"u")return;let a=u=>{if(u.key!=="Escape"||!b.current)return;let P=f.current;y.current=P,u.preventDefault(),u.stopPropagation(),R(!1),D(new Set),window.setTimeout(()=>{p(H=>H||P),y.current=null},50)},C=u=>{if(u.key!=="Escape"||y.current===null)return;let P=y.current;y.current=null,u.preventDefault(),u.stopPropagation(),p(P)};return document.addEventListener("keydown",a,!0),document.addEventListener("keyup",C,!0),()=>{document.removeEventListener("keydown",a,!0),document.removeEventListener("keyup",C,!0)}},[]);function g(a){D(C=>{let u=new Set(C);return u.has(a)?u.delete(a):u.add(a),u})}function S(){D(a=>{let C=new Set(a);if(c)for(let u of q)C.delete(u);else for(let u of q)C.add(u);return C})}function $(a=!1){let C=r;R(!1),D(new Set),a&&typeof window<"u"&&window.setTimeout(()=>p(C),0)}return(0,e.jsxs)("section",{className:"skills-installed-block",children:[(0,e.jsx)(te,{title:s("skills.installed"),count:s("skills.installedCount",{count:l.skills.length}),hint:s("skills.installedHelp"),children:(0,e.jsx)("div",{className:"skills-installed-header-actions",children:w?(0,e.jsx)("button",{type:"button","data-action":"cancel-installed-selection",onClick:()=>$(),children:s("skills.cancel")}):(0,e.jsx)("button",{type:"button","data-action":"select-installed-skills",disabled:l.skills.length===0,onClick:()=>R(!0),children:s("skills.select")})})}),(0,e.jsxs)("section",{className:"bd-card skills-installed-panel",children:[(0,e.jsxs)("div",{className:"skills-library-toolbar",children:[(0,e.jsxs)("label",{className:"skills-installed-search",children:[(0,e.jsx)("span",{className:"sr-only",children:s("skills.searchLabel")}),(0,e.jsx)("input",{type:"text",role:"searchbox",inputMode:"search","data-action":"search-installed-skills",placeholder:s("skills.searchPlaceholder"),value:r,onChange:a=>p(a.currentTarget.value),onKeyDown:a=>{a.key!=="Escape"||!w||(a.preventDefault(),a.stopPropagation(),$(!0))}}),r?(0,e.jsx)("button",{type:"button","data-action":"clear-installed-search","aria-label":s("skills.clearSearch"),onClick:()=>p(""),children:"\xD7"}):null]}),w?(0,e.jsxs)("label",{className:"skills-select-all-results",children:[(0,e.jsx)("input",{ref:o,type:"checkbox",checked:c,disabled:h.length===0||l.removingNames.size>0,onChange:S}),(0,e.jsx)("span",{children:L?s("skills.selectSearchResults",{count:h.length}):s("skills.selectAllSkills",{count:h.length})})]}):null,L?(0,e.jsx)("span",{className:"skills-filter-count",children:s("skills.resultCount",{count:h.length})}):null,T>1?(0,e.jsxs)("div",{className:"skills-pager",children:[(0,e.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"-1","aria-label":s("skills.prevPage"),title:s("skills.prevPage"),disabled:x===0,onClick:()=>A(a=>Math.max(0,a-1)),children:"\u2039"}),(0,e.jsx)("span",{children:s("skills.pageStatus",{page:x+1,pages:T})}),(0,e.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"1","aria-label":s("skills.nextPage"),title:s("skills.nextPage"),disabled:x>=T-1,onClick:()=>A(a=>Math.min(T-1,a+1)),children:"\u203A"})]}):null]}),(0,e.jsx)("div",{className:"skills-installed-live",role:"status","aria-live":"polite",children:l.status?(0,e.jsx)("span",{className:Re(l.status),children:l.status.text}):null}),l.skills.length===0?(0,e.jsxs)("div",{className:"skills-library-empty",children:[(0,e.jsx)("strong",{children:s("skills.emptyTitle")}),(0,e.jsx)("p",{children:s("skills.emptyHelp")})]}):h.length===0?(0,e.jsxs)("div",{className:"skills-library-empty","data-empty":"search",children:[(0,e.jsx)("strong",{children:s("skills.noResultsTitle",{query:r.trim()})}),(0,e.jsx)("p",{children:s("skills.noResultsHelp")}),(0,e.jsx)("button",{type:"button","data-action":"clear-installed-search-empty",onClick:()=>p(""),children:s("skills.clearSearch")})]}):(0,e.jsx)("div",{className:"skills-list",children:F.map(a=>{let C=I.has(a.name),u=l.removingNames.has(a.name);return(0,e.jsxs)("article",{className:`skills-row skills-installed-card${w?" is-selectable":""}${C?" is-selected":""}${u?" is-removing":""}`,"data-skill":a.name,"data-selection-mode":w?"true":void 0,"aria-busy":u||void 0,onClick:w?()=>g(a.name):void 0,children:[(0,e.jsxs)("div",{className:"skills-row-body",children:[(0,e.jsxs)("div",{className:"skills-row-title",children:[w?(0,e.jsx)("input",{type:"checkbox","aria-label":s("skills.selectNamed",{skill:a.displayName??a.name}),checked:C,disabled:u,onClick:P=>P.stopPropagation(),onChange:()=>g(a.name)}):null,(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:a.displayName??a.name}),a.displayName&&a.displayName!==a.name?(0,e.jsx)("small",{className:"skills-canonical-name",children:a.name}):null]})]}),a.description?(0,e.jsx)("p",{children:a.description}):null,(0,e.jsx)("small",{className:"skills-source-badge",children:ze(a,s)}),u?(0,e.jsx)("span",{className:"skills-removing-label",children:s("skills.removing")}):null]}),w?null:(0,e.jsxs)("div",{className:"skills-card-actions",children:[(0,e.jsx)("button",{type:"button","data-action":"update-skill",disabled:l.busySkill===`${a.name}:update`||u,onClick:()=>l.onUpdate(a.name),children:s("skills.update")}),(0,e.jsx)("button",{type:"button","data-action":"remove-skill",disabled:u,onClick:()=>l.onRequestRemove([a.name]),children:s("skills.remove")})]})]},a.name)})})]}),w?(0,e.jsxs)("div",{className:"skills-bulk-action-bar",role:"toolbar","aria-label":s("skills.bulkActions"),children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:s("skills.selectedCount",{count:I.size})}),z>0?(0,e.jsx)("small",{children:s("skills.selectedHidden",{count:z})}):null]}),(0,e.jsx)("button",{type:"button",className:"danger","data-action":"remove-selected-skills",disabled:I.size===0||l.removingNames.size>0,onClick:()=>l.onRequestRemove([...I]),children:s("skills.removeSelected",{count:I.size})})]}):null]})}function Pl(l){let s=K(),o=(0,i.useRef)(null),k=l.names??[],f=l.references.length>0,b=k.slice(0,3),y=new Set(l.references.flatMap(r=>r.bots)).size;return(0,i.useEffect)(()=>{let r=o.current;if(r)if(l.names&&!r.open)try{r.showModal()}catch{}else!l.names&&r.open&&r.close()},[l.names]),(0,e.jsx)("dialog",{className:"skills-remove-dialog","data-remove-skills-dialog":!0,ref:o,onCancel:r=>{r.preventDefault(),l.busy||l.onCancel()},onClick:r=>{r.target===r.currentTarget&&!l.busy&&l.onCancel()},children:(0,e.jsxs)("article",{children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:f?k.length===1?s("skills.removeInUseOneTitle",{skill:k[0]}):s("skills.removeInUseManyTitle",{count:k.length}):k.length===1?s("skills.removeOneTitle",{skill:k[0]}):s("skills.removeManyTitle",{count:k.length})}),(0,e.jsx)("p",{children:f?k.length===1?s("skills.removeInUseOneHelp",{count:y}):s("skills.removeInUseManyHelp",{count:y}):k.length===1?s("skills.removeOnePermanentHelp"):s("skills.removePermanentHelp")})]}),(0,e.jsxs)("div",{className:"skills-remove-dialog-body",children:[k.length>1?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("ul",{children:b.map(r=>(0,e.jsx)("li",{children:r},r))}),k.length>b.length?(0,e.jsx)("p",{children:s("skills.removeMore",{count:k.length-b.length})}):null]}):null,l.references.length>0?(0,e.jsxs)("div",{className:"skills-remove-reference-warning",role:"alert",children:[(0,e.jsx)("strong",{children:s("skills.removeReferencesDetail")}),(0,e.jsx)("ul",{children:l.references.map(r=>(0,e.jsxs)("li",{children:[(0,e.jsx)("strong",{children:r.name}),(0,e.jsx)("span",{children:r.bots.join(", ")})]},r.name))})]}):null,l.error?(0,e.jsx)("p",{className:"hint-warn",role:"alert",children:l.error}):null]}),(0,e.jsxs)("footer",{className:"actions",children:[(0,e.jsx)("button",{type:"button",autoFocus:!0,disabled:l.busy,onClick:l.onCancel,children:s("skills.cancel")}),(0,e.jsx)("button",{type:"button",className:"danger",disabled:l.busy,onClick:()=>l.onConfirm(f),children:l.busy?s("skills.removing"):f?s("skills.removeAnyway"):k.length===1?s("skills.removeOneConfirm"):s("skills.removeSelected",{count:k.length})})]})]})})}function Tl(){let l=K(),s=(0,i.useRef)(!0),o=(0,i.useRef)(new Set),k=(0,i.useRef)(null),[f,b]=(0,i.useState)([]),[y,r]=(0,i.useState)([]),[p,w]=(0,i.useState)([]),[R,I]=(0,i.useState)("off"),[D,x]=(0,i.useState)("auto"),[A,M]=(0,i.useState)(null),[j,L]=(0,i.useState)(!0),[h,B]=(0,i.useState)(""),[T,F]=(0,i.useState)(""),[q,_]=(0,i.useState)(""),[z,c]=(0,i.useState)(null),[g,S]=(0,i.useState)(!1),[$,a]=(0,i.useState)(!1),[C,u]=(0,i.useState)(!1),[P,H]=(0,i.useState)([]),[Q,W]=(0,i.useState)(()=>new Set),[U,X]=(0,i.useState)(!1),[Je,Ie]=(0,i.useState)(!1),[me,Ke]=(0,i.useState)(null),[ge,fe]=(0,i.useState)(()=>new Set),[Pe,ne]=(0,i.useState)(null),[We,Te]=(0,i.useState)(null),[Ue,De]=(0,i.useState)(null),[Fe,ve]=(0,i.useState)({}),[ye,V]=(0,i.useState)(null),[xe,be]=(0,i.useState)(null),[Qe,Y]=(0,i.useState)(!1),[Xe,ie]=(0,i.useState)([]),[Ve,ae]=(0,i.useState)(null),[Z,Ae]=(0,i.useState)(()=>new Set),ee=(0,i.useMemo)(()=>new Set(f.map(t=>t.name)),[f]),J=(0,i.useMemo)(()=>y.length===0?void 0:(me?y.find(n=>ue(n)===me):void 0)??y.find(n=>n.skills.length>0)??y[0],[me,y]),pe=J?ue(J):"",le=(0,i.useMemo)(()=>J?J.skills.filter(t=>!ee.has(t.name)).map(t=>t.rootDir??t.source?.root??"").filter(Boolean):[],[J,ee]),Me=le.length>0&&le.every(t=>ge.has(t)),Le=(0,i.useCallback)(()=>{for(let t of o.current)window.clearTimeout(t);o.current.clear()},[]),Ye=(0,i.useCallback)(t=>new Promise(n=>{let d=window.setTimeout(()=>{o.current.delete(d),n()},t);o.current.add(d)}),[]),Ee=(0,i.useCallback)(async()=>{let[t,n]=await Promise.all([fetch("/api/skills"),fetch("/api/bots")]),d=await t.json().catch(()=>({})),m=await n.json().catch(()=>({}));if(!t.ok){let v=d?.error??`skills HTTP ${t.status}`;throw new Error(v==="not_found_yet"||v==="not_found"?l("skills.apiUnavailable"):v)}if(!n.ok)throw new Error(m?.error??`bots HTTP ${n.status}`);return{skills:Array.isArray(d.skills)?d.skills:[],nativeSkillGroups:Array.isArray(d.nativeSkillGroups)?d.nativeSkillGroups:[],bots:Array.isArray(m.bots)?m.bots:[],trustProjectSkills:d.trustProjectSkills==="all"?"all":"off",delivery:d.delivery==="prompt"||d.delivery==="native"?d.delivery:"auto"}},[l]),se=(0,i.useCallback)(async()=>{L(!0);try{let t=await Ee();if(!s.current)return;b(t.skills),r(t.nativeSkillGroups),w(t.bots),I(t.trustProjectSkills),x(t.delivery),M(null),fe(n=>{let d=new Set,m=new Set(t.skills.map(v=>v.name));for(let v of t.nativeSkillGroups)for(let N of v.skills){let E=N.rootDir??N.source?.root??"";E&&!m.has(N.name)&&n.has(E)&&d.add(E)}return d})}catch(t){if(!s.current)return;M(t?.message??String(t))}finally{s.current&&L(!1)}},[Ee]);(0,i.useEffect)(()=>(s.current=!0,se(),()=>{s.current=!1,Le()}),[Le,se]),(0,i.useEffect)(()=>{if(!ye||Z.size>0)return;let t=window.setTimeout(()=>{s.current&&V(null)},6e3);return()=>window.clearTimeout(t)},[ye,Z]),(0,i.useEffect)(()=>{let t=k.current;if(t)if(U&&!t.open)try{t.showModal()}catch{}else!U&&t.open&&t.close()},[U,pe]);async function Be(t,n,d=!0){let m=t;for(n({text:l("skills.jobRunning"),ok:!0});;){if(!s.current)return;if(m.status==="succeeded"){n({text:l("skills.saved"),ok:!0}),d&&await se();return}if(m.status==="failed")throw new Error(m.error??"job_failed");if(await Ye(800),!s.current)return;let v=await O(`/api/skills/jobs/${encodeURIComponent(m.id)}`,{method:"GET"});if(!s.current)return;m=v.job}}function Ze(t){return p.filter(n=>ke(n.skills).includes(t)).map(n=>n.botName??n.larkAppId)}function oe(){H([]),W(new Set),u(!1)}function $e(){return{source:h.trim(),path:T.trim()||void 0,ref:q.trim()||void 0}}function el(t){let n=t??[...Q];return{...$e(),skillNames:n.length>0?n:void 0}}async function ll(){a(!0),c({text:l("skills.scanning"),ok:!0});try{let t=await O("/api/skills/discover",{method:"POST",body:JSON.stringify($e())});if(!s.current)return{skills:[],directInstall:!1};let n=t.discovery?.directInstall===!0,d=Array.isArray(t.discovery?.skills)?t.discovery.skills:[];return H(d),W(new Set(d.map(m=>m.name))),{skills:d,directInstall:n}}finally{s.current&&a(!1)}}function G(t){let n=t||"";return n.startsWith("skill_git_command_failed")&&/authentication failed|could not read username|repository not found|unauthor|\b401\b|\b403\b/i.test(n)?l("skills.gitNeedsAuth"):n.startsWith("agentbuddy_not_found")?l("skills.agentbuddyNotFound"):n.startsWith("agentbuddy_login_required")?l("skills.agentbuddyNeedsLogin"):n.startsWith("agentbuddy_command_failed")?/login|credential|unauthor|not logged|401|403/i.test(n)?l("skills.agentbuddyNeedsLogin"):l("skills.agentbuddyCommandFailed"):n.startsWith("agentbuddy_clear_telemetry_failed")||n.startsWith("agentbuddy_telemetry_not_stripped")?l("skills.agentbuddyTelemetryFailed"):n.startsWith("agentbuddy_no_skill_produced")?l("skills.agentbuddyNoSkill"):n.startsWith("invalid_agentbuddy")?l("skills.agentbuddyInvalid"):n}async function he(t){S(!0);try{let n=await O("/api/skills/install",{method:"POST",body:JSON.stringify(el(t))});if(!s.current)return;await Be(n.job,c),s.current&&oe()}catch(n){s.current&&c({text:`${l("skills.failed")}: ${G(n?.message??String(n))}`,ok:!1})}finally{s.current&&S(!1)}}function sl(t){W(n=>{let d=new Set(n);return d.has(t)?d.delete(t):d.add(t),d})}function tl(t){W(t?new Set(P.map(n=>n.name)):new Set)}async function nl(){if(!h.trim()){c({text:l("skills.sourceRequired"),ok:!1});return}try{u(!1);let{skills:t,directInstall:n}=await ll();if(!s.current)return;if(n){await he();return}if(t.length===0){c({text:l("skills.scanEmpty"),ok:!1});return}if(t.length===1){await he([t[0].name]);return}c({text:l("skills.scanFound",{count:t.length}),ok:!0}),u(!0)}catch(t){s.current&&c({text:`${l("skills.failed")}: ${G(t?.message??String(t))}`,ok:!1})}}async function il(){let t=[...Q];if(t.length===0){c({text:l("skills.discoverNothingSelected"),ok:!1});return}await he(t)}async function al(){let t=[...ge].filter(Boolean);if(t.length===0){c({text:l("skills.discoverNothingSelected"),ok:!1});return}Ie(!0);try{if(c({text:l("skills.discoverRegisteringBatch",{total:t.length}),ok:!0}),await O("/api/skills/install-local-links",{method:"POST",body:JSON.stringify({sources:t})}),!s.current)return;X(!1),await se(),s.current&&c({text:l("skills.saved"),ok:!0})}catch(n){s.current&&c({text:`${l("skills.failed")}: ${G(n?.message??String(n))}`,ok:!1})}finally{s.current&&Ie(!1)}}async function ol(t){if(R!==t){ne("project");try{let n=await O("/api/skills/global",{method:"PUT",body:JSON.stringify({trustProjectSkills:t})});if(!s.current)return;I(n.trustProjectSkills==="all"?"all":t)}catch(n){s.current&&window.alert(`${l("skills.failed")}: ${G(n?.message??String(n))}`)}finally{s.current&&ne(null)}}}async function rl(t){if(D!==t){ne("delivery");try{let n=await O("/api/skills/global",{method:"PUT",body:JSON.stringify({delivery:t})});if(!s.current)return;x(n.delivery==="prompt"||n.delivery==="native"?n.delivery:t)}catch(n){s.current&&window.alert(`${l("skills.failed")}: ${G(n?.message??String(n))}`)}finally{s.current&&ne(null)}}}async function cl(t){Te(`${t}:update`);try{let n=await O(`/api/skills/${encodeURIComponent(t)}/update`,{method:"POST",body:"{}"});if(!s.current)return;await Be(n.job,c)}catch(n){s.current&&window.alert(`${l("skills.failed")}: ${G(n?.message??String(n))}`)}finally{s.current&&Te(null)}}function dl(t){let n=[...new Set(t.filter(d=>ee.has(d)))];n.length!==0&&(be(n),Y(!0),ie([]),ae(null))}function ul(){Z.size>0||(Y(!1),be(null),ie([]),ae(null))}async function kl(t){let n=xe??[];if(n.length!==0){Ae(new Set(n)),Y(!1),ae(null),V({text:l("skills.removingCount",{count:n.length}),ok:!0});try{let d=await O("/api/skills",{method:"DELETE",body:JSON.stringify({names:n,force:t})});if(!s.current)return;let m=Array.isArray(d.removed)?d.removed.filter(N=>typeof N=="string"):n,v=new Set(m);b(N=>N.filter(E=>!v.has(E.name))),V({text:m.length===1?l("skills.removedOne",{skill:m[0]}):l("skills.removedMany",{count:m.length}),ok:!0}),be(null),ie([])}catch(d){if(!s.current)return;if(d?.status===409&&d?.body?.error==="skills_in_use"){let v=Array.isArray(d.body.affectedSkills)?d.body.affectedSkills.map(N=>{let E=typeof N?.name=="string"?N.name:"",Se=Array.isArray(N?.affectedBots)?N.affectedBots.map(re=>re?.botName||re?.larkAppId||"").filter(Boolean):Ze(E);return E?{name:E,bots:Se}:null}).filter(N=>N!==null):[];ie(v),Y(!0),V(null);return}let m=l("skills.removeFailed",{detail:G(d?.message??String(d))});ae(m),Y(!0),V({text:m,ok:!1})}finally{s.current&&Ae(new Set)}}}async function ml(t,n){let d=`${t}:set`;De(d),ve(m=>({...m,[t]:null}));try{let m=await O(`/api/bots/${encodeURIComponent(t)}/skills`,{method:"PUT",body:JSON.stringify({action:"set",policy:n.length>0?{include:n.map(v=>`skill:${v}`)}:null})});if(!s.current)return;w(v=>v.map(N=>N.larkAppId===t?{...N,skills:m.skills??null}:N)),ve(v=>({...v,[t]:{text:l("skills.policySaved"),ok:!0}}))}catch(m){throw s.current&&ve(v=>({...v,[t]:{text:`${l("skills.failed")}: ${G(m?.message??String(m))}`,ok:!1}})),m}finally{s.current&&De(null)}}let gl=p.filter(t=>wl(t.skills)).length,fl=p.reduce((t,n)=>t+Nl(n.skills),0),vl=(0,e.jsxs)("div",{className:"page-heading-actions skills-heading-actions",children:[(0,e.jsxs)("div",{className:"skills-metric-strip",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("small",{children:l("skills.metricInstalled")}),(0,e.jsx)("strong",{children:f.length})]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("small",{children:l("skills.metricBots")}),(0,e.jsxs)("strong",{children:[gl,"/",p.length]})]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("small",{children:l("skills.metricAttached")}),(0,e.jsx)("strong",{children:fl})]})]}),(0,e.jsx)(_e,{id:"skills-refresh",label:l("skills.refresh"),busy:j,disabled:j,onClick:()=>{se()}})]}),yl=(0,e.jsx)("div",{className:"skills-page-stack",children:j?(0,e.jsx)(je,{label:l("common.loading")}):A?(0,e.jsx)("p",{className:"hint-warn",children:A}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"skills-config-row",children:[(0,e.jsxs)("section",{className:"skills-config-block",children:[(0,e.jsx)(te,{title:l("skills.globalDefaults")}),(0,e.jsxs)("article",{className:"bd-card skills-defaults-panel skills-config-card",children:[(0,e.jsxs)("div",{className:"skills-control-block",children:[(0,e.jsx)("span",{className:"skills-control-label",children:l("skills.globalProject")}),(0,e.jsx)(Ge,{value:R,disabled:Pe==="project",options:[{value:"off",label:l("skills.globalProjectOff"),help:l("skills.globalProjectOffHelp")},{value:"all",label:l("skills.globalProjectAll"),help:l("skills.globalProjectAllHelp")}],onChange:t=>{ol(t)}})]}),(0,e.jsxs)("div",{className:"skills-control-block",children:[(0,e.jsx)("span",{className:"skills-control-label",children:l("skills.globalDelivery")}),(0,e.jsx)(Ge,{value:D,disabled:Pe==="delivery",options:[{value:"auto",label:l("skills.deliveryAuto"),help:l("skills.deliveryAutoHelp")},{value:"prompt",label:l("skills.deliveryPrompt"),help:l("skills.deliveryPromptHelp")},{value:"native",label:l("skills.deliveryNative"),help:l("skills.deliveryNativeHelp")}],onChange:t=>{rl(t)}})]})]})]}),(0,e.jsxs)("section",{className:"skills-config-block",children:[(0,e.jsx)(te,{title:(0,e.jsx)(de,{help:l("skills.installInfo"),helpLabel:l("skills.installInfoLabel"),children:l("skills.install")})}),(0,e.jsx)(Rl,{showTitle:!1,installSource:h,installPath:T,installRef:q,installStatus:z,installBusy:g,installDiscovering:$,installSelectionOpen:C,installCandidates:P,selectedInstallSkills:Q,onInstallSourceChange:t=>{B(t),oe()},onInstallPathChange:t=>{F(t),oe()},onInstallRefChange:t=>{_(t),oe()},onToggleInstallSkill:sl,onSelectAllInstallSkills:tl,onConfirmInstallSelection:()=>{il()},onCloseInstallSelection:()=>u(!1),onInstall:()=>{nl()},onOpenNativeDiscovery:()=>X(!0)})]}),(0,e.jsxs)("section",{className:"skills-config-block",children:[(0,e.jsx)(te,{title:l("skills.bots"),count:l("skills.botCount",{count:p.length}),hint:l("skills.botsHelp")}),(0,e.jsx)("section",{className:"bd-card skills-bots-panel skills-config-card",children:(0,e.jsx)("div",{className:"skills-bot-grid",children:p.map(t=>(0,e.jsx)(Al,{bot:t,installedNames:ee,skills:f,status:Fe[t.larkAppId]??null,busyKey:Ue,onSave:ml},t.larkAppId))})})]})]}),(0,e.jsx)(Il,{skills:f,busySkill:We,removingNames:Z,status:ye,onUpdate:t=>{cl(t)},onRequestRemove:dl}),(0,e.jsx)(Pl,{names:Qe?xe:null,references:Xe,busy:Z.size>0,error:Ve,onCancel:ul,onConfirm:t=>{kl(t)}}),(0,e.jsx)("dialog",{className:"skills-discovery-dialog",id:"skills-discovery-dialog",ref:k,onClose:()=>X(!1),onClick:t=>{t.target===t.currentTarget&&X(!1)},children:(0,e.jsxs)("article",{children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:l("skills.discoverTitle")}),(0,e.jsx)("p",{children:l("skills.discoverHelp")}),(0,e.jsx)("button",{type:"button",className:"skills-discovery-close","data-action":"close-discovery","aria-label":l("skills.discoverClose"),title:l("skills.discoverClose"),onClick:()=>X(!1)})]}),(0,e.jsx)("div",{className:"skills-discovery-body",children:J?(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"skills-discovery-layout",children:[(0,e.jsx)("div",{className:"skills-discovery-tabs",role:"tablist","aria-label":l("skills.discoverTitle"),children:y.map(t=>{let n=ue(t),d=n===pe;return(0,e.jsxs)("button",{type:"button",role:"tab","data-discovery-tab":n,className:d?"selected":"","aria-selected":d?"true":"false",onClick:()=>Ke(n),children:[(0,e.jsx)("strong",{children:t.label??t.cliId}),(0,e.jsx)("small",{children:l("skills.skillCount",{count:t.skills.length})})]},n)})}),(0,e.jsxs)("div",{className:"skills-discovery-main",children:[(0,e.jsx)("div",{className:"skills-discovery-path",children:(0,e.jsx)("code",{children:J.rootDir})}),y.map(t=>{let n=ue(t);return(0,e.jsx)("section",{className:"skills-discovery-group","data-discovery-panel":n,hidden:!(n===pe),children:t.skills.length===0?(0,e.jsx)("p",{className:"empty",children:l("skills.discoverGroupEmpty")}):(0,e.jsx)("div",{className:"skills-discovery-list",children:t.skills.map(m=>{let v=ee.has(m.name),N=m.rootDir??m.source?.root??"";return(0,e.jsxs)("label",{className:`skills-discovery-row${v?" installed":""}`,children:[(0,e.jsx)("input",{type:"checkbox","data-discovered-skill":!0,value:N,disabled:v,checked:!v&&ge.has(N),onChange:E=>{let Se=E.currentTarget.checked;fe(re=>{let Ne=new Set(re);return Se?Ne.add(N):Ne.delete(N),Ne})}}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:m.name}),m.description?(0,e.jsx)("small",{children:m.description}):null]}),v?(0,e.jsx)("em",{children:l("skills.discoverRegistered")}):null]},`${m.name}:${N}`)})})},n)})]})]})}):(0,e.jsx)("p",{className:"empty",children:l("skills.discoverEmpty")})}),(0,e.jsxs)("footer",{className:"actions",children:[(0,e.jsx)("button",{type:"button","data-action":"toggle-discovered-skills",disabled:le.length===0,onClick:()=>{fe(t=>{let n=new Set(t);return Me?le.forEach(d=>n.delete(d)):le.forEach(d=>n.add(d)),n})},children:l(Me?"skills.discoverClearSelection":"skills.discoverSelectAll")}),(0,e.jsx)("button",{type:"button",className:"primary","data-action":"register-discovered-skills",disabled:Je,onClick:()=>{al()},children:l("skills.discoverRegister")})]})]})})]})});return(0,e.jsxs)("section",{className:"page skills-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:l("nav.skills")}),(0,e.jsx)("h1",{children:l("skills.title")})]}),vl]}),(0,e.jsx)("div",{id:"skills-body",children:yl})]})}function Dl(l,s){return l.size===s.length&&s.every(o=>l.has(o))}function xl(l){let s=K(),o=(0,i.useRef)(null),k=(0,i.useRef)(null),f=(0,i.useRef)(null),[b,y]=(0,i.useState)(!1),[r,p]=(0,i.useState)(""),[w,R]=(0,i.useState)(()=>new Set(l.names)),[I,D]=(0,i.useState)(null),x=l.names.join(`
4
+ `),A=r.trim().toLocaleLowerCase(),M=(0,i.useMemo)(()=>{let c=new Map(l.skills.map(g=>[g.name,g]));for(let g of l.names)c.has(g)||c.set(g,{name:g});return[...c.values()].sort((g,S)=>g.name.localeCompare(S.name))},[l.names,l.skills]),j=(0,i.useMemo)(()=>A?M.filter(c=>`${c.name} ${c.description||""}`.toLocaleLowerCase().includes(A)):M,[A,M]),L=!Dl(w,l.names),h=(0,i.useCallback)(()=>{let c=k.current;if(!c||typeof window>"u")return;let g=c.getBoundingClientRect(),S=12,$=7,a=Math.min(370,Math.max(260,window.innerWidth-S*2)),C=Math.min(Math.max(S,g.left),Math.max(S,window.innerWidth-a-S)),u=Math.max(0,g.top-$-S),P=Math.max(0,window.innerHeight-g.bottom-$-S),H=u>P,Q=H?u:P,W=118+Math.min(M.length,5)*42,U=Math.max(180,Math.min(W,Q));D({left:C,top:H?Math.max(S,g.top-$-U):g.bottom+$,width:a,height:U})},[M.length]);(0,i.useEffect)(()=>{b||R(new Set(l.names))},[x,b]),(0,i.useEffect)(()=>{if(!b||typeof document>"u")return;let c=g=>{o.current?.contains(g.target)||f.current?.contains(g.target)||(y(!1),p(""),R(new Set(l.names)))};return document.addEventListener("pointerdown",c),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),h(),()=>{document.removeEventListener("pointerdown",c),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[x,b,h]);function B(){R(new Set(l.names)),p(""),h(),y(!0)}function T(){R(new Set(l.names)),p(""),y(!1)}function F(c){R(g=>{let S=new Set(g);return S.has(c)?S.delete(c):S.add(c),S})}async function q(){let c=[...w].sort((g,S)=>g.localeCompare(S));try{await l.onSave(c),p(""),y(!1)}catch{}}let _=l.names.length===0?s("skills.pickerPlaceholder"):l.names.length===1?l.names[0]:s("skills.pickerSelectedCount",{count:l.names.length}),z=b?(0,e.jsxs)("div",{ref:f,className:"skills-multi-picker-popover",style:I?{left:I.left,top:I.top,width:I.width,height:I.height}:void 0,children:[(0,e.jsxs)("div",{className:"skills-multi-picker-head",children:[(0,e.jsxs)("label",{className:"skills-multi-picker-search",children:[(0,e.jsx)("span",{className:"skills-multi-picker-search-icon","aria-hidden":"true"}),(0,e.jsx)("input",{type:"search","data-action":"search-skills",autoFocus:!0,autoComplete:"off",value:r,placeholder:s("skills.pickerSearchPlaceholder"),onChange:c=>p(c.currentTarget.value),onKeyDown:c=>{c.key==="Escape"&&(c.preventDefault(),T())}})]}),(0,e.jsxs)("div",{className:"skills-multi-picker-meta",children:[(0,e.jsx)("span",{children:s("skills.pickerSelectionMeta",{selected:w.size,total:M.length})}),w.size>0?(0,e.jsx)("button",{type:"button",className:"skills-multi-picker-clear","data-action":"clear-skill-selection",onClick:()=>R(new Set),children:s("skills.pickerClear")}):null]})]}),(0,e.jsxs)("div",{className:"skills-multi-picker-options",role:"listbox","aria-label":s("skills.priority"),"aria-multiselectable":"true",children:[j.map(c=>{let g=w.has(c.name),S=!l.installedNames.has(c.name);return(0,e.jsxs)("button",{type:"button",className:`skills-multi-picker-option${g?" selected":""}${S?" dangling":""}`,role:"option","aria-selected":g,"data-skill-name":c.name,onClick:()=>F(c.name),children:[(0,e.jsx)("span",{className:"skills-multi-picker-check","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"skills-multi-picker-option-copy",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("b",{children:c.name}),S?(0,e.jsx)("em",{children:s("skills.dangling")}):null]}),c.description?(0,e.jsx)("small",{children:c.description}):null]})]},c.name)}),j.length===0?(0,e.jsx)("p",{className:"skills-multi-picker-empty",children:s("skills.pickerNoResults")}):null]}),(0,e.jsxs)("footer",{className:"skills-multi-picker-actions",children:[(0,e.jsx)("button",{type:"button",className:"ghost","data-action":"cancel-skill-selection",disabled:l.busy,onClick:T,children:s("skills.cancel")}),(0,e.jsx)("button",{type:"button",className:"primary","data-action":"save-skill-selection",disabled:!L||l.busy,onClick:()=>{q()},children:l.busy?s("skills.saving"):s("skills.saveSelection")})]})]}):null;return(0,e.jsxs)("div",{ref:o,className:`skills-multi-picker${b?" open":""}`,"data-skill-picker":l.botId,children:[(0,e.jsxs)("button",{ref:k,type:"button",className:"skills-multi-picker-trigger","data-action":"open-skill-picker","aria-haspopup":"listbox","aria-expanded":b,disabled:l.busy,onClick:()=>b?T():B(),children:[(0,e.jsxs)("span",{className:"skills-multi-picker-trigger-copy",children:[(0,e.jsx)("b",{children:_}),(0,e.jsx)("small",{children:s("skills.pickerTriggerHint")})]}),(0,e.jsx)("span",{className:"skills-multi-picker-chevron","aria-hidden":"true"})]}),z&&typeof document<"u"?(0,qe.createPortal)(z,document.body):z]})}function Al(l){let s=K(),{bot:o,installedNames:k,skills:f,status:b,busyKey:y,onSave:r}=l,p=o.botName??o.larkAppId,w=ke(o.skills);return o.error?(0,e.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":o.larkAppId,children:[(0,e.jsxs)("header",{children:[(0,e.jsx)(Ce,{html:we({name:p,larkAppId:o.larkAppId,size:"sm"})}),(0,e.jsx)("strong",{children:p})]}),(0,e.jsx)("p",{className:"hint-warn-inline",children:o.error})]}):(0,e.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":o.larkAppId,children:[(0,e.jsxs)("header",{className:"skills-bot-head",children:[(0,e.jsx)(Ce,{html:we({name:p,larkAppId:o.larkAppId,size:"sm",dot:"ok"})}),(0,e.jsxs)("div",{className:"skills-bot-title-line",children:[(0,e.jsx)("strong",{children:p}),(0,e.jsx)("span",{className:"skills-count-pill",children:s("skills.skillCount",{count:w.length})})]})]}),(0,e.jsxs)("section",{className:"skills-policy-panel",children:[(0,e.jsx)("div",{className:"skills-priority-head",children:(0,e.jsx)("h3",{className:"skills-priority-title",children:s("skills.priority")})}),(0,e.jsx)(xl,{botId:o.larkAppId,names:w,installedNames:k,skills:f,busy:y===`${o.larkAppId}:set`,onSave:R=>r(o.larkAppId,R)})]}),(0,e.jsx)("span",{className:Re(b),"data-bot-status":!0,children:b?.text??""})]})}function $l(l){return He(l,(0,e.jsx)(Tl,{}))}export{Al as BotPolicyCard,Il as InstalledSkillsLibrary,Pl as RemoveSkillsDialog,xl as SkillMultiPicker,Rl as SkillsInstallPanel,$l as renderSkillsPage};
@@ -1 +1 @@
1
- import{a as G,b as J,c as S,d as re}from"./chunk-EVK77ASG.js";import{c as E}from"./chunk-FLGXZJTD.js";import{a as oe,d as q,g as ie,p as se}from"./chunk-QFMH6ITB.js";import"./chunk-KQB42ML5.js";import{a as K}from"./chunk-SYC6D5XU.js";import{a as z,d as ne}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var d=L(z(),1);async function V(){return G("/api/team/hosted")}async function le(){return G("/api/team/remote-roster")}async function de(t,a){return re("/api/team/local-bots/"+encodeURIComponent(t)+"/capability",{capability:a})}async function me(t){return G("/api/team/local-bots/"+encodeURIComponent(t)+"/role")}async function ce(t){return S("/api/team/identity/auto-bind",t?{unionId:t}:void 0)}async function ue(t,a){return J("DELETE",`/api/team/hosted/${encodeURIComponent(t)}/members/${encodeURIComponent(a)}`)}async function pe(t,a,n){return S("/api/team/federated-group",{name:a,larkAppIds:n,teamId:t})}async function ge(t,a,n,o){return S("/api/team/remote-group",{hubUrl:t,teamId:a,name:n,larkAppIds:o})}async function ye(t){return S("/api/team/hosted",{name:t})}async function fe(t){return J("DELETE","/api/team/hosted/"+encodeURIComponent(t))}async function be(t){return S("/api/team/local-invite",{teamId:t})}async function ke(t,a){return S("/api/team/join-remote",{hubUrl:t,inviteCode:a})}function F(t,a){let n=a.query.trim().toLowerCase();return!(n&&!((t.name||"")+" "+(t.cliId||"")+" "+(t.capability||"")).toLowerCase().includes(n)||a.cliId&&t.cliId!==a.cliId||a.hasCapability&&!t.capability||a.hasRole&&!t.hasTeamRole)}function he(t){return Array.from(new Set(t.flatMap(a=>a.bots.map(n=>n.cliId)).filter(Boolean))).sort()}function ve(t,a){return(t.teams||[]).map(n=>({kind:"local",key:`local:${n.teamId}`,teamId:n.teamId,label:n.isDefault?a("team.myHostedTeam"):n.name,sub:"",ok:!0,deployments:n.deployments||[],bots:n.bots||[]}))}function Te(t,a){return(t.memberships||[]).map(o=>{let m=o.roster?.deployments||[],r=m.find(v=>v.local),p=r?.name?a("team.remoteTeamLabel",{name:r.name}):o.teamName||o.teamId;return{kind:"remote",key:`${o.hubUrl}::${o.teamId}`,teamId:o.teamId,label:p,sub:o.hubUrl,ok:!!o.ok,error:o.error,hubUrl:o.hubUrl,deployments:m,bots:o.roster?.bots||[]}})}function W(t,a,n){return t.map(o=>({...o,bots:o.bots.map(m=>m.larkAppId===a?{...m,capability:n.trim()||null}:m)}))}var e=L(ne(),1),we=L(z(),1);function Ie(){let t=(0,d.useRef)(!0);return(0,d.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Ce(t){let a=E(),n=t.active==="home",o=t.active==="manage";return(0,e.jsxs)("nav",{className:"team-subnav insight-tabs",role:"tablist","aria-label":a("team.eyebrow"),children:[(0,e.jsx)("a",{href:"#/team",className:`itab${n?" on":""}`,role:"tab","aria-selected":n,children:a("team.navHome")}),(0,e.jsx)("a",{href:"#/team/manage",className:`itab${o?" on":""}`,role:"tab","aria-selected":o,children:a("team.navManage")})]})}function Q(t,a){return t.get(a)??new Set}function He(){let t=E(),a=Ie(),[n,o]=(0,d.useState)([]),[m,r]=(0,d.useState)([]),[p,v]=(0,d.useState)(""),[N,T]=(0,d.useState)(t("team.unbound")),[u,R]=(0,d.useState)({query:"",cliId:"",hasCapability:!1,hasRole:!1}),[P,M]=(0,d.useState)(()=>new Map),[D,x]=(0,d.useState)(()=>new Map),[O,I]=(0,d.useState)(()=>new Set),[B,A]=(0,d.useState)(()=>new Set),[U,C]=(0,d.useState)({kind:"hidden"}),[j,c]=(0,d.useState)(()=>new Map),[g,h]=(0,d.useState)(null),y=(0,d.useMemo)(()=>[...n,...m],[n,m]),Y=(0,d.useMemo)(()=>he(y),[y]),Z=(0,d.useMemo)(()=>[{value:"",label:t("team.allCli")},...Y.map(i=>({value:i,label:i}))],[Y,t]),H=(0,d.useCallback)(async()=>{let i=await V();if(!a.current)return;let s=i.body;if(!s?.ok){o([]);return}v(s.deployment?.deploymentId??""),T(s.deployment?.ownerName||(s.deployment?.ownerUnionId?t("team.bound"):t("team.unbound"))),o(ve(s,t))},[a,t]),ee=(0,d.useCallback)(async()=>{let i=await le();a.current&&r(Te(i.body,t))},[a,t]);(0,d.useEffect)(()=>{M(new Map),x(new Map),I(new Set),A(new Set),H(),ee()},[H,ee]),(0,d.useEffect)(()=>{T(i=>i==="\u672A\u7ED1\u5B9A"||i==="Unbound"?t("team.unbound"):i)},[t]),(0,d.useEffect)(()=>{let i=new Map;for(let s of y)i.set(s.key,new Set(s.bots.filter(l=>F(l,u)).map(l=>l.larkAppId)));M(s=>{let l=!1,f=new Map;for(let[b,k]of s){let w=i.get(b),$=new Set([...k].filter(Ae=>w?.has(Ae)));$.size!==k.size&&(l=!0),$.size&&f.set(b,$)}return l?f:s})},[u,y]);let te=(0,d.useMemo)(()=>{if(!y.length)return"";let i=new Set,s=new Set;for(let b of y)b.bots.filter(w=>F(w,u)).forEach(w=>i.add(w.larkAppId)),b.bots.forEach(w=>s.add(w.larkAppId));let l=y.length>1?t("team.acrossTeams",{n:y.length}):"";return`\xB7 ${i.size===s.size?`${s.size}`:`${i.size} / ${s.size}`} ${t("team.botsWord")}${l}`},[u,y,t]);function _(i,s){c(l=>{let f=new Map(l);return f.set(i,s),f})}function Se(i,s,l){M(f=>{let b=new Map(f),k=new Set(b.get(i)??[]);return l?k.add(s):k.delete(s),k.size?b.set(i,k):b.delete(i),b})}function Me(i,s){x(l=>{let f=new Map(l);return s?f.set(i,s):f.delete(i),f})}async function xe(i,s){await de(i,s),a.current&&(o(l=>W(l,i,s)),r(l=>W(l,i,s)))}async function Be(i,s){let l=await me(i);a.current&&h({app:i,name:s,content:l.body?.role||""})}async function Pe(i,s,l){confirm(t("team.removeMemberConfirm",{name:l}))&&(await ue(i,s),a.current&&H())}async function De(i){let s=[...Q(P,i.key)];if(!s.length){_(i.key,{kind:"err",key:"team.errPickBot"});return}let l=(D.get(i.key)||"").trim()||t("team.defaultGroupName");_(i.key,{kind:"muted",key:"team.creatingGroup"});let f=i.kind==="local"?await pe(i.teamId,l,s):await ge(i.hubUrl,i.teamId,l,s);a.current&&(_(i.key,{kind:"group-result",body:f.body,status:f.status}),f.body?.ok&&(M(b=>{let k=new Map(b);return k.delete(i.key),k}),x(b=>{let k=new Map(b);return k.delete(i.key),k}),i.kind==="local"&&H()))}async function ae(i){C({kind:"loading",key:i?"team.binding":"team.identifying"});let s=await ce(i);if(!a.current)return;let l=s.body;if(l?.ok&&l.owner){C({kind:"ok",name:l.owner.name||l.owner.unionId||""}),H();return}if(l?.ok&&l.needChoice&&Array.isArray(l.candidates)){C({kind:"choice",candidates:l.candidates});return}if(l?.error==="no_candidates"){C({kind:"err",key:"team.noCandidates"});return}C({kind:"bind-fail",error:String(l?.error||"unknown")})}return(0,e.jsxs)("section",{className:"page team-page team-home-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.homeTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"home"})})]}),(0,e.jsxs)("section",{className:"overview-block team-identity-section",children:[(0,e.jsx)(q,{title:t("team.localDeployTitle"),hint:t("team.bindHint")}),(0,e.jsx)("div",{className:"card team-card team-identity-card",children:(0,e.jsxs)("p",{className:"team-identity-row",children:[(0,e.jsx)("span",{className:"team-identity-label",children:t("team.myIdentity")}),(0,e.jsx)("b",{id:"tf-owner",children:N}),(0,e.jsx)("button",{type:"button",id:"tf-autobind",className:"page-primary-action",onClick:()=>{ae()},children:t("team.bindBtn")}),(0,e.jsx)("span",{id:"tf-bind-out",className:"team-bind-status",hidden:U.kind==="hidden",children:(0,e.jsx)(Le,{state:U,tr:t,onPick:i=>{ae(i)}})})]})})]}),(0,e.jsxs)("section",{className:"overview-block team-roster-section",children:[(0,e.jsx)(q,{title:t("team.myTeams"),count:te?te.replace(/^·\s*/,""):void 0,hint:t("team.teamsHint")}),(0,e.jsxs)("div",{className:"card team-card team-roster-card",children:[(0,e.jsxs)("form",{className:"team-filters dashboard-toolbar",onSubmit:i=>i.preventDefault(),children:[(0,e.jsx)("input",{id:"tf-search",type:"search",placeholder:t("team.searchPh"),value:u.query,onChange:i=>R(s=>({...s,query:i.target.value}))}),(0,e.jsx)(se,{id:"tf-cli",className:"team-cli-menu",ariaLabel:t("team.allCli"),value:u.cliId,label:oe(Z,u.cliId),options:Z,onChange:i=>R(s=>({...s,cliId:i}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-fcap",checked:u.hasCapability,onChange:i=>R(s=>({...s,hasCapability:i.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasCap")})]}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-frole",checked:u.hasRole,onChange:i=>R(s=>({...s,hasRole:i.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasRole")})]})]}),(0,e.jsx)("div",{id:"tf-teams",children:(0,e.jsx)(Oe,{teams:y,filters:u,pickedByTeam:P,gnameByTeam:D,expandedTeams:O,expandedDeps:B,groupOutputs:j,myDeploymentId:p,tr:t,onToggleTeam:i=>I(s=>Ne(s,i)),onToggleDep:i=>A(s=>Ne(s,i)),onPick:Se,onGroupNameChange:Me,onCapabilityChange:(i,s)=>{xe(i,s)},onOpenRole:(i,s)=>{Be(i,s)},onRemoveMember:(i,s,l)=>{Pe(i,s,l)},onPullGroup:i=>{De(i)}})})]})]}),(0,e.jsx)(_e,{state:g,tr:t,onClose:()=>h(null)})]})}function Ne(t,a){let n=new Set(t);return n.has(a)?n.delete(a):n.add(a),n}function Le(t){let{state:a,tr:n}=t;return a.kind==="hidden"?null:a.kind==="loading"?(0,e.jsx)("span",{className:"team-bind-loading",children:n(a.key)}):a.kind==="ok"?(0,e.jsx)("span",{className:"ok",children:n("team.bound2",{name:a.name})}):a.kind==="choice"?(0,e.jsxs)(e.Fragment,{children:[n("team.multiCandidate"),(0,e.jsx)("br",{}),a.candidates.map(o=>(0,e.jsx)("button",{type:"button",className:"tf-pickowner ghost","data-union":o.unionId,style:{margin:"2px"},onClick:()=>t.onPick(o.unionId),children:o.name||o.unionId},o.unionId))]}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)("span",{className:"err",children:n("team.bindFail",{error:a.error})})}function Oe(t){let{tr:a}=t;return t.teams.length?(0,e.jsx)(e.Fragment,{children:t.teams.map(n=>{let o=n.bots.filter(p=>F(p,t.filters)),m=!t.expandedTeams.has(n.key),r=n.kind==="remote"?n.ok?(0,e.jsx)("span",{className:"team-status-pill ok",children:a("team.connected")}):(0,e.jsx)("span",{className:"team-status-pill err",children:a("team.connectFail",{error:n.error||""})}):(0,e.jsx)("span",{className:"team-status-pill muted",children:a("team.iHost")});return(0,e.jsxs)("article",{className:"card team-list-card",children:[(0,e.jsxs)("button",{type:"button",className:"tf-team-h","data-tk":n.key,"aria-expanded":!m,onClick:()=>t.onToggleTeam(n.key),children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:m?"\u203A":"\u2304"}),(0,e.jsx)("b",{children:n.label}),n.sub?(0,e.jsx)("span",{className:"muted",children:n.sub}):null,r,(0,e.jsx)("span",{className:"team-meta-pill",children:a("team.teamMeta",{deps:n.deployments.length,bots:n.bots.length})})]}),m?null:n.kind==="remote"&&!n.ok?(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:a("team.rosterFail")}):(0,e.jsx)(Ue,{...t,team:n,filtered:o})]},n.key)})}):(0,e.jsx)("p",{className:"muted",children:a("team.noTeams")})}function Ue(t){let{team:a,tr:n}=t,o=[...a.deployments].sort((r,p)=>r.local===p.local?0:r.local?-1:1),m=o.some(r=>t.filtered.some(p=>p.deployment.id===r.id));return(0,e.jsxs)(e.Fragment,{children:[o.map(r=>(0,we.createElement)(je,{...t,deployment:r,key:r.id})),m?null:(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:n("team.noMatch")}),(0,e.jsxs)("div",{className:"team-pull-row",children:[(0,e.jsxs)("label",{className:"team-pill-field team-group-name-field",children:[(0,e.jsx)("span",{children:n("team.gnameLabel")}),(0,e.jsx)("input",{className:"tf-gname","data-tk":a.key,value:t.gnameByTeam.get(a.key)||"",placeholder:n("team.gnamePlaceholder"),onChange:r=>t.onGroupNameChange(a.key,r.target.value)})]}),(0,e.jsx)("button",{className:"tf-grp page-primary-action","data-tk":a.key,onClick:()=>t.onPullGroup(a),children:n("team.pullGroupBtn")}),(0,e.jsx)("span",{className:"muted team-pull-hint",children:n("team.pullGroupHint")}),(0,e.jsx)("span",{className:"tf-gout","data-tk":a.key,children:(0,e.jsx)(Ge,{output:t.groupOutputs.get(a.key),tr:n})})]})]})}function je(t){let{team:a,deployment:n,tr:o}=t,m=t.filtered.filter(u=>u.deployment.id===n.id);if(!m.length)return null;let r=n.id===t.myDeploymentId,p=r?o("team.tagLocal"):n.stale?o("team.tagRemoteStale"):o("team.tagRemote"),v=`${a.key}::${n.id}`,N=t.expandedDeps.has(v),T=m.filter(u=>Q(t.pickedByTeam,a.key).has(u.larkAppId)).length;return(0,e.jsxs)("section",{className:"team-deployment-block",children:[(0,e.jsxs)("div",{className:"tf-dep-h","data-dk":v,"aria-expanded":N,role:"button",tabIndex:0,onClick:()=>t.onToggleDep(v),onKeyDown:u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),t.onToggleDep(v))},children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:N?"\u2304":"\u203A"}),(0,e.jsx)("b",{children:n.name}),(0,e.jsxs)("span",{className:"muted",children:[o("team.depTag",{tag:p})," \xB7 ",o("team.depCount",{count:m.length}),T?o("team.depSelected",{n:T}):""]}),a.kind==="local"&&!r?(0,e.jsx)("button",{type:"button",className:"tf-rmmember ghost","data-team":a.teamId,"data-dep":n.id,"data-name":n.name,onClick:u=>{u.stopPropagation(),t.onRemoveMember(a.teamId,n.id,n.name)},children:o("team.removeMember")}):null]}),N?(0,e.jsx)("div",{className:"team-roster-list",children:m.map(u=>(0,e.jsx)(Ee,{bot:u,mine:r,picked:Q(t.pickedByTeam,a.key).has(u.larkAppId),teamKey:a.key,tr:o,onPick:t.onPick,onCapabilityChange:t.onCapabilityChange,onOpenRole:t.onOpenRole},u.larkAppId))}):null]})}function Ee(t){let{bot:a,tr:n}=t,o=a.deployment.stale?{opacity:.55}:void 0,m=()=>t.onPick(t.teamKey,a.larkAppId,!t.picked);return(0,e.jsxs)("article",{className:`team-bot-row${t.picked?" selected":""}`,style:o,role:"checkbox","aria-checked":t.picked,tabIndex:0,onClick:r=>{Re(r.target)||m()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||Re(r.target)||(r.preventDefault(),m())},children:[(0,e.jsxs)("label",{className:`team-check-pill${t.picked?" selected":""}`,onClick:r=>r.stopPropagation(),children:[(0,e.jsx)("input",{type:"checkbox",className:"tf-pick","data-tk":t.teamKey,"data-app":a.larkAppId,checked:t.picked,onChange:r=>t.onPick(t.teamKey,a.larkAppId,r.target.checked)}),(0,e.jsx)("span",{className:"team-check-dot","aria-hidden":"true"})]}),(0,e.jsxs)("div",{className:"team-bot-main",children:[(0,e.jsx)("strong",{children:a.name}),(0,e.jsx)("span",{children:a.larkAppId})]}),(0,e.jsx)("span",{className:"team-meta-pill",children:a.cliId}),(0,e.jsx)("div",{className:"team-capability-cell",children:t.mine?(0,e.jsxs)("label",{className:"team-pill-field team-cap-field",children:[(0,e.jsx)("span",{children:n("team.capLabel")}),(0,e.jsx)("input",{className:"tf-cap","data-app":a.larkAppId,defaultValue:a.capability||"",placeholder:n("team.capPh"),onBlur:r=>{let p=r.target.value;p!==(a.capability||"")&&t.onCapabilityChange(a.larkAppId,p)},onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),r.currentTarget.blur())}})]}):a.capability||null}),(0,e.jsx)("div",{className:"team-role-cell",children:a.hasTeamRole?t.mine?(0,e.jsx)("button",{className:"tf-role","data-app":a.larkAppId,"data-name":a.name,onClick:()=>t.onOpenRole(a.larkAppId,a.name),children:n("team.viewRole")}):n("team.hasRoleShort"):(0,e.jsx)("span",{className:"muted",children:"\u2014"})})]})}function Re(t){return t instanceof HTMLElement?!!t.closest('button, input, textarea, select, a, label, [contenteditable="true"]'):!1}function Ge(t){let{output:a,tr:n}=t;return a?a.kind==="muted"?(0,e.jsx)("span",{className:"muted",children:n(a.key)}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)(Fe,{body:a.body,status:a.status,tr:n}):null}function Fe(t){let{body:a,status:n,tr:o}=t;if(a?.ok&&a.chatId){let p=a.shareLink||"https://applink.feishu.cn/client/chat/open?openChatId="+encodeURIComponent(a.chatId);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"ok",children:o("team.groupCreated")}),a.delegatedTo?o("team.delegatedBy",{name:String(a.delegatedTo)}):""," \xB7 ",(0,e.jsx)("a",{href:p,target:"_blank",rel:"noreferrer",children:o("team.openInLark")}),(a.invalidBotIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidBots",{ids:(a.invalidBotIds||[]).join(", ")})]}):null,(a.invalidOwnerUnionIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidOwners",{n:(a.invalidOwnerUnionIds||[]).length})]}):null,a.missingOperatorIdentity?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.missingIdentity")]}):null,(a.skippedNoOwner||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.skippedNoOwner",{n:(a.skippedNoOwner||[]).length})]}):null]})}let m=a?.error||n,r=m==="no_local_online_bot"?o("team.errNoLocalBot"):m==="all_bots_skipped_no_owner"?o("team.errAllSkipped"):m==="no_creator_available"?o("team.errNoCreator"):m==="delegation_timeout"?o("team.errDelegationTimeout"):o("team.errGroupCreate",{error:String(m)});return(0,e.jsx)("span",{className:"err",children:r})}function _e(t){let{state:a,tr:n}=t;return(0,e.jsx)("div",{id:"tf-modal",className:"team-role-modal","data-app":a?.app,hidden:!a,children:(0,e.jsxs)("div",{className:"team-role-dialog",children:[(0,e.jsx)("h2",{id:"tf-modal-title",children:a?n("team.roleModalTitleName",{name:a.name}):n("team.roleModalTitle")}),(0,e.jsx)("p",{className:"muted",style:{fontSize:"13px"},children:n("team.roleModalHint")}),(0,e.jsx)("textarea",{id:"tf-modal-text",readOnly:!0,value:a?.content??""}),(0,e.jsx)("div",{className:"team-role-actions",children:(0,e.jsx)("button",{type:"button",id:"tf-modal-cancel",onClick:t.onClose,children:n("team.close")})})]})})}function $e(){let t=E(),a=Ie(),[n,o]=(0,d.useState)([]),[m,r]=(0,d.useState)(""),[p,v]=(0,d.useState)(""),[N,T]=(0,d.useState)({kind:"none"}),[u,R]=(0,d.useState)(()=>new Map),[P,M]=(0,d.useState)(""),[D,x]=(0,d.useState)(""),[O,I]=(0,d.useState)({kind:"none"}),B=(0,d.useCallback)(async()=>{let c=await V();if(!a.current)return;let g=c.body;r(h=>g?.suggestedHubUrl||h),o(g?.teams||[])},[a]);(0,d.useEffect)(()=>{B()},[B]);async function A(){let c=p.trim();if(!c){T({kind:"err",key:"team.errName"});return}T({kind:"muted",key:"team.creating"});let g=await ye(c);a.current&&(g.body?.ok?(T({kind:"ok",key:"team.created"}),v(""),B()):T({kind:"create-fail",error:String(g.body?.error||g.status)}))}async function U(c){R(h=>{let y=new Map(h);return y.set(c,{kind:"muted",key:"team.generating"}),y});let g=await be(c);a.current&&R(h=>{let y=new Map(h);return y.set(c,g.body?.code?{kind:"invite",code:g.body.code}:{kind:"err",key:"team.genFail"}),y})}async function C(c,g){confirm(t("team.delConfirm",{name:g}))&&(await fe(c),a.current&&B())}async function j(){let c=P.trim(),g=D.trim();if(I({kind:"muted",key:"team.joining"}),!c||!g){I({kind:"err",key:"team.errHubCode"});return}let h=await ke(c,g);a.current&&(h.body?.ok?(I({kind:"joined",name:String(h.body.teamName||"")}),x("")):I({kind:"join-fail",error:h.body?.error||h.status}))}return(0,e.jsxs)("section",{className:"page team-page team-manage-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.manageTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"manage"})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.hostedTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar",onSubmit:c=>{c.preventDefault(),A()},children:[(0,e.jsx)("input",{id:"tm-newname",type:"text",placeholder:t("team.newTeamPh"),value:p,onChange:c=>v(c.target.value)}),(0,e.jsx)(ie,{id:"tm-create",className:"page-primary-action",onClick:()=>{A()},children:t("team.createTeamBtn")}),(0,e.jsx)("span",{className:"toolbar-status tm-cout",children:(0,e.jsx)(X,{status:N,tr:t})})]}),(0,e.jsx)("div",{id:"tm-list",children:(0,e.jsx)(ze,{teams:n,suggestedHubUrl:m,inviteStatuses:u,tr:t,onInvite:c=>{U(c)},onDelete:(c,g)=>{C(c,g)}})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.joinTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar team-join-form",onSubmit:c=>{c.preventDefault(),j()},children:[(0,e.jsx)("input",{id:"tm-hub",type:"text",placeholder:t("team.hubPh"),value:P,onChange:c=>M(c.target.value)}),(0,e.jsx)("input",{id:"tm-code",type:"text",placeholder:t("team.codePh"),value:D,onChange:c=>x(c.target.value)}),(0,e.jsx)("button",{type:"button",id:"tm-join",className:"page-primary-action",onClick:()=>{j()},children:t("team.joinBtn")})]}),(0,e.jsx)("div",{id:"tm-join-out",className:"team-inline-output",hidden:O.kind==="none",children:(0,e.jsx)(X,{status:O,tr:t})})]})]})}function ze(t){let{teams:a,tr:n}=t;return a.length?(0,e.jsx)(e.Fragment,{children:a.map(o=>{let m=(o.deployments||[]).filter(p=>!p.local).length,r=t.inviteStatuses.get(o.teamId)??{kind:"none"};return(0,e.jsxs)("div",{className:"card team-list-card team-manage-card",children:[(0,e.jsxs)("div",{className:"team-manage-head",children:[(0,e.jsx)("b",{children:o.name}),o.isDefault?(0,e.jsx)("span",{className:"team-status-pill muted",children:n("team.default")}):null,(0,e.jsxs)("span",{className:"team-meta-pill",children:[n("team.manageMetaDeps",{count:(o.deployments||[]).length}),m?n("team.manageMetaRemote",{r:m}):""," \xB7 ",n("team.manageMetaBots",{count:(o.bots||[]).length})]}),(0,e.jsxs)("span",{className:"team-manage-actions",children:[(0,e.jsx)("button",{className:"tm-invite ghost","data-team":o.teamId,onClick:()=>t.onInvite(o.teamId),children:n("team.genInvite")}),o.isDefault?null:(0,e.jsx)("button",{className:"tm-del ghost","data-team":o.teamId,"data-name":o.name,onClick:()=>t.onDelete(o.teamId,o.name),children:n("team.delBtn")})]})]}),(0,e.jsx)("div",{className:"tm-inv-out team-inline-output","data-team":o.teamId,hidden:r.kind==="none",children:(0,e.jsx)(X,{status:r,tr:n,suggestedHubUrl:t.suggestedHubUrl})})]},o.teamId)})}):(0,e.jsx)("p",{className:"muted",children:n("team.noTeamsShort")})}function X(t){let{status:a,tr:n}=t;if(a.kind==="none")return null;if(a.kind==="muted")return(0,e.jsx)("span",{className:"muted",children:n(a.key)});if(a.kind==="ok")return(0,e.jsx)("span",{className:"ok",children:n(a.key)});if(a.kind==="err")return(0,e.jsx)("span",{className:"err",children:n(a.key)});if(a.kind==="create-fail")return(0,e.jsx)("span",{className:"err",children:n("team.createFail",{error:a.error})});if(a.kind==="invite")return(0,e.jsxs)(e.Fragment,{children:[n("team.inviteResultLede"),(0,e.jsx)("br",{}),n("team.inviteHub"),(0,e.jsx)("code",{children:t.suggestedHubUrl||""}),(0,e.jsx)("br",{}),n("team.inviteCode"),(0,e.jsx)("code",{className:"team-invite-code",children:a.code})]});if(a.kind==="joined")return(0,e.jsx)("span",{className:"ok",children:n("team.joined",{name:a.name})});let o=a.error,m=o==="cannot_join_self"?n("team.joinErrSelf"):o==="deployment_already_joined"?n("team.joinErrAlready"):o==="hub_unreachable"?n("team.joinErrUnreachable"):o==="hub_timeout"?n("team.joinErrTimeout"):n("team.joinErrGeneric",{error:String(o)});return(0,e.jsx)("span",{className:"err",children:m})}function Xe(t){return K(t,(0,e.jsx)(He,{}))}function Ye(t){return K(t,(0,e.jsx)($e,{}))}export{Xe as renderTeamFederationPage,Ye as renderTeamManagePage};
1
+ import{a as G,b as J,c as S,d as re}from"./chunk-EVK77ASG.js";import{c as E}from"./chunk-VA6QWSGQ.js";import{a as oe,d as q,g as ie,q as se}from"./chunk-5CJMHTT4.js";import"./chunk-DLZK52JU.js";import{a as K}from"./chunk-SYC6D5XU.js";import{a as z,d as ne}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var d=L(z(),1);async function V(){return G("/api/team/hosted")}async function le(){return G("/api/team/remote-roster")}async function de(t,a){return re("/api/team/local-bots/"+encodeURIComponent(t)+"/capability",{capability:a})}async function me(t){return G("/api/team/local-bots/"+encodeURIComponent(t)+"/role")}async function ce(t){return S("/api/team/identity/auto-bind",t?{unionId:t}:void 0)}async function ue(t,a){return J("DELETE",`/api/team/hosted/${encodeURIComponent(t)}/members/${encodeURIComponent(a)}`)}async function pe(t,a,n){return S("/api/team/federated-group",{name:a,larkAppIds:n,teamId:t})}async function ge(t,a,n,o){return S("/api/team/remote-group",{hubUrl:t,teamId:a,name:n,larkAppIds:o})}async function ye(t){return S("/api/team/hosted",{name:t})}async function fe(t){return J("DELETE","/api/team/hosted/"+encodeURIComponent(t))}async function be(t){return S("/api/team/local-invite",{teamId:t})}async function ke(t,a){return S("/api/team/join-remote",{hubUrl:t,inviteCode:a})}function F(t,a){let n=a.query.trim().toLowerCase();return!(n&&!((t.name||"")+" "+(t.cliId||"")+" "+(t.capability||"")).toLowerCase().includes(n)||a.cliId&&t.cliId!==a.cliId||a.hasCapability&&!t.capability||a.hasRole&&!t.hasTeamRole)}function he(t){return Array.from(new Set(t.flatMap(a=>a.bots.map(n=>n.cliId)).filter(Boolean))).sort()}function ve(t,a){return(t.teams||[]).map(n=>({kind:"local",key:`local:${n.teamId}`,teamId:n.teamId,label:n.isDefault?a("team.myHostedTeam"):n.name,sub:"",ok:!0,deployments:n.deployments||[],bots:n.bots||[]}))}function Te(t,a){return(t.memberships||[]).map(o=>{let m=o.roster?.deployments||[],r=m.find(v=>v.local),p=r?.name?a("team.remoteTeamLabel",{name:r.name}):o.teamName||o.teamId;return{kind:"remote",key:`${o.hubUrl}::${o.teamId}`,teamId:o.teamId,label:p,sub:o.hubUrl,ok:!!o.ok,error:o.error,hubUrl:o.hubUrl,deployments:m,bots:o.roster?.bots||[]}})}function W(t,a,n){return t.map(o=>({...o,bots:o.bots.map(m=>m.larkAppId===a?{...m,capability:n.trim()||null}:m)}))}var e=L(ne(),1),we=L(z(),1);function Ie(){let t=(0,d.useRef)(!0);return(0,d.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Ce(t){let a=E(),n=t.active==="home",o=t.active==="manage";return(0,e.jsxs)("nav",{className:"team-subnav insight-tabs",role:"tablist","aria-label":a("team.eyebrow"),children:[(0,e.jsx)("a",{href:"#/team",className:`itab${n?" on":""}`,role:"tab","aria-selected":n,children:a("team.navHome")}),(0,e.jsx)("a",{href:"#/team/manage",className:`itab${o?" on":""}`,role:"tab","aria-selected":o,children:a("team.navManage")})]})}function Q(t,a){return t.get(a)??new Set}function He(){let t=E(),a=Ie(),[n,o]=(0,d.useState)([]),[m,r]=(0,d.useState)([]),[p,v]=(0,d.useState)(""),[N,T]=(0,d.useState)(t("team.unbound")),[u,R]=(0,d.useState)({query:"",cliId:"",hasCapability:!1,hasRole:!1}),[P,M]=(0,d.useState)(()=>new Map),[D,x]=(0,d.useState)(()=>new Map),[O,I]=(0,d.useState)(()=>new Set),[B,A]=(0,d.useState)(()=>new Set),[U,C]=(0,d.useState)({kind:"hidden"}),[j,c]=(0,d.useState)(()=>new Map),[g,h]=(0,d.useState)(null),y=(0,d.useMemo)(()=>[...n,...m],[n,m]),Y=(0,d.useMemo)(()=>he(y),[y]),Z=(0,d.useMemo)(()=>[{value:"",label:t("team.allCli")},...Y.map(i=>({value:i,label:i}))],[Y,t]),H=(0,d.useCallback)(async()=>{let i=await V();if(!a.current)return;let s=i.body;if(!s?.ok){o([]);return}v(s.deployment?.deploymentId??""),T(s.deployment?.ownerName||(s.deployment?.ownerUnionId?t("team.bound"):t("team.unbound"))),o(ve(s,t))},[a,t]),ee=(0,d.useCallback)(async()=>{let i=await le();a.current&&r(Te(i.body,t))},[a,t]);(0,d.useEffect)(()=>{M(new Map),x(new Map),I(new Set),A(new Set),H(),ee()},[H,ee]),(0,d.useEffect)(()=>{T(i=>i==="\u672A\u7ED1\u5B9A"||i==="Unbound"?t("team.unbound"):i)},[t]),(0,d.useEffect)(()=>{let i=new Map;for(let s of y)i.set(s.key,new Set(s.bots.filter(l=>F(l,u)).map(l=>l.larkAppId)));M(s=>{let l=!1,f=new Map;for(let[b,k]of s){let w=i.get(b),$=new Set([...k].filter(Ae=>w?.has(Ae)));$.size!==k.size&&(l=!0),$.size&&f.set(b,$)}return l?f:s})},[u,y]);let te=(0,d.useMemo)(()=>{if(!y.length)return"";let i=new Set,s=new Set;for(let b of y)b.bots.filter(w=>F(w,u)).forEach(w=>i.add(w.larkAppId)),b.bots.forEach(w=>s.add(w.larkAppId));let l=y.length>1?t("team.acrossTeams",{n:y.length}):"";return`\xB7 ${i.size===s.size?`${s.size}`:`${i.size} / ${s.size}`} ${t("team.botsWord")}${l}`},[u,y,t]);function _(i,s){c(l=>{let f=new Map(l);return f.set(i,s),f})}function Se(i,s,l){M(f=>{let b=new Map(f),k=new Set(b.get(i)??[]);return l?k.add(s):k.delete(s),k.size?b.set(i,k):b.delete(i),b})}function Me(i,s){x(l=>{let f=new Map(l);return s?f.set(i,s):f.delete(i),f})}async function xe(i,s){await de(i,s),a.current&&(o(l=>W(l,i,s)),r(l=>W(l,i,s)))}async function Be(i,s){let l=await me(i);a.current&&h({app:i,name:s,content:l.body?.role||""})}async function Pe(i,s,l){confirm(t("team.removeMemberConfirm",{name:l}))&&(await ue(i,s),a.current&&H())}async function De(i){let s=[...Q(P,i.key)];if(!s.length){_(i.key,{kind:"err",key:"team.errPickBot"});return}let l=(D.get(i.key)||"").trim()||t("team.defaultGroupName");_(i.key,{kind:"muted",key:"team.creatingGroup"});let f=i.kind==="local"?await pe(i.teamId,l,s):await ge(i.hubUrl,i.teamId,l,s);a.current&&(_(i.key,{kind:"group-result",body:f.body,status:f.status}),f.body?.ok&&(M(b=>{let k=new Map(b);return k.delete(i.key),k}),x(b=>{let k=new Map(b);return k.delete(i.key),k}),i.kind==="local"&&H()))}async function ae(i){C({kind:"loading",key:i?"team.binding":"team.identifying"});let s=await ce(i);if(!a.current)return;let l=s.body;if(l?.ok&&l.owner){C({kind:"ok",name:l.owner.name||l.owner.unionId||""}),H();return}if(l?.ok&&l.needChoice&&Array.isArray(l.candidates)){C({kind:"choice",candidates:l.candidates});return}if(l?.error==="no_candidates"){C({kind:"err",key:"team.noCandidates"});return}C({kind:"bind-fail",error:String(l?.error||"unknown")})}return(0,e.jsxs)("section",{className:"page team-page team-home-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.homeTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"home"})})]}),(0,e.jsxs)("section",{className:"overview-block team-identity-section",children:[(0,e.jsx)(q,{title:t("team.localDeployTitle"),hint:t("team.bindHint")}),(0,e.jsx)("div",{className:"card team-card team-identity-card",children:(0,e.jsxs)("p",{className:"team-identity-row",children:[(0,e.jsx)("span",{className:"team-identity-label",children:t("team.myIdentity")}),(0,e.jsx)("b",{id:"tf-owner",children:N}),(0,e.jsx)("button",{type:"button",id:"tf-autobind",className:"page-primary-action",onClick:()=>{ae()},children:t("team.bindBtn")}),(0,e.jsx)("span",{id:"tf-bind-out",className:"team-bind-status",hidden:U.kind==="hidden",children:(0,e.jsx)(Le,{state:U,tr:t,onPick:i=>{ae(i)}})})]})})]}),(0,e.jsxs)("section",{className:"overview-block team-roster-section",children:[(0,e.jsx)(q,{title:t("team.myTeams"),count:te?te.replace(/^·\s*/,""):void 0,hint:t("team.teamsHint")}),(0,e.jsxs)("div",{className:"card team-card team-roster-card",children:[(0,e.jsxs)("form",{className:"team-filters dashboard-toolbar",onSubmit:i=>i.preventDefault(),children:[(0,e.jsx)("input",{id:"tf-search",type:"search",placeholder:t("team.searchPh"),value:u.query,onChange:i=>R(s=>({...s,query:i.target.value}))}),(0,e.jsx)(se,{id:"tf-cli",className:"team-cli-menu",ariaLabel:t("team.allCli"),value:u.cliId,label:oe(Z,u.cliId),options:Z,onChange:i=>R(s=>({...s,cliId:i}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-fcap",checked:u.hasCapability,onChange:i=>R(s=>({...s,hasCapability:i.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasCap")})]}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-frole",checked:u.hasRole,onChange:i=>R(s=>({...s,hasRole:i.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasRole")})]})]}),(0,e.jsx)("div",{id:"tf-teams",children:(0,e.jsx)(Oe,{teams:y,filters:u,pickedByTeam:P,gnameByTeam:D,expandedTeams:O,expandedDeps:B,groupOutputs:j,myDeploymentId:p,tr:t,onToggleTeam:i=>I(s=>Ne(s,i)),onToggleDep:i=>A(s=>Ne(s,i)),onPick:Se,onGroupNameChange:Me,onCapabilityChange:(i,s)=>{xe(i,s)},onOpenRole:(i,s)=>{Be(i,s)},onRemoveMember:(i,s,l)=>{Pe(i,s,l)},onPullGroup:i=>{De(i)}})})]})]}),(0,e.jsx)(_e,{state:g,tr:t,onClose:()=>h(null)})]})}function Ne(t,a){let n=new Set(t);return n.has(a)?n.delete(a):n.add(a),n}function Le(t){let{state:a,tr:n}=t;return a.kind==="hidden"?null:a.kind==="loading"?(0,e.jsx)("span",{className:"team-bind-loading",children:n(a.key)}):a.kind==="ok"?(0,e.jsx)("span",{className:"ok",children:n("team.bound2",{name:a.name})}):a.kind==="choice"?(0,e.jsxs)(e.Fragment,{children:[n("team.multiCandidate"),(0,e.jsx)("br",{}),a.candidates.map(o=>(0,e.jsx)("button",{type:"button",className:"tf-pickowner ghost","data-union":o.unionId,style:{margin:"2px"},onClick:()=>t.onPick(o.unionId),children:o.name||o.unionId},o.unionId))]}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)("span",{className:"err",children:n("team.bindFail",{error:a.error})})}function Oe(t){let{tr:a}=t;return t.teams.length?(0,e.jsx)(e.Fragment,{children:t.teams.map(n=>{let o=n.bots.filter(p=>F(p,t.filters)),m=!t.expandedTeams.has(n.key),r=n.kind==="remote"?n.ok?(0,e.jsx)("span",{className:"team-status-pill ok",children:a("team.connected")}):(0,e.jsx)("span",{className:"team-status-pill err",children:a("team.connectFail",{error:n.error||""})}):(0,e.jsx)("span",{className:"team-status-pill muted",children:a("team.iHost")});return(0,e.jsxs)("article",{className:"card team-list-card",children:[(0,e.jsxs)("button",{type:"button",className:"tf-team-h","data-tk":n.key,"aria-expanded":!m,onClick:()=>t.onToggleTeam(n.key),children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:m?"\u203A":"\u2304"}),(0,e.jsx)("b",{children:n.label}),n.sub?(0,e.jsx)("span",{className:"muted",children:n.sub}):null,r,(0,e.jsx)("span",{className:"team-meta-pill",children:a("team.teamMeta",{deps:n.deployments.length,bots:n.bots.length})})]}),m?null:n.kind==="remote"&&!n.ok?(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:a("team.rosterFail")}):(0,e.jsx)(Ue,{...t,team:n,filtered:o})]},n.key)})}):(0,e.jsx)("p",{className:"muted",children:a("team.noTeams")})}function Ue(t){let{team:a,tr:n}=t,o=[...a.deployments].sort((r,p)=>r.local===p.local?0:r.local?-1:1),m=o.some(r=>t.filtered.some(p=>p.deployment.id===r.id));return(0,e.jsxs)(e.Fragment,{children:[o.map(r=>(0,we.createElement)(je,{...t,deployment:r,key:r.id})),m?null:(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:n("team.noMatch")}),(0,e.jsxs)("div",{className:"team-pull-row",children:[(0,e.jsxs)("label",{className:"team-pill-field team-group-name-field",children:[(0,e.jsx)("span",{children:n("team.gnameLabel")}),(0,e.jsx)("input",{className:"tf-gname","data-tk":a.key,value:t.gnameByTeam.get(a.key)||"",placeholder:n("team.gnamePlaceholder"),onChange:r=>t.onGroupNameChange(a.key,r.target.value)})]}),(0,e.jsx)("button",{className:"tf-grp page-primary-action","data-tk":a.key,onClick:()=>t.onPullGroup(a),children:n("team.pullGroupBtn")}),(0,e.jsx)("span",{className:"muted team-pull-hint",children:n("team.pullGroupHint")}),(0,e.jsx)("span",{className:"tf-gout","data-tk":a.key,children:(0,e.jsx)(Ge,{output:t.groupOutputs.get(a.key),tr:n})})]})]})}function je(t){let{team:a,deployment:n,tr:o}=t,m=t.filtered.filter(u=>u.deployment.id===n.id);if(!m.length)return null;let r=n.id===t.myDeploymentId,p=r?o("team.tagLocal"):n.stale?o("team.tagRemoteStale"):o("team.tagRemote"),v=`${a.key}::${n.id}`,N=t.expandedDeps.has(v),T=m.filter(u=>Q(t.pickedByTeam,a.key).has(u.larkAppId)).length;return(0,e.jsxs)("section",{className:"team-deployment-block",children:[(0,e.jsxs)("div",{className:"tf-dep-h","data-dk":v,"aria-expanded":N,role:"button",tabIndex:0,onClick:()=>t.onToggleDep(v),onKeyDown:u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),t.onToggleDep(v))},children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:N?"\u2304":"\u203A"}),(0,e.jsx)("b",{children:n.name}),(0,e.jsxs)("span",{className:"muted",children:[o("team.depTag",{tag:p})," \xB7 ",o("team.depCount",{count:m.length}),T?o("team.depSelected",{n:T}):""]}),a.kind==="local"&&!r?(0,e.jsx)("button",{type:"button",className:"tf-rmmember ghost","data-team":a.teamId,"data-dep":n.id,"data-name":n.name,onClick:u=>{u.stopPropagation(),t.onRemoveMember(a.teamId,n.id,n.name)},children:o("team.removeMember")}):null]}),N?(0,e.jsx)("div",{className:"team-roster-list",children:m.map(u=>(0,e.jsx)(Ee,{bot:u,mine:r,picked:Q(t.pickedByTeam,a.key).has(u.larkAppId),teamKey:a.key,tr:o,onPick:t.onPick,onCapabilityChange:t.onCapabilityChange,onOpenRole:t.onOpenRole},u.larkAppId))}):null]})}function Ee(t){let{bot:a,tr:n}=t,o=a.deployment.stale?{opacity:.55}:void 0,m=()=>t.onPick(t.teamKey,a.larkAppId,!t.picked);return(0,e.jsxs)("article",{className:`team-bot-row${t.picked?" selected":""}`,style:o,role:"checkbox","aria-checked":t.picked,tabIndex:0,onClick:r=>{Re(r.target)||m()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||Re(r.target)||(r.preventDefault(),m())},children:[(0,e.jsxs)("label",{className:`team-check-pill${t.picked?" selected":""}`,onClick:r=>r.stopPropagation(),children:[(0,e.jsx)("input",{type:"checkbox",className:"tf-pick","data-tk":t.teamKey,"data-app":a.larkAppId,checked:t.picked,onChange:r=>t.onPick(t.teamKey,a.larkAppId,r.target.checked)}),(0,e.jsx)("span",{className:"team-check-dot","aria-hidden":"true"})]}),(0,e.jsxs)("div",{className:"team-bot-main",children:[(0,e.jsx)("strong",{children:a.name}),(0,e.jsx)("span",{children:a.larkAppId})]}),(0,e.jsx)("span",{className:"team-meta-pill",children:a.cliId}),(0,e.jsx)("div",{className:"team-capability-cell",children:t.mine?(0,e.jsxs)("label",{className:"team-pill-field team-cap-field",children:[(0,e.jsx)("span",{children:n("team.capLabel")}),(0,e.jsx)("input",{className:"tf-cap","data-app":a.larkAppId,defaultValue:a.capability||"",placeholder:n("team.capPh"),onBlur:r=>{let p=r.target.value;p!==(a.capability||"")&&t.onCapabilityChange(a.larkAppId,p)},onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),r.currentTarget.blur())}})]}):a.capability||null}),(0,e.jsx)("div",{className:"team-role-cell",children:a.hasTeamRole?t.mine?(0,e.jsx)("button",{className:"tf-role","data-app":a.larkAppId,"data-name":a.name,onClick:()=>t.onOpenRole(a.larkAppId,a.name),children:n("team.viewRole")}):n("team.hasRoleShort"):(0,e.jsx)("span",{className:"muted",children:"\u2014"})})]})}function Re(t){return t instanceof HTMLElement?!!t.closest('button, input, textarea, select, a, label, [contenteditable="true"]'):!1}function Ge(t){let{output:a,tr:n}=t;return a?a.kind==="muted"?(0,e.jsx)("span",{className:"muted",children:n(a.key)}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)(Fe,{body:a.body,status:a.status,tr:n}):null}function Fe(t){let{body:a,status:n,tr:o}=t;if(a?.ok&&a.chatId){let p=a.shareLink||"https://applink.feishu.cn/client/chat/open?openChatId="+encodeURIComponent(a.chatId);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"ok",children:o("team.groupCreated")}),a.delegatedTo?o("team.delegatedBy",{name:String(a.delegatedTo)}):""," \xB7 ",(0,e.jsx)("a",{href:p,target:"_blank",rel:"noreferrer",children:o("team.openInLark")}),(a.invalidBotIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidBots",{ids:(a.invalidBotIds||[]).join(", ")})]}):null,(a.invalidOwnerUnionIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidOwners",{n:(a.invalidOwnerUnionIds||[]).length})]}):null,a.missingOperatorIdentity?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.missingIdentity")]}):null,(a.skippedNoOwner||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.skippedNoOwner",{n:(a.skippedNoOwner||[]).length})]}):null]})}let m=a?.error||n,r=m==="no_local_online_bot"?o("team.errNoLocalBot"):m==="all_bots_skipped_no_owner"?o("team.errAllSkipped"):m==="no_creator_available"?o("team.errNoCreator"):m==="delegation_timeout"?o("team.errDelegationTimeout"):o("team.errGroupCreate",{error:String(m)});return(0,e.jsx)("span",{className:"err",children:r})}function _e(t){let{state:a,tr:n}=t;return(0,e.jsx)("div",{id:"tf-modal",className:"team-role-modal","data-app":a?.app,hidden:!a,children:(0,e.jsxs)("div",{className:"team-role-dialog",children:[(0,e.jsx)("h2",{id:"tf-modal-title",children:a?n("team.roleModalTitleName",{name:a.name}):n("team.roleModalTitle")}),(0,e.jsx)("p",{className:"muted",style:{fontSize:"13px"},children:n("team.roleModalHint")}),(0,e.jsx)("textarea",{id:"tf-modal-text",readOnly:!0,value:a?.content??""}),(0,e.jsx)("div",{className:"team-role-actions",children:(0,e.jsx)("button",{type:"button",id:"tf-modal-cancel",onClick:t.onClose,children:n("team.close")})})]})})}function $e(){let t=E(),a=Ie(),[n,o]=(0,d.useState)([]),[m,r]=(0,d.useState)(""),[p,v]=(0,d.useState)(""),[N,T]=(0,d.useState)({kind:"none"}),[u,R]=(0,d.useState)(()=>new Map),[P,M]=(0,d.useState)(""),[D,x]=(0,d.useState)(""),[O,I]=(0,d.useState)({kind:"none"}),B=(0,d.useCallback)(async()=>{let c=await V();if(!a.current)return;let g=c.body;r(h=>g?.suggestedHubUrl||h),o(g?.teams||[])},[a]);(0,d.useEffect)(()=>{B()},[B]);async function A(){let c=p.trim();if(!c){T({kind:"err",key:"team.errName"});return}T({kind:"muted",key:"team.creating"});let g=await ye(c);a.current&&(g.body?.ok?(T({kind:"ok",key:"team.created"}),v(""),B()):T({kind:"create-fail",error:String(g.body?.error||g.status)}))}async function U(c){R(h=>{let y=new Map(h);return y.set(c,{kind:"muted",key:"team.generating"}),y});let g=await be(c);a.current&&R(h=>{let y=new Map(h);return y.set(c,g.body?.code?{kind:"invite",code:g.body.code}:{kind:"err",key:"team.genFail"}),y})}async function C(c,g){confirm(t("team.delConfirm",{name:g}))&&(await fe(c),a.current&&B())}async function j(){let c=P.trim(),g=D.trim();if(I({kind:"muted",key:"team.joining"}),!c||!g){I({kind:"err",key:"team.errHubCode"});return}let h=await ke(c,g);a.current&&(h.body?.ok?(I({kind:"joined",name:String(h.body.teamName||"")}),x("")):I({kind:"join-fail",error:h.body?.error||h.status}))}return(0,e.jsxs)("section",{className:"page team-page team-manage-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.manageTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"manage"})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.hostedTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar",onSubmit:c=>{c.preventDefault(),A()},children:[(0,e.jsx)("input",{id:"tm-newname",type:"text",placeholder:t("team.newTeamPh"),value:p,onChange:c=>v(c.target.value)}),(0,e.jsx)(ie,{id:"tm-create",className:"page-primary-action",onClick:()=>{A()},children:t("team.createTeamBtn")}),(0,e.jsx)("span",{className:"toolbar-status tm-cout",children:(0,e.jsx)(X,{status:N,tr:t})})]}),(0,e.jsx)("div",{id:"tm-list",children:(0,e.jsx)(ze,{teams:n,suggestedHubUrl:m,inviteStatuses:u,tr:t,onInvite:c=>{U(c)},onDelete:(c,g)=>{C(c,g)}})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.joinTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar team-join-form",onSubmit:c=>{c.preventDefault(),j()},children:[(0,e.jsx)("input",{id:"tm-hub",type:"text",placeholder:t("team.hubPh"),value:P,onChange:c=>M(c.target.value)}),(0,e.jsx)("input",{id:"tm-code",type:"text",placeholder:t("team.codePh"),value:D,onChange:c=>x(c.target.value)}),(0,e.jsx)("button",{type:"button",id:"tm-join",className:"page-primary-action",onClick:()=>{j()},children:t("team.joinBtn")})]}),(0,e.jsx)("div",{id:"tm-join-out",className:"team-inline-output",hidden:O.kind==="none",children:(0,e.jsx)(X,{status:O,tr:t})})]})]})}function ze(t){let{teams:a,tr:n}=t;return a.length?(0,e.jsx)(e.Fragment,{children:a.map(o=>{let m=(o.deployments||[]).filter(p=>!p.local).length,r=t.inviteStatuses.get(o.teamId)??{kind:"none"};return(0,e.jsxs)("div",{className:"card team-list-card team-manage-card",children:[(0,e.jsxs)("div",{className:"team-manage-head",children:[(0,e.jsx)("b",{children:o.name}),o.isDefault?(0,e.jsx)("span",{className:"team-status-pill muted",children:n("team.default")}):null,(0,e.jsxs)("span",{className:"team-meta-pill",children:[n("team.manageMetaDeps",{count:(o.deployments||[]).length}),m?n("team.manageMetaRemote",{r:m}):""," \xB7 ",n("team.manageMetaBots",{count:(o.bots||[]).length})]}),(0,e.jsxs)("span",{className:"team-manage-actions",children:[(0,e.jsx)("button",{className:"tm-invite ghost","data-team":o.teamId,onClick:()=>t.onInvite(o.teamId),children:n("team.genInvite")}),o.isDefault?null:(0,e.jsx)("button",{className:"tm-del ghost","data-team":o.teamId,"data-name":o.name,onClick:()=>t.onDelete(o.teamId,o.name),children:n("team.delBtn")})]})]}),(0,e.jsx)("div",{className:"tm-inv-out team-inline-output","data-team":o.teamId,hidden:r.kind==="none",children:(0,e.jsx)(X,{status:r,tr:n,suggestedHubUrl:t.suggestedHubUrl})})]},o.teamId)})}):(0,e.jsx)("p",{className:"muted",children:n("team.noTeamsShort")})}function X(t){let{status:a,tr:n}=t;if(a.kind==="none")return null;if(a.kind==="muted")return(0,e.jsx)("span",{className:"muted",children:n(a.key)});if(a.kind==="ok")return(0,e.jsx)("span",{className:"ok",children:n(a.key)});if(a.kind==="err")return(0,e.jsx)("span",{className:"err",children:n(a.key)});if(a.kind==="create-fail")return(0,e.jsx)("span",{className:"err",children:n("team.createFail",{error:a.error})});if(a.kind==="invite")return(0,e.jsxs)(e.Fragment,{children:[n("team.inviteResultLede"),(0,e.jsx)("br",{}),n("team.inviteHub"),(0,e.jsx)("code",{children:t.suggestedHubUrl||""}),(0,e.jsx)("br",{}),n("team.inviteCode"),(0,e.jsx)("code",{className:"team-invite-code",children:a.code})]});if(a.kind==="joined")return(0,e.jsx)("span",{className:"ok",children:n("team.joined",{name:a.name})});let o=a.error,m=o==="cannot_join_self"?n("team.joinErrSelf"):o==="deployment_already_joined"?n("team.joinErrAlready"):o==="hub_unreachable"?n("team.joinErrUnreachable"):o==="hub_timeout"?n("team.joinErrTimeout"):n("team.joinErrGeneric",{error:String(o)});return(0,e.jsx)("span",{className:"err",children:m})}function Xe(t){return K(t,(0,e.jsx)(He,{}))}function Ye(t){return K(t,(0,e.jsx)($e,{}))}export{Xe as renderTeamFederationPage,Ye as renderTeamManagePage};
@@ -1,4 +1,4 @@
1
- import{c as $}from"./chunk-FLGXZJTD.js";import{d as E}from"./chunk-QFMH6ITB.js";import{t as F}from"./chunk-KQB42ML5.js";import{a as O}from"./chunk-SYC6D5XU.js";import{a as re,d as V}from"./chunk-5THX4DI2.js";import{c as S}from"./chunk-7SZRL6FY.js";var l=S(re(),1);async function _(t=fetch){let e=await t("/api/v3/runs");if(!e.ok)return[];let o=await e.json();return Array.isArray(o.runs)?o.runs:[]}async function j(t,e=fetch){let o=await e(`/api/v3/runs/${encodeURIComponent(t)}`);return o.ok?{ok:!0,view:await o.json()}:{ok:!1,status:o.status}}async function J(t,e=fetch){let o=await e(`/api/v3/runs/${encodeURIComponent(t)}/cancel`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})}),s={};try{let a=await o.json();a&&typeof a=="object"&&!Array.isArray(a)&&(s=a)}catch{}if(!o.ok||s.ok===!1)return{ok:!1,status:o.status,error:typeof s.error=="string"?s.error:`http_${o.status}`};let r=s.status;return{ok:!0,...typeof s.runId=="string"?{runId:s.runId}:{},...ae(r)?{runStatus:r}:{},...s.alreadyTerminal===!0?{alreadyTerminal:!0}:{}}}function ae(t){return t==="running"||t==="cancelling"||t==="cancelled"||t==="succeeded"||t==="failed"||t==="blocked"}var I={pending:"\u5F85\u673A",gateWaiting:"\u7B49\u5BA1\u6279",running:"\u8FD0\u884C\u4E2D",done:"\u5B8C\u6210",skipped:"\u5DF2\u8DF3\u8FC7",cancelled:"\u5DF2\u53D6\u6D88",blocked:"\u53D7\u963B",superseded:"\u5DF2\u5237\u65B0",failed:"\u5931\u8D25"},X={exit:"\u2713 \u901A\u8FC7",continue:"\u21BB \u7EE7\u7EED\u8FD4\u5DE5",exhausted:"\u26D4 \u8F6E\u6570\u8017\u5C3D"},p={nodeWidth:168,plainHeight:48,loopHeight:70,columnGap:226,verticalGap:30,padding:26,maxDots:8},x={width:104,height:30,columnGap:138,rowGap:42,padding:6};function k(t){return t==="succeeded"||t==="failed"||t==="cancelled"}function W(t=typeof location<"u"?location.hash:""){let e=t.match(/^#\/workflows\/([^?#]+)/);if(!e)return null;try{return decodeURIComponent(e[1])}catch{return e[1]}}function L(t,e){return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function D(t){return t.isLoop?p.loopHeight:p.plainHeight}function C(t){return t.nodes.filter(e=>!e.loop)}function z(t){let e=C(t),o=ie(e),s=new Map;for(let i of e){let m=o.get(i.id)??0,u=s.get(m);u?u.push(i):s.set(m,[i])}let r=[...s.keys()].sort((i,m)=>i-m),a=[],d=new Map,c=0;for(let i of r){let m=s.get(i)??[],u=p.padding;for(let g of m){let v={node:g,x:p.padding+i*p.columnGap,y:u,width:p.nodeWidth,height:D(g)};a.push(v),d.set(g.id,v),u+=v.height+p.verticalGap}c=Math.max(c,u-p.verticalGap+p.padding)}let f=p.padding*2+(r.length===0?0:Math.max(...r)*p.columnGap+p.nodeWidth),w=new Map(e.map(i=>[i.id,i])),y=[];for(let i of e){let m=d.get(i.id);if(m)for(let u of i.depends){let g=d.get(u),v=w.get(u);if(!g||!v)continue;let N=g.x+p.nodeWidth,R=g.y+D(v)/2,b=m.x,M=m.y+D(i)/2;y.push({fromId:u,toId:i.id,x1:N,y1:R,x2:b,y2:M,mx:(N+b)/2,live:i.status==="running"})}}return{width:f,height:c,nodes:a,edges:y}}function ie(t){let e=new Map(t.map(a=>[a.id,a])),o=new Map,s=new Set;function r(a){if(o.has(a))return o.get(a);if(s.has(a))return 0;s.add(a);let c=(e.get(a)?.depends??[]).filter(w=>e.has(w)),f=c.length?1+Math.max(...c.map(r)):0;return s.delete(a),o.set(a,f),f}for(let a of t)r(a.id);return o}function U(t,e){return(t?.nodes??[]).filter(o=>o.loop?.loopId===e)}function q(t,e,o){if(o&&e){let r=t.find(a=>a.id===e);if(r)return r}let s=t.filter(r=>r.status==="running");return s[s.length-1]??t[t.length-1]??null}function Y(t){let e=new Map;for(let o of t){let s=o.loop?.iteration;if(s===void 0)continue;let r=e.get(s);r?r.push(o):e.set(s,[o])}return[...e.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({iteration:o,instances:s}))}function P(t){let e=t.loopState?.maxIterations;return t.loopState&&e!==void 0?e+t.loopState.granted:void 0}function K(t,e){let o=new Map(t.map(i=>[i.id,i])),s=new Map;function r(i){if(s.has(i))return s.get(i);s.set(i,0);let m=(o.get(i)?.depends??[]).filter(g=>o.has(g)),u=m.length?1+Math.max(...m.map(r)):0;return s.set(i,u),u}let a=new Map,d=0,c=[],f=new Map;for(let i of t){let m=r(i.id),u=a.get(m)??0;a.set(m,u+1),d=Math.max(d,u);let g={templateId:i.id,node:e.get(i.id),x:x.padding+m*x.columnGap,y:x.padding+u*x.rowGap,width:x.width,height:x.height};c.push(g),f.set(i.id,g)}let w=s.size?Math.max(...s.values()):0,y=[];for(let i of t){let m=f.get(i.id);if(m)for(let u of i.depends){let g=f.get(u);if(!g)continue;let v=g.x+x.width,N=g.y+x.height/2,R=m.x,b=m.y+x.height/2;y.push({fromId:u,toId:i.id,x1:v,y1:N,x2:R,y2:b,mx:(v+R)/2,live:e.get(i.id)?.status==="running"})}}return{width:x.padding*2+(t.length?w*x.columnGap+x.width:0),height:x.padding*2+d*x.rowGap+x.height,nodes:c,edges:y}}function H(t){let e=t.webTerminal;return`${e?.status??"-"}|${e?.sessionId??"-"}|${e?.webPort??"-"}|${t.hasPtyLog?"1":"0"}`}function Q(t,e,o){t.setAttribute("data-run-id",e),t.setAttribute("data-node-id",o.id),t.innerHTML=le(e,o).html}function le(t,e,o={}){let s=H(e),r=e.webTerminal;if(r?.status==="live"&&r.webPort&&r.webPort>0)return{kind:"live",signature:s,html:de(r.webPort,r.sessionId,o.host)};if(e.hasPtyLog)return{kind:"replay",signature:s,html:ue(t,e.id,r?.status==="closed")};let a=r?.status==="live"?"\u7EC8\u7AEF\u6B63\u5728\u542F\u52A8\uFF0C\u7A0D\u540E\u5237\u65B0":"\u6682\u65E0\u7EC8\u7AEF\u8BB0\u5F55";return{kind:"empty",signature:s,html:ce(a)}}function de(t,e,o){let s=me(t,o,e);return`<div class="v3-terminal-panel">
1
+ import{c as $}from"./chunk-VA6QWSGQ.js";import{d as E}from"./chunk-5CJMHTT4.js";import{t as F}from"./chunk-DLZK52JU.js";import{a as O}from"./chunk-SYC6D5XU.js";import{a as ae,d as V}from"./chunk-5THX4DI2.js";import{c as S}from"./chunk-7SZRL6FY.js";var l=S(ae(),1);async function _(t=fetch){let e=await t("/api/v3/runs");if(!e.ok)return[];let o=await e.json();return Array.isArray(o.runs)?o.runs:[]}async function j(t,e=fetch){let o=await e(`/api/v3/runs/${encodeURIComponent(t)}`);return o.ok?{ok:!0,view:await o.json()}:{ok:!1,status:o.status}}async function J(t,e=fetch){let o=await e(`/api/v3/runs/${encodeURIComponent(t)}/cancel`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})}),s={};try{let r=await o.json();r&&typeof r=="object"&&!Array.isArray(r)&&(s=r)}catch{}if(!o.ok||s.ok===!1)return{ok:!1,status:o.status,error:typeof s.error=="string"?s.error:`http_${o.status}`};let a=s.status;return{ok:!0,...typeof s.runId=="string"?{runId:s.runId}:{},...re(a)?{runStatus:a}:{},...s.alreadyTerminal===!0?{alreadyTerminal:!0}:{}}}function re(t){return t==="running"||t==="cancelling"||t==="cancelled"||t==="succeeded"||t==="failed"||t==="blocked"}var I={pending:"\u5F85\u673A",gateWaiting:"\u7B49\u5BA1\u6279",running:"\u8FD0\u884C\u4E2D",done:"\u5B8C\u6210",skipped:"\u5DF2\u8DF3\u8FC7",cancelled:"\u5DF2\u53D6\u6D88",blocked:"\u53D7\u963B",superseded:"\u5DF2\u5237\u65B0",failed:"\u5931\u8D25"},X={exit:"\u2713 \u901A\u8FC7",continue:"\u21BB \u7EE7\u7EED\u8FD4\u5DE5",exhausted:"\u26D4 \u8F6E\u6570\u8017\u5C3D"},p={nodeWidth:168,plainHeight:48,loopHeight:70,columnGap:226,verticalGap:30,padding:26,maxDots:8},x={width:104,height:30,columnGap:138,rowGap:42,padding:6};function k(t){return t==="succeeded"||t==="failed"||t==="cancelled"}function W(t=typeof location<"u"?location.hash:""){let e=t.match(/^#\/workflows\/([^?#]+)/);if(!e)return null;try{return decodeURIComponent(e[1])}catch{return e[1]}}function L(t,e){return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function D(t){return t.isLoop?p.loopHeight:p.plainHeight}function C(t){return t.nodes.filter(e=>!e.loop)}function z(t){let e=C(t),o=ie(e),s=new Map;for(let i of e){let m=o.get(i.id)??0,c=s.get(m);c?c.push(i):s.set(m,[i])}let a=[...s.keys()].sort((i,m)=>i-m),r=[],d=new Map,u=0;for(let i of a){let m=s.get(i)??[],c=p.padding;for(let g of m){let v={node:g,x:p.padding+i*p.columnGap,y:c,width:p.nodeWidth,height:D(g)};r.push(v),d.set(g.id,v),c+=v.height+p.verticalGap}u=Math.max(u,c-p.verticalGap+p.padding)}let f=p.padding*2+(a.length===0?0:Math.max(...a)*p.columnGap+p.nodeWidth),w=new Map(e.map(i=>[i.id,i])),y=[];for(let i of e){let m=d.get(i.id);if(m)for(let c of i.depends){let g=d.get(c),v=w.get(c);if(!g||!v)continue;let N=g.x+p.nodeWidth,R=g.y+D(v)/2,b=m.x,M=m.y+D(i)/2;y.push({fromId:c,toId:i.id,x1:N,y1:R,x2:b,y2:M,mx:(N+b)/2,live:i.status==="running"})}}return{width:f,height:u,nodes:r,edges:y}}function ie(t){let e=new Map(t.map(r=>[r.id,r])),o=new Map,s=new Set;function a(r){if(o.has(r))return o.get(r);if(s.has(r))return 0;s.add(r);let u=(e.get(r)?.depends??[]).filter(w=>e.has(w)),f=u.length?1+Math.max(...u.map(a)):0;return s.delete(r),o.set(r,f),f}for(let r of t)a(r.id);return o}function U(t,e){return(t?.nodes??[]).filter(o=>o.loop?.loopId===e)}function q(t,e,o){if(o&&e){let a=t.find(r=>r.id===e);if(a)return a}let s=t.filter(a=>a.status==="running");return s[s.length-1]??t[t.length-1]??null}function Y(t){let e=new Map;for(let o of t){let s=o.loop?.iteration;if(s===void 0)continue;let a=e.get(s);a?a.push(o):e.set(s,[o])}return[...e.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({iteration:o,instances:s}))}function P(t){let e=t.loopState?.maxIterations;return t.loopState&&e!==void 0?e+t.loopState.granted:void 0}function K(t,e){let o=new Map(t.map(i=>[i.id,i])),s=new Map;function a(i){if(s.has(i))return s.get(i);s.set(i,0);let m=(o.get(i)?.depends??[]).filter(g=>o.has(g)),c=m.length?1+Math.max(...m.map(a)):0;return s.set(i,c),c}let r=new Map,d=0,u=[],f=new Map;for(let i of t){let m=a(i.id),c=r.get(m)??0;r.set(m,c+1),d=Math.max(d,c);let g={templateId:i.id,node:e.get(i.id),x:x.padding+m*x.columnGap,y:x.padding+c*x.rowGap,width:x.width,height:x.height};u.push(g),f.set(i.id,g)}let w=s.size?Math.max(...s.values()):0,y=[];for(let i of t){let m=f.get(i.id);if(m)for(let c of i.depends){let g=f.get(c);if(!g)continue;let v=g.x+x.width,N=g.y+x.height/2,R=m.x,b=m.y+x.height/2;y.push({fromId:c,toId:i.id,x1:v,y1:N,x2:R,y2:b,mx:(v+R)/2,live:e.get(i.id)?.status==="running"})}}return{width:x.padding*2+(t.length?w*x.columnGap+x.width:0),height:x.padding*2+d*x.rowGap+x.height,nodes:u,edges:y}}function H(t){let e=t.webTerminal;return`${e?.status??"-"}|${e?.sessionId??"-"}|${e?.webPort??"-"}|${t.hasPtyLog?"1":"0"}`}function Q(t,e,o){t.setAttribute("data-run-id",e),t.setAttribute("data-node-id",o.id),t.innerHTML=le(e,o).html}function le(t,e,o={}){let s=H(e),a=e.webTerminal;if(a?.status==="live"&&a.webPort&&a.webPort>0)return{kind:"live",signature:s,html:de(a.webPort,a.sessionId,o.host)};if(e.hasPtyLog)return{kind:"replay",signature:s,html:ce(t,e.id,a?.status==="closed")};let r=a?.status==="live"?"\u7EC8\u7AEF\u6B63\u5728\u542F\u52A8\uFF0C\u7A0D\u540E\u5237\u65B0":"\u6682\u65E0\u7EC8\u7AEF\u8BB0\u5F55";return{kind:"empty",signature:s,html:ue(r)}}function de(t,e,o){let s=me(t,o,e);return`<div class="v3-terminal-panel">
2
2
  <div class="v3-terminal-head">
3
3
  <span class="v3-terminal-dot live"></span>
4
4
  <span>\u5B9E\u65F6\u7EC8\u7AEF\uFF08\u53EA\u8BFB\uFF09</span>
@@ -6,15 +6,15 @@ import{c as $}from"./chunk-FLGXZJTD.js";import{d as E}from"./chunk-QFMH6ITB.js";
6
6
  <a class="btn-link" href="${T(s)}" target="_blank" rel="noopener">\u65B0\u7A97\u53E3\u6253\u5F00</a>
7
7
  </div>
8
8
  <iframe class="v3-terminal-frame" src="${T(s)}" title="v3 live terminal" loading="lazy"></iframe>
9
- </div>`}function ue(t,e,o){let s=`/api/v3/runs/${encodeURIComponent(t)}/nodes/${encodeURIComponent(e)}/pty-log`,r=fe(s,`${t} / ${e}`);return`<div class="v3-terminal-panel">
9
+ </div>`}function ce(t,e,o){let s=`/api/v3/runs/${encodeURIComponent(t)}/nodes/${encodeURIComponent(e)}/pty-log`,a=fe(s,`${t} / ${e}`);return`<div class="v3-terminal-panel">
10
10
  <div class="v3-terminal-head">
11
11
  <span class="v3-terminal-dot ${o?"closed":"replay"}"></span>
12
12
  <span>${o?"\u7EC8\u7AEF\u56DE\u653E":"\u7EC8\u7AEF\u8BB0\u5F55"}</span>
13
13
  <span class="muted">PTY log</span>
14
14
  <a class="btn-link" href="${T(s)}" target="_blank" rel="noopener">\u4E0B\u8F7D/\u6253\u5F00\u539F\u59CB\u65E5\u5FD7</a>
15
15
  </div>
16
- <iframe class="v3-terminal-frame" srcdoc="${T(r)}" title="v3 terminal replay" loading="lazy"></iframe>
17
- </div>`}function ce(t){return`<div class="v3-terminal-empty muted">${G(t)}</div>`}function me(t,e,o){return o&&typeof window<"u"&&window.location.protocol==="https:"?`${window.location.origin}/s/${encodeURIComponent(o)}`:`http://${e??pe()}:${t}/`}function pe(){return typeof window>"u"?"127.0.0.1":window.location.hostname||"127.0.0.1"}function fe(t,e){let o=JSON.stringify(t);return`<!doctype html>
16
+ <iframe class="v3-terminal-frame" srcdoc="${T(a)}" title="v3 terminal replay" loading="lazy"></iframe>
17
+ </div>`}function ue(t){return`<div class="v3-terminal-empty muted">${G(t)}</div>`}function me(t,e,o){return o&&typeof window<"u"&&window.location.protocol==="https:"?`${window.location.origin}/s/${encodeURIComponent(o)}`:`http://${e??pe()}:${t}/`}function pe(){return typeof window>"u"?"127.0.0.1":window.location.hostname||"127.0.0.1"}function fe(t,e){let o=JSON.stringify(t);return`<!doctype html>
18
18
  <html>
19
19
  <head>
20
20
  <meta charset="utf-8">
@@ -91,4 +91,4 @@ import{c as $}from"./chunk-FLGXZJTD.js";import{d as E}from"./chunk-QFMH6ITB.js";
91
91
  })();
92
92
  <\/script>
93
93
  </body>
94
- </html>`}function G(t){return t.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function T(t){return G(t).replace(/`/g,"&#96;")}var n=S(V(),1);function ee(){return typeof document<"u"&&document.hidden}function ge(){let[t,e]=(0,l.useState)([]);return(0,l.useEffect)(()=>{let o=!1,s=null,r=()=>{s=window.setTimeout(()=>{a()},2e3)};async function a(){if(!o){if(!ee())try{let d=await _();o||e(d)}catch{}o||r()}}return a(),()=>{o=!0,s!==null&&window.clearTimeout(s)}},[]),t}function ve(t){let[e,o]=(0,l.useState)(null),[s,r]=(0,l.useState)("");return(0,l.useEffect)(()=>{let a=!1,d=null,c=()=>{d=window.setTimeout(()=>{f()},2e3)};async function f(){if(a)return;let w=!1;if(!ee())try{let y=await j(t);if(a)return;y.ok?(o(y.view),r(y.view.runStatus),w=k(y.view.runStatus)):r(y.status===404?"not found":`HTTP ${y.status}`)}catch{}!a&&!w&&c()}return f(),()=>{a=!0,d!==null&&window.clearTimeout(d)}},[t]),{view:e,statusText:s}}function he(){let t=$(),e=ge(),o=(0,n.jsx)("div",{className:"page-heading-actions v3r-run-toolbar",children:(0,n.jsx)("span",{className:"v3r-run-count",children:e.length})});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"page-heading",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"eyebrow",children:t("nav.workflows")}),(0,n.jsx)("h1",{children:t("nav.workflows")})]}),o]}),(0,n.jsx)("section",{className:"overview-block v3r-runs-section",children:(0,n.jsx)("div",{className:"v3r-run-list",children:e.length?e.map(s=>(0,n.jsxs)("a",{className:"v3r-run-card",href:`#/workflows/${encodeURIComponent(s.runId)}`,children:[(0,n.jsxs)("span",{className:"v3r-run-main",children:[(0,n.jsx)("code",{className:"v3r-runid",children:s.runId}),(0,n.jsxs)("small",{children:["\u8282\u70B9 ",s.nodeCount]})]}),(0,n.jsx)("span",{className:`v3r-pill rs-${s.runStatus}`,children:s.runStatus})]},s.runId)):(0,n.jsxs)("div",{className:"empty v3r-empty",children:["\u6682\u65E0\u5DE5\u4F5C\u6D41\u8FD0\u884C\uFF08\u7528 ",(0,n.jsx)("code",{children:"/workflow new"})," \u53D1\u8D77\u4E00\u4E2A\uFF09"]})})})]})}function we(t){let e=$(),{view:o,statusText:s}=ve(t.runId),[r,a]=(0,l.useState)(null),[d,c]=(0,l.useState)(null),[f,w]=(0,l.useState)(!1),[y,i]=(0,l.useState)(!1),[m,u]=(0,l.useState)(!1),[g,v]=(0,l.useState)(null);(0,l.useEffect)(()=>{a(null),c(null),w(!1),i(!1),u(!1),v(null)},[t.runId]),(0,l.useEffect)(()=>{o?.runStatus==="cancelling"?(u(!0),v(e("workflow.v3.cancelPending"))):o?.runStatus==="cancelled"?(u(!1),v(e("workflow.v3.cancelled"))):k(o?.runStatus)&&u(!1)},[e,o?.runStatus]),(0,l.useEffect)(()=>{o&&a(h=>h&&o.nodes.some(oe=>oe.id===h)?h:C(o)[0]?.id??o.nodes[0]?.id??null)},[o]);let N=(0,l.useCallback)(h=>{a(h),c(null),w(!1)},[]),R=(0,l.useCallback)(h=>{c(h),w(!0)},[]),b=o?.nodes.find(h=>h.id===r)??null,M=o?`v3r-pill rs-${o.runStatus}`:"v3r-pill",A=k(o?.runStatus),B=y||m||o?.runStatus==="cancelling",se=(0,l.useCallback)(async()=>{if(!(!o||A||B)&&window.confirm(e("workflow.v3.cancelConfirm",{runId:t.runId}))){i(!0),v(null);try{let h=await J(t.runId);if(!h.ok){v(h.status===401?e("workflow.v3.cancelAuthRequired"):e("workflow.v3.cancelFailed",{error:h.error}));return}v(h.runStatus==="cancelled"?e("workflow.v3.cancelled"):h.alreadyTerminal?e("workflow.v3.cancelAlreadyTerminal"):e("workflow.v3.cancelPending")),u(h.runStatus!=="cancelled"&&h.alreadyTerminal!==!0)}catch{v(e("workflow.v3.cancelFailed",{error:"network_error"}))}finally{i(!1)}}},[B,t.runId,A,e,o]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"page-heading v3r-detail-heading",children:[(0,n.jsxs)("div",{className:"v3r-title-row",children:[(0,n.jsx)("p",{className:"eyebrow",children:e("nav.workflows")}),(0,n.jsxs)("a",{href:"#/workflows",className:"btn-link v3r-back-link",children:["\u2190 ",e("nav.workflows")]}),(0,n.jsx)("h1",{children:t.runId}),(0,n.jsx)("span",{className:`${M} v3r-run-status-pill`,children:s})]}),(0,n.jsx)("div",{className:"page-heading-actions",children:(0,n.jsx)(ye,{runStatus:o?.runStatus,busy:y||m,onCancel:()=>{se()}})})]}),g?(0,n.jsx)("div",{className:`v3r-cancel-notice${o?.runStatus==="cancelled"?" done":""}`,role:"status",children:g}):null,(0,n.jsxs)("div",{className:"v3r-wrap",children:[(0,n.jsxs)("section",{className:"overview-block v3r-graph-section",children:[(0,n.jsx)(E,{title:"\u8FD0\u884C\u62D3\u6251",hint:o?`${o.nodes.length} \u4E2A\u8282\u70B9`:s}),(0,n.jsxs)("div",{className:"v3r-graph-card",children:[(0,n.jsx)(be,{view:o,selectedId:r,onSelect:N}),(0,n.jsx)(xe,{})]})]}),(0,n.jsxs)("section",{className:"overview-block v3r-node-section",children:[(0,n.jsx)(E,{title:"\u8282\u70B9\u8BE6\u60C5",hint:b?(0,n.jsxs)("span",{className:`v3r-pill v3r-node-status-pill st-${b.status}`,children:[(0,n.jsx)("i",{className:"dot"}),I[b.status]]}):"\u9009\u62E9\u4E00\u4E2A\u8282\u70B9"}),(0,n.jsx)(Se,{runId:t.runId,view:o,node:b,instanceId:d,instancePinned:f,onInstanceSelect:R})]})]})]})}function ye(t){let e=$();if(!F.authed)return null;let o=k(t.runStatus),s=t.busy||t.runStatus==="cancelling";return(0,n.jsx)("button",{type:"button",className:"danger v3r-cancel-button",disabled:!t.runStatus||o||s,title:e(o?"workflow.v3.cancelTerminal":"workflow.v3.cancelTitle"),onClick:t.onCancel,children:e(s?"workflow.v3.cancelling":o?"workflow.v3.cancelTerminal":"workflow.v3.cancel")})}function xe(){return(0,n.jsxs)("div",{className:"v3r-legend",children:[(0,n.jsx)("span",{className:"lg st-pending",children:"\u5F85\u673A"}),(0,n.jsx)("span",{className:"lg st-running",children:"\u8FD0\u884C\u4E2D"}),(0,n.jsx)("span",{className:"lg st-gateWaiting",children:"\u7B49\u5BA1\u6279"}),(0,n.jsx)("span",{className:"lg st-done",children:"\u5B8C\u6210"}),(0,n.jsx)("span",{className:"lg st-skipped",children:"\u5DF2\u8DF3\u8FC7"}),(0,n.jsx)("span",{className:"lg st-cancelled",children:"\u5DF2\u53D6\u6D88"}),(0,n.jsx)("span",{className:"lg st-blocked",children:"\u53D7\u963B"}),(0,n.jsx)("span",{className:"lg st-failed",children:"\u5931\u8D25"}),(0,n.jsx)("span",{className:"lg lg-loop",children:"\u27F3 \u5FAA\u73AF\u5BB9\u5668"})]})}function be(t){let e=(0,l.useMemo)(()=>t.view?z(t.view):null,[t.view]),o=e?`${e.width}:${e.height}:${e.nodes.map(r=>r.node.id).join("\0")}`:"",s=(0,l.useRef)(null);return(0,l.useLayoutEffect)(()=>{let r=s.current;if(!r||!o)return;let a=0,d=()=>{a=0,r.scrollLeft=Math.max(0,(r.scrollWidth-r.clientWidth)/2),r.scrollTop=Math.max(0,(r.scrollHeight-r.clientHeight)/2)},c=()=>{a&&window.cancelAnimationFrame(a),a=window.requestAnimationFrame(d)};c();let f=typeof ResizeObserver>"u"?null:new ResizeObserver(c);f?.observe(r);let w=r.querySelector(".v3r-graph-stage");return w&&f?.observe(w),()=>{a&&window.cancelAnimationFrame(a),f?.disconnect()}},[o]),(0,n.jsx)("div",{id:"v3-graph",className:"v3r-graph",ref:s,children:e?(0,n.jsx)("div",{className:"v3r-graph-stage",children:(0,n.jsxs)("svg",{width:e.width,height:e.height,viewBox:`0 0 ${e.width} ${e.height}`,children:[(0,n.jsx)("defs",{children:(0,n.jsx)("marker",{id:"v3arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:(0,n.jsx)("path",{d:"M0,0 L10,5 L0,10 z",fill:"var(--faint, #8b98aa)"})})}),e.edges.map(r=>(0,n.jsx)("path",{className:`v3r-edge${r.live?" live":""}`,d:`M${r.x1},${r.y1} C${r.mx},${r.y1} ${r.mx},${r.y2} ${r.x2},${r.y2}`,markerEnd:"url(#v3arrow)"},`${r.fromId}->${r.toId}`)),e.nodes.map(r=>(0,n.jsx)(Ne,{box:r,selected:r.node.id===t.selectedId,onSelect:t.onSelect},r.node.id))]})}):null})}function Ne(t){let{box:e,selected:o}=t,s=e.node;return s.isLoop?(0,n.jsx)(Re,{box:e,selected:o,onSelect:t.onSelect}):(0,n.jsxs)("g",{className:`v3r-node st-${s.status}${o?" sel":""}`,"data-node":s.id,onClick:()=>t.onSelect(s.id),children:[(0,n.jsx)("rect",{className:"v3r-box",x:e.x,y:e.y,width:p.nodeWidth,height:p.plainHeight,rx:"10"}),(0,n.jsx)("text",{className:"v3r-nid",x:e.x+14,y:e.y+20,children:L(s.id,18)}),(0,n.jsx)("text",{className:"v3r-nstatus",x:e.x+14,y:e.y+37,children:I[s.status]})]})}function Re(t){let{box:e,selected:o}=t,s=e.node,r=s.loopState,a=P(s),d=r?`${I[s.status]} \xB7 \u7B2C${r.iteration}${a!==void 0?`/${a}`:""}\u8F6E`:`${I[s.status]} \xB7 loop`,c=r?.maxIterations;return(0,n.jsxs)("g",{className:`v3r-node v3r-loopnode st-${s.status}${o?" sel":""}`,"data-node":s.id,onClick:()=>t.onSelect(s.id),children:[(0,n.jsx)("rect",{className:"v3r-cap",x:e.x-4,y:e.y-4,width:p.nodeWidth+8,height:p.loopHeight+8,rx:"14"}),(0,n.jsx)("rect",{className:"v3r-box",x:e.x,y:e.y,width:p.nodeWidth,height:p.loopHeight,rx:"10"}),(0,n.jsx)("text",{className:"v3r-spin",x:e.x+14,y:e.y+21,children:"\u27F3"}),(0,n.jsx)("text",{className:"v3r-nid",x:e.x+30,y:e.y+21,children:L(s.id,16)}),(0,n.jsx)("text",{className:"v3r-nstatus",x:e.x+14,y:e.y+39,children:d}),r&&a!==void 0&&a<=p.maxDots?(0,n.jsx)(Ie,{node:s,x:e.x,y:e.y,budget:a,maxIterations:c}):null]})}function Ie(t){let e=t.node.loopState,o=t.y+p.loopHeight-13,s=Array.from({length:t.budget},(r,a)=>a+1);return(0,n.jsxs)(n.Fragment,{children:[s.map(r=>{let a=r<e.iteration?"v3r-dot done":r===e.iteration?`v3r-dot cur${t.node.status==="running"?" live":""}`:"v3r-dot todo",d=t.maxIterations!==void 0&&r>t.maxIterations?" grant":"";return(0,n.jsx)("circle",{className:`${a}${d}`,cx:t.x+14+(r-1)*15,cy:o,r:"3.6"},r)}),e.lastDecision==="exit"?(0,n.jsx)("text",{className:"v3r-dots-verdict ok",x:t.x+14+t.budget*15+4,y:o+4,children:"\u2713"}):null,e.lastDecision==="exhausted"&&t.node.status==="blocked"?(0,n.jsx)("text",{className:"v3r-dots-verdict warn",x:t.x+14+t.budget*15+4,y:o+4,children:"\u26A0"}):null]})}function Se(t){let e=t.node,o=(0,l.useMemo)(()=>e?.isLoop?U(t.view,e.id):[],[e,t.view]),s=e?.isLoop?q(o,t.instanceId,t.instancePinned):e,r=e?.isLoop?s?.id??null:null;return e?(0,n.jsxs)("div",{id:"v3-node-panel",className:"v3r-panel",children:[(0,n.jsxs)("div",{id:"v3-node-meta",children:[e.goal?(0,n.jsx)("p",{className:"v3r-goal",children:e.goal}):null,e.depends.length?(0,n.jsxs)("p",{className:"v3r-deps",children:[(0,n.jsx)("span",{children:"\u4F9D\u8D56"}),e.depends.map(a=>(0,n.jsx)("span",{className:"v3r-dep",children:a},a))]}):null,e.errorClass?(0,n.jsx)(ke,{node:e}):null,e.isLoop?(0,n.jsx)($e,{runId:t.runId,node:e,instances:o,activeInstanceId:r,onInstanceSelect:t.onInstanceSelect}):null]}),(0,n.jsx)("div",{id:"v3-inst-strip",children:e.isLoop&&s?(0,n.jsx)(Ve,{node:s,auto:!t.instancePinned}):null}),(0,n.jsx)(Te,{runId:t.runId,node:s})]}):(0,n.jsx)("div",{id:"v3-node-panel",className:"v3r-panel",children:(0,n.jsx)("p",{className:"muted",children:"\u70B9\u4E00\u4E2A\u8282\u70B9\u770B\u8BE6\u60C5\u4E0E\u7EC8\u7AEF"})})}function ke(t){let e=t.node;return(0,n.jsxs)("p",{className:"v3r-err",children:["\u539F\u56E0\uFF1A",e.errorClass,e.errorCode?` (${e.errorCode})`:"",e.status==="blocked"&&!e.isLoop?(0,n.jsxs)(n.Fragment,{children:[" \u2014 \u98DE\u4E66\u5361\u7247\u6216 ",(0,n.jsx)("code",{children:"botmux workflow retry"})," \u53EF\u91CD\u8BD5"]}):null]})}function Ve(t){let e=t.node.loop;return(0,n.jsxs)("div",{className:"v3r-inst-strip",children:[(0,n.jsx)("span",{className:"lbl",children:"\u5B9E\u4F8B\u7EC8\u7AEF"}),(0,n.jsx)("span",{className:"v3r-nodeid sm",children:t.node.id}),(0,n.jsxs)("span",{className:`v3r-pill st-${t.node.status}`,children:[(0,n.jsx)("i",{className:"dot"}),I[t.node.status]]}),(0,n.jsxs)("span",{className:"muted",children:["\u7B2C ",e.iteration," \u8F6E \xB7 ",e.bodyNodeId,t.auto?" \xB7 \u81EA\u52A8\u8DDF\u968F":""]})]})}function $e(t){let e=t.node.loopState;if(!e)return(0,n.jsx)("p",{className:"muted",children:"loop \u672A\u5F00\u59CB"});let o=P(t.node),s=new Map(e.decisions.map(a=>[a.iteration,a.decision])),r=Y(t.instances);return(0,n.jsxs)("div",{className:"v3r-loop-sec",children:[(0,n.jsxs)("div",{className:"v3r-loop-meter",children:[(0,n.jsxs)("span",{className:"num",children:["\u7B2C ",(0,n.jsx)("b",{children:e.iteration}),o!==void 0?(0,n.jsxs)(n.Fragment,{children:[" / ",(0,n.jsx)("b",{children:o})]}):null," \u8F6E"]}),e.granted>0?(0,n.jsxs)("span",{className:"v3r-granted-tag",children:["\u542B\u4EBA\u5DE5\u8FFD\u52A0 +",e.granted]}):null,e.lastDecision==="exit"?(0,n.jsx)("span",{className:"v3r-verdict vd-exit",children:"\u2713 \u5DF2\u6536\u655B"}):null]}),(0,n.jsx)("div",{className:"v3r-rounds",children:r.map(a=>{let d=s.get(a.iteration),c=a.iteration===e.iteration,f=e.maxIterations!==void 0&&a.iteration>e.maxIterations;return(0,n.jsxs)("div",{className:`v3r-round${c?" cur":""}${d?` vd-${d}`:""}`,children:[(0,n.jsxs)("div",{className:"v3r-round-head",children:[(0,n.jsxs)("span",{className:"rn",children:["R",a.iteration]}),f?(0,n.jsx)("span",{className:"v3r-granted-tag",children:"\u2795 \u8FFD\u52A0\u8F6E"}):null,d?(0,n.jsx)("span",{className:`v3r-verdict vd-${d}`,children:X[d]}):c&&t.node.status==="running"?(0,n.jsx)("span",{className:"v3r-verdict vd-live",children:"\u25B6 \u8FDB\u884C\u4E2D"}):null]}),(0,n.jsx)(Le,{template:e.bodyTemplate,instances:a.instances,activeInstanceId:t.activeInstanceId,onInstanceSelect:t.onInstanceSelect})]},a.iteration)})}),t.node.status==="blocked"?(0,n.jsxs)("div",{className:"v3r-cta",children:["\u26A0 \u8F6E\u6570\u8017\u5C3D\uFF0C\u7B49\u4EBA\u8FFD\u52A0 \u2014 \u98DE\u4E66\u5361\u7247\u70B9\u300C\u2795 \u8FFD\u52A0 1 \u8F6E\u300D\uFF0C\u6216 ",(0,n.jsxs)("code",{children:["botmux workflow grant ",t.runId]})]}):null]})}function Le(t){let e=(0,l.useMemo)(()=>new Map(t.instances.map(s=>[s.loop.bodyNodeId,s])),[t.instances]),o=(0,l.useMemo)(()=>K(t.template,e),[t.template,e]);return(0,n.jsxs)("svg",{className:"v3r-mini-svg",width:o.width,height:o.height,viewBox:`0 0 ${o.width} ${o.height}`,children:[(0,n.jsx)("defs",{children:(0,n.jsx)("marker",{id:"v3arrow-mini",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:(0,n.jsx)("path",{d:"M0,0 L10,5 L0,10 z",fill:"var(--faint, #8b98aa)"})})}),o.edges.map(s=>(0,n.jsx)("path",{className:`v3r-edge${s.live?" live":""}`,d:`M${s.x1},${s.y1} C${s.mx},${s.y1} ${s.mx},${s.y2} ${s.x2},${s.y2}`,markerEnd:"url(#v3arrow-mini)"},`${s.fromId}->${s.toId}`)),o.nodes.map(s=>{let r=s.node,a=r?.status??"pending",d=r?.id===t.activeInstanceId;return(0,n.jsxs)("g",{className:`v3r-node v3r-mini st-${a}${d?" sel":""}${r?"":" ghost"}`,"data-sel":r?.id,style:r?{cursor:"pointer"}:void 0,onClick:c=>{r&&(c.stopPropagation(),t.onInstanceSelect(r.id))},children:[(0,n.jsx)("rect",{className:"v3r-box",x:s.x,y:s.y,width:s.width,height:s.height,rx:"8"}),(0,n.jsx)("circle",{className:"v3r-mini-dot",cx:s.x+13,cy:s.y+s.height/2,r:"3.4"}),(0,n.jsx)("text",{className:"v3r-nid",x:s.x+24,y:s.y+s.height/2+4,children:L(s.templateId,12)})]},s.templateId)})]})}function Te(t){let e=(0,l.useRef)(null),o=(0,l.useRef)(null),s=t.node?`${t.runId}|${t.node.id}|${H(t.node)}`:null;return(0,l.useEffect)(()=>{let r=e.current;if(r){if(!t.node||!s){r.innerHTML="",o.current=null;return}o.current!==s&&(Q(r,t.runId,t.node),o.current=s)}},[t.runId,t.node,s]),(0,n.jsx)("div",{id:"v3-term-slot",className:"v3r-term-slot",ref:e})}function te(){let t=W();return(0,n.jsx)("section",{className:"page workflows-page v3-page",children:t?(0,n.jsx)(we,{runId:t}):(0,n.jsx)(he,{})})}var ne=S(V(),1);function je(t){return O(t,(0,ne.jsx)(te,{}))}export{je as renderV3RunsPage};
94
+ </html>`}function G(t){return t.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function T(t){return G(t).replace(/`/g,"&#96;")}var n=S(V(),1);function ee(){return typeof document<"u"&&document.hidden}function ge(){let[t,e]=(0,l.useState)([]);return(0,l.useEffect)(()=>{let o=!1,s=null,a=()=>{s=window.setTimeout(()=>{r()},2e3)};async function r(){if(!o){if(!ee())try{let d=await _();o||e(d)}catch{}o||a()}}return r(),()=>{o=!0,s!==null&&window.clearTimeout(s)}},[]),t}function ve(t){let[e,o]=(0,l.useState)(null),[s,a]=(0,l.useState)("");return(0,l.useEffect)(()=>{let r=!1,d=null,u=()=>{d=window.setTimeout(()=>{f()},2e3)};async function f(){if(r)return;let w=!1;if(!ee())try{let y=await j(t);if(r)return;y.ok?(o(y.view),a(y.view.runStatus),w=k(y.view.runStatus)):a(y.status===404?"not found":`HTTP ${y.status}`)}catch{}!r&&!w&&u()}return f(),()=>{r=!0,d!==null&&window.clearTimeout(d)}},[t]),{view:e,statusText:s}}function he(){let t=$(),e=ge(),o=(0,n.jsx)("div",{className:"page-heading-actions v3r-run-toolbar",children:(0,n.jsx)("span",{className:"v3r-run-count",children:e.length})});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"page-heading",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"eyebrow",children:t("nav.workflows")}),(0,n.jsx)("h1",{children:t("nav.workflows")})]}),o]}),(0,n.jsx)("section",{className:"overview-block v3r-runs-section",children:(0,n.jsx)("div",{className:"v3r-run-list",children:e.length?e.map(s=>(0,n.jsxs)("a",{className:"v3r-run-card",href:`#/workflows/${encodeURIComponent(s.runId)}`,children:[(0,n.jsxs)("span",{className:"v3r-run-main",children:[(0,n.jsx)("code",{className:"v3r-runid",children:s.runId}),(0,n.jsxs)("small",{children:["\u8282\u70B9 ",s.nodeCount]})]}),(0,n.jsx)("span",{className:`v3r-pill rs-${s.runStatus}`,children:s.runStatus})]},s.runId)):(0,n.jsxs)("div",{className:"empty v3r-empty",children:["\u6682\u65E0\u5DE5\u4F5C\u6D41\u8FD0\u884C\uFF08\u7528 ",(0,n.jsx)("code",{children:"/workflow new"})," \u53D1\u8D77\u4E00\u4E2A\uFF09"]})})})]})}function we(t){let e=$(),{view:o,statusText:s}=ve(t.runId),[a,r]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[f,w]=(0,l.useState)(!1),[y,i]=(0,l.useState)(!1),[m,c]=(0,l.useState)(!1),[g,v]=(0,l.useState)(null);(0,l.useEffect)(()=>{r(null),u(null),w(!1),i(!1),c(!1),v(null)},[t.runId]),(0,l.useEffect)(()=>{o?.runStatus==="cancelling"?(c(!0),v(e("workflow.v3.cancelPending"))):o?.runStatus==="cancelled"?(c(!1),v(e("workflow.v3.cancelled"))):k(o?.runStatus)&&c(!1)},[e,o?.runStatus]),(0,l.useEffect)(()=>{o&&r(h=>h&&o.nodes.some(oe=>oe.id===h)?h:C(o)[0]?.id??o.nodes[0]?.id??null)},[o]);let N=(0,l.useCallback)(h=>{r(h),u(null),w(!1)},[]),R=(0,l.useCallback)(h=>{u(h),w(!0)},[]),b=o?.nodes.find(h=>h.id===a)??null,M=o?`v3r-pill rs-${o.runStatus}`:"v3r-pill",A=k(o?.runStatus),B=y||m||o?.runStatus==="cancelling",se=(0,l.useCallback)(async()=>{if(!(!o||A||B)&&window.confirm(e("workflow.v3.cancelConfirm",{runId:t.runId}))){i(!0),v(null);try{let h=await J(t.runId);if(!h.ok){v(h.status===401?e("workflow.v3.cancelAuthRequired"):e("workflow.v3.cancelFailed",{error:h.error}));return}v(h.runStatus==="cancelled"?e("workflow.v3.cancelled"):h.alreadyTerminal?e("workflow.v3.cancelAlreadyTerminal"):e("workflow.v3.cancelPending")),c(h.runStatus!=="cancelled"&&h.alreadyTerminal!==!0)}catch{v(e("workflow.v3.cancelFailed",{error:"network_error"}))}finally{i(!1)}}},[B,t.runId,A,e,o]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"page-heading v3r-detail-heading",children:[(0,n.jsxs)("div",{className:"v3r-title-row",children:[(0,n.jsx)("p",{className:"eyebrow",children:e("nav.workflows")}),(0,n.jsxs)("a",{href:"#/workflows",className:"btn-link v3r-back-link",children:["\u2190 ",e("nav.workflows")]}),(0,n.jsx)("h1",{children:t.runId}),(0,n.jsx)("span",{className:`${M} v3r-run-status-pill`,children:s})]}),(0,n.jsx)("div",{className:"page-heading-actions",children:(0,n.jsx)(ye,{runStatus:o?.runStatus,busy:y||m,onCancel:()=>{se()}})})]}),g?(0,n.jsx)("div",{className:`v3r-cancel-notice${o?.runStatus==="cancelled"?" done":""}`,role:"status",children:g}):null,(0,n.jsxs)("div",{className:"v3r-wrap",children:[(0,n.jsxs)("section",{className:"overview-block v3r-graph-section",children:[(0,n.jsx)(E,{title:"\u8FD0\u884C\u62D3\u6251",hint:o?`${o.nodes.length} \u4E2A\u8282\u70B9`:s}),(0,n.jsxs)("div",{className:"v3r-graph-card",children:[(0,n.jsx)(be,{view:o,selectedId:a,onSelect:N}),(0,n.jsx)(xe,{})]})]}),(0,n.jsxs)("section",{className:"overview-block v3r-node-section",children:[(0,n.jsx)(E,{title:"\u8282\u70B9\u8BE6\u60C5",hint:b?(0,n.jsxs)("span",{className:`v3r-pill v3r-node-status-pill st-${b.status}`,children:[(0,n.jsx)("i",{className:"dot"}),I[b.status]]}):"\u9009\u62E9\u4E00\u4E2A\u8282\u70B9"}),(0,n.jsx)(Se,{runId:t.runId,view:o,node:b,instanceId:d,instancePinned:f,onInstanceSelect:R})]})]})]})}function ye(t){let e=$();if(!F.authed)return null;let o=k(t.runStatus),s=t.busy||t.runStatus==="cancelling";return(0,n.jsx)("button",{type:"button",className:"danger v3r-cancel-button",disabled:!t.runStatus||o||s,title:e(o?"workflow.v3.cancelTerminal":"workflow.v3.cancelTitle"),onClick:t.onCancel,children:e(s?"workflow.v3.cancelling":o?"workflow.v3.cancelTerminal":"workflow.v3.cancel")})}function xe(){return(0,n.jsxs)("div",{className:"v3r-legend",children:[(0,n.jsx)("span",{className:"lg st-pending",children:"\u5F85\u673A"}),(0,n.jsx)("span",{className:"lg st-running",children:"\u8FD0\u884C\u4E2D"}),(0,n.jsx)("span",{className:"lg st-gateWaiting",children:"\u7B49\u5BA1\u6279"}),(0,n.jsx)("span",{className:"lg st-done",children:"\u5B8C\u6210"}),(0,n.jsx)("span",{className:"lg st-skipped",children:"\u5DF2\u8DF3\u8FC7"}),(0,n.jsx)("span",{className:"lg st-cancelled",children:"\u5DF2\u53D6\u6D88"}),(0,n.jsx)("span",{className:"lg st-blocked",children:"\u53D7\u963B"}),(0,n.jsx)("span",{className:"lg st-failed",children:"\u5931\u8D25"}),(0,n.jsx)("span",{className:"lg lg-loop",children:"\u27F3 \u5FAA\u73AF\u5BB9\u5668"})]})}function be(t){let e=(0,l.useMemo)(()=>t.view?z(t.view):null,[t.view]),o=e?`${e.width}:${e.height}:${e.nodes.map(a=>a.node.id).join("\0")}`:"",s=(0,l.useRef)(null);return(0,l.useLayoutEffect)(()=>{let a=s.current;if(!a||!o)return;let r=0,d=()=>{r=0,a.scrollLeft=Math.max(0,(a.scrollWidth-a.clientWidth)/2),a.scrollTop=Math.max(0,(a.scrollHeight-a.clientHeight)/2)},u=()=>{r&&window.cancelAnimationFrame(r),r=window.requestAnimationFrame(d)};u();let f=typeof ResizeObserver>"u"?null:new ResizeObserver(u);f?.observe(a);let w=a.querySelector(".v3r-graph-stage");return w&&f?.observe(w),()=>{r&&window.cancelAnimationFrame(r),f?.disconnect()}},[o]),(0,n.jsx)("div",{id:"v3-graph",className:"v3r-graph",ref:s,children:e?(0,n.jsx)("div",{className:"v3r-graph-stage",children:(0,n.jsxs)("svg",{width:e.width,height:e.height,viewBox:`0 0 ${e.width} ${e.height}`,children:[(0,n.jsx)("defs",{children:(0,n.jsx)("marker",{id:"v3arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:(0,n.jsx)("path",{d:"M0,0 L10,5 L0,10 z",fill:"var(--faint, #8b98aa)"})})}),e.edges.map(a=>(0,n.jsx)("path",{className:`v3r-edge${a.live?" live":""}`,d:`M${a.x1},${a.y1} C${a.mx},${a.y1} ${a.mx},${a.y2} ${a.x2},${a.y2}`,markerEnd:"url(#v3arrow)"},`${a.fromId}->${a.toId}`)),e.nodes.map(a=>(0,n.jsx)(Ne,{box:a,selected:a.node.id===t.selectedId,onSelect:t.onSelect},a.node.id))]})}):null})}function Ne(t){let{box:e,selected:o}=t,s=e.node;return s.isLoop?(0,n.jsx)(Re,{box:e,selected:o,onSelect:t.onSelect}):(0,n.jsxs)("g",{className:`v3r-node st-${s.status}${o?" sel":""}`,"data-node":s.id,onClick:()=>t.onSelect(s.id),children:[(0,n.jsx)("rect",{className:"v3r-box",x:e.x,y:e.y,width:p.nodeWidth,height:p.plainHeight,rx:"10"}),(0,n.jsx)("text",{className:"v3r-nid",x:e.x+14,y:e.y+20,children:L(s.id,18)}),(0,n.jsx)("text",{className:"v3r-nstatus",x:e.x+14,y:e.y+37,children:I[s.status]})]})}function Re(t){let{box:e,selected:o}=t,s=e.node,a=s.loopState,r=P(s),d=a?`${I[s.status]} \xB7 \u7B2C${a.iteration}${r!==void 0?`/${r}`:""}\u8F6E`:`${I[s.status]} \xB7 loop`,u=a?.maxIterations;return(0,n.jsxs)("g",{className:`v3r-node v3r-loopnode st-${s.status}${o?" sel":""}`,"data-node":s.id,onClick:()=>t.onSelect(s.id),children:[(0,n.jsx)("rect",{className:"v3r-cap",x:e.x-4,y:e.y-4,width:p.nodeWidth+8,height:p.loopHeight+8,rx:"14"}),(0,n.jsx)("rect",{className:"v3r-box",x:e.x,y:e.y,width:p.nodeWidth,height:p.loopHeight,rx:"10"}),(0,n.jsx)("text",{className:"v3r-spin",x:e.x+14,y:e.y+21,children:"\u27F3"}),(0,n.jsx)("text",{className:"v3r-nid",x:e.x+30,y:e.y+21,children:L(s.id,16)}),(0,n.jsx)("text",{className:"v3r-nstatus",x:e.x+14,y:e.y+39,children:d}),a&&r!==void 0&&r<=p.maxDots?(0,n.jsx)(Ie,{node:s,x:e.x,y:e.y,budget:r,maxIterations:u}):null]})}function Ie(t){let e=t.node.loopState,o=t.y+p.loopHeight-13,s=Array.from({length:t.budget},(a,r)=>r+1);return(0,n.jsxs)(n.Fragment,{children:[s.map(a=>{let r=a<e.iteration?"v3r-dot done":a===e.iteration?`v3r-dot cur${t.node.status==="running"?" live":""}`:"v3r-dot todo",d=t.maxIterations!==void 0&&a>t.maxIterations?" grant":"";return(0,n.jsx)("circle",{className:`${r}${d}`,cx:t.x+14+(a-1)*15,cy:o,r:"3.6"},a)}),e.lastDecision==="exit"?(0,n.jsx)("text",{className:"v3r-dots-verdict ok",x:t.x+14+t.budget*15+4,y:o+4,children:"\u2713"}):null,e.lastDecision==="exhausted"&&t.node.status==="blocked"?(0,n.jsx)("text",{className:"v3r-dots-verdict warn",x:t.x+14+t.budget*15+4,y:o+4,children:"\u26A0"}):null]})}function Se(t){let e=t.node,o=(0,l.useMemo)(()=>e?.isLoop?U(t.view,e.id):[],[e,t.view]),s=e?.isLoop?q(o,t.instanceId,t.instancePinned):e,a=e?.isLoop?s?.id??null:null;return e?(0,n.jsxs)("div",{id:"v3-node-panel",className:"v3r-panel",children:[(0,n.jsxs)("div",{id:"v3-node-meta",children:[e.goal?(0,n.jsx)("p",{className:"v3r-goal",children:e.goal}):null,e.depends.length?(0,n.jsxs)("p",{className:"v3r-deps",children:[(0,n.jsx)("span",{children:"\u4F9D\u8D56"}),e.depends.map(r=>(0,n.jsx)("span",{className:"v3r-dep",children:r},r))]}):null,e.errorClass?(0,n.jsx)(ke,{node:e}):null,e.isLoop?(0,n.jsx)($e,{runId:t.runId,node:e,instances:o,activeInstanceId:a,onInstanceSelect:t.onInstanceSelect}):null]}),(0,n.jsx)("div",{id:"v3-inst-strip",children:e.isLoop&&s?(0,n.jsx)(Ve,{node:s,auto:!t.instancePinned}):null}),(0,n.jsx)(Te,{runId:t.runId,node:s})]}):(0,n.jsx)("div",{id:"v3-node-panel",className:"v3r-panel",children:(0,n.jsx)("p",{className:"muted",children:"\u70B9\u4E00\u4E2A\u8282\u70B9\u770B\u8BE6\u60C5\u4E0E\u7EC8\u7AEF"})})}function ke(t){let e=t.node;return(0,n.jsxs)("p",{className:"v3r-err",children:["\u539F\u56E0\uFF1A",e.errorClass,e.errorCode?` (${e.errorCode})`:"",e.status==="blocked"&&!e.isLoop?(0,n.jsxs)(n.Fragment,{children:[" \u2014 \u98DE\u4E66\u5361\u7247\u6216 ",(0,n.jsx)("code",{children:"botmux workflow retry"})," \u53EF\u91CD\u8BD5"]}):null]})}function Ve(t){let e=t.node.loop;return(0,n.jsxs)("div",{className:"v3r-inst-strip",children:[(0,n.jsx)("span",{className:"lbl",children:"\u5B9E\u4F8B\u7EC8\u7AEF"}),(0,n.jsx)("span",{className:"v3r-nodeid sm",children:t.node.id}),(0,n.jsxs)("span",{className:`v3r-pill st-${t.node.status}`,children:[(0,n.jsx)("i",{className:"dot"}),I[t.node.status]]}),(0,n.jsxs)("span",{className:"muted",children:["\u7B2C ",e.iteration," \u8F6E \xB7 ",e.bodyNodeId,t.auto?" \xB7 \u81EA\u52A8\u8DDF\u968F":""]})]})}function $e(t){let e=t.node.loopState;if(!e)return(0,n.jsx)("p",{className:"muted",children:"loop \u672A\u5F00\u59CB"});let o=P(t.node),s=new Map(e.decisions.map(r=>[r.iteration,r.decision])),a=Y(t.instances);return(0,n.jsxs)("div",{className:"v3r-loop-sec",children:[(0,n.jsxs)("div",{className:"v3r-loop-meter",children:[(0,n.jsxs)("span",{className:"num",children:["\u7B2C ",(0,n.jsx)("b",{children:e.iteration}),o!==void 0?(0,n.jsxs)(n.Fragment,{children:[" / ",(0,n.jsx)("b",{children:o})]}):null," \u8F6E"]}),e.granted>0?(0,n.jsxs)("span",{className:"v3r-granted-tag",children:["\u542B\u4EBA\u5DE5\u8FFD\u52A0 +",e.granted]}):null,e.lastDecision==="exit"?(0,n.jsx)("span",{className:"v3r-verdict vd-exit",children:"\u2713 \u5DF2\u6536\u655B"}):null]}),(0,n.jsx)("div",{className:"v3r-rounds",children:a.map(r=>{let d=s.get(r.iteration),u=r.iteration===e.iteration,f=e.maxIterations!==void 0&&r.iteration>e.maxIterations;return(0,n.jsxs)("div",{className:`v3r-round${u?" cur":""}${d?` vd-${d}`:""}`,children:[(0,n.jsxs)("div",{className:"v3r-round-head",children:[(0,n.jsxs)("span",{className:"rn",children:["R",r.iteration]}),f?(0,n.jsx)("span",{className:"v3r-granted-tag",children:"\u2795 \u8FFD\u52A0\u8F6E"}):null,d?(0,n.jsx)("span",{className:`v3r-verdict vd-${d}`,children:X[d]}):u&&t.node.status==="running"?(0,n.jsx)("span",{className:"v3r-verdict vd-live",children:"\u25B6 \u8FDB\u884C\u4E2D"}):null]}),(0,n.jsx)(Le,{template:e.bodyTemplate,instances:r.instances,activeInstanceId:t.activeInstanceId,onInstanceSelect:t.onInstanceSelect})]},r.iteration)})}),t.node.status==="blocked"?(0,n.jsxs)("div",{className:"v3r-cta",children:["\u26A0 \u8F6E\u6570\u8017\u5C3D\uFF0C\u7B49\u4EBA\u8FFD\u52A0 \u2014 \u98DE\u4E66\u5361\u7247\u70B9\u300C\u2795 \u8FFD\u52A0 1 \u8F6E\u300D\uFF0C\u6216 ",(0,n.jsxs)("code",{children:["botmux workflow grant ",t.runId]})]}):null]})}function Le(t){let e=(0,l.useMemo)(()=>new Map(t.instances.map(s=>[s.loop.bodyNodeId,s])),[t.instances]),o=(0,l.useMemo)(()=>K(t.template,e),[t.template,e]);return(0,n.jsxs)("svg",{className:"v3r-mini-svg",width:o.width,height:o.height,viewBox:`0 0 ${o.width} ${o.height}`,children:[(0,n.jsx)("defs",{children:(0,n.jsx)("marker",{id:"v3arrow-mini",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:(0,n.jsx)("path",{d:"M0,0 L10,5 L0,10 z",fill:"var(--faint, #8b98aa)"})})}),o.edges.map(s=>(0,n.jsx)("path",{className:`v3r-edge${s.live?" live":""}`,d:`M${s.x1},${s.y1} C${s.mx},${s.y1} ${s.mx},${s.y2} ${s.x2},${s.y2}`,markerEnd:"url(#v3arrow-mini)"},`${s.fromId}->${s.toId}`)),o.nodes.map(s=>{let a=s.node,r=a?.status??"pending",d=a?.id===t.activeInstanceId;return(0,n.jsxs)("g",{className:`v3r-node v3r-mini st-${r}${d?" sel":""}${a?"":" ghost"}`,"data-sel":a?.id,style:a?{cursor:"pointer"}:void 0,onClick:u=>{a&&(u.stopPropagation(),t.onInstanceSelect(a.id))},children:[(0,n.jsx)("rect",{className:"v3r-box",x:s.x,y:s.y,width:s.width,height:s.height,rx:"8"}),(0,n.jsx)("circle",{className:"v3r-mini-dot",cx:s.x+13,cy:s.y+s.height/2,r:"3.4"}),(0,n.jsx)("text",{className:"v3r-nid",x:s.x+24,y:s.y+s.height/2+4,children:L(s.templateId,12)})]},s.templateId)})]})}function Te(t){let e=(0,l.useRef)(null),o=(0,l.useRef)(null),s=t.node?`${t.runId}|${t.node.id}|${H(t.node)}`:null;return(0,l.useEffect)(()=>{let a=e.current;if(a){if(!t.node||!s){a.innerHTML="",o.current=null;return}o.current!==s&&(Q(a,t.runId,t.node),o.current=s)}},[t.runId,t.node,s]),(0,n.jsx)("div",{id:"v3-term-slot",className:"v3r-term-slot",ref:e})}function te(){let t=W();return(0,n.jsx)("section",{className:"page workflows-page v3-page",children:t?(0,n.jsx)(we,{runId:t}):(0,n.jsx)(he,{})})}var ne=S(V(),1);function je(t){return O(t,(0,ne.jsx)(te,{}))}export{je as renderV3RunsPage};
@@ -1 +1 @@
1
- import{c as B}from"./chunk-FLGXZJTD.js";import{c as W,j as C}from"./chunk-QFMH6ITB.js";import"./chunk-KQB42ML5.js";import{a as P}from"./chunk-SYC6D5XU.js";import{a as O,d as T}from"./chunk-5THX4DI2.js";import{c as R}from"./chunk-7SZRL6FY.js";var r=R(O(),1);var e=R(T(),1);function x(t){let a=Date.parse(t);if(!a)return t||"-";let o=Math.max(0,Math.floor((Date.now()-a)/1e3));if(o<60)return`${o}s ago`;let i=Math.floor(o/60);if(i<60)return`${i}m ago`;let n=Math.floor(i/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function F(t){return t.chatId?.trim()||"__local__"}function G(t,a){if(t==="__local__")return"\u672A\u7ED1\u5B9A\u7FA4 / \u672C\u5730\u767D\u677F";let o=a.get(t);return o&&o!==t?`${o} (${t})`:t}function K(t,a){let o=new Map;for(let i of t){let n=F(i),c=o.get(n)??[];c.push(i),o.set(n,c)}return[...o.entries()].map(([i,n])=>({chatId:i,label:G(i,a),rows:[...n].sort((c,b)=>b.updatedAt.localeCompare(c.updatedAt))})).sort((i,n)=>i.label.localeCompare(n.label))}function z(){return decodeURIComponent((location.hash.match(/^#\/whiteboards\/([^/]+)/)?.[1]??"").trim())}async function E(t,a){let o=await fetch(`/api/whiteboards/${encodeURIComponent(t)}`),i=await o.json().catch(()=>({}));if(o.ok)return{id:t,content:String(i.content??""),row:a.find(n=>n.id===t)}}async function J(t){let a=new Map;if(!t?.ok)return a;let o=await t.json().catch(()=>({})),i=Array.isArray(o.chats)?o.chats:[];for(let n of i)n.chatId&&a.set(String(n.chatId),String(n.name||n.chatId));return a}function Q(t){let a=t.row,o=a.title||a.id;return(0,e.jsxs)("a",{className:`wb-item${t.active?" active":""}`,"data-whiteboard-id":a.id,href:`#/whiteboards/${encodeURIComponent(a.id)}`,onClick:i=>{i.preventDefault(),t.onSelect(a.id)},children:[(0,e.jsx)("div",{className:"wb-item-head",children:(0,e.jsxs)("div",{className:"wb-item-main",children:[(0,e.jsx)("strong",{children:(0,e.jsx)(C,{text:o,textClassName:"wb-title-scroll"})}),(0,e.jsx)("span",{className:"wb-id-text",title:a.id,children:a.id})]})}),(0,e.jsxs)("div",{className:"wb-item-foot",children:[(0,e.jsxs)("div",{className:"wb-item-meta",children:[(0,e.jsx)("span",{children:x(a.updatedAt)}),(0,e.jsx)("span",{children:"\xB7"}),(0,e.jsxs)("span",{children:["log ",a.logCount]})]}),(0,e.jsx)("span",{className:"wb-scope",title:a.scope,children:a.scope})]})]})}function p(t){let a=t.value||"-";return(0,e.jsxs)("div",{className:"wb-meta-card",title:a,children:[(0,e.jsx)("span",{children:t.label}),(0,e.jsx)("strong",{children:a})]})}function V(t){let a=t.selected;if(!a)return(0,e.jsx)("p",{className:"empty",children:"\u9009\u62E9\u5DE6\u4FA7\u767D\u677F\u67E5\u770B meta \u548C board.md\u3002"});let o=a.row,i=o?.chatId?G(o.chatId,t.groupNames):"\u672A\u7ED1\u5B9A\u7FA4 / \u672C\u5730\u767D\u677F",n=o?.title||a.id;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"wb-detail-head",children:[(0,e.jsxs)("div",{className:"wb-detail-title",children:[(0,e.jsx)("p",{className:"eyebrow",children:"WHITEBOARD"}),(0,e.jsx)("h2",{title:n,children:n}),(0,e.jsx)("code",{title:a.id,children:a.id})]}),(0,e.jsx)("button",{type:"button",className:"danger","data-delete-whiteboard":!0,onClick:t.onDelete,children:"\u5220\u9664\u767D\u677F"})]}),(0,e.jsxs)("div",{className:"wb-meta-grid",children:[(0,e.jsx)(p,{label:"\u6240\u5C5E\u7FA4",value:i}),(0,e.jsx)(p,{label:"\u8303\u56F4",value:o?.scope??"-"}),(0,e.jsx)(p,{label:"\u6700\u8FD1\u66F4\u65B0",value:o?.updatedAt?x(o.updatedAt):"-"}),(0,e.jsx)(p,{label:"\u6765\u6E90\u76EE\u5F55",value:o?.workingDir??"-"})]}),(0,e.jsxs)("details",{className:"wb-admin-info",children:[(0,e.jsx)("summary",{children:"\u7BA1\u7406\u4FE1\u606F / \u6587\u4EF6\u8DEF\u5F84"}),(0,e.jsx)("code",{children:o?.path??""})]}),(0,e.jsxs)("section",{className:"wb-board-panel",children:[(0,e.jsxs)("div",{className:"wb-board-panel-head",children:[(0,e.jsx)("strong",{children:"board.md"}),(0,e.jsx)("span",{children:"\u53EA\u8BFB\u9884\u89C8"})]}),(0,e.jsx)("pre",{children:a.content||"\uFF08\u6682\u65E0\u5185\u5BB9\uFF09"})]})]})}function X(t){let a=t.selected.row?.title||t.selected.id;return(0,e.jsx)("div",{className:"wb-delete-backdrop","data-delete-modal":!0,onClick:o=>{o.target===o.currentTarget&&t.onCancel()},children:(0,e.jsxs)("div",{className:"wb-delete-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"wb-delete-title",children:[(0,e.jsxs)("div",{className:"wb-delete-body",children:[(0,e.jsx)("div",{className:"wb-delete-mark","aria-hidden":"true",children:"!"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{id:"wb-delete-title",children:"\u5220\u9664\u767D\u677F\uFF1F"}),(0,e.jsxs)("p",{children:["\u5C06\u5220\u9664 ",(0,e.jsx)("strong",{children:a}),"\uFF08",(0,e.jsx)("code",{children:t.selected.id}),"\uFF09\u7684 board\u3001log\u3001meta\uFF0C\u5E76\u6E05\u7406\u9ED8\u8BA4\u7ED1\u5B9A\u548C\u4F1A\u8BDD\u5F15\u7528\u3002\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002"]})]})]}),(0,e.jsxs)("div",{className:"actions wb-delete-actions",children:[(0,e.jsx)("button",{type:"button","data-delete-cancel":!0,onClick:t.onCancel,disabled:t.deleting,children:"\u53D6\u6D88"}),(0,e.jsx)("button",{type:"button",className:"danger","data-delete-confirm":!0,onClick:t.onConfirm,disabled:t.deleting,children:t.deleting?"\u5220\u9664\u4E2D...":"\u786E\u8BA4\u5220\u9664"})]})]})})}function Y(){let t=B(),a=(0,r.useRef)(!1),o=(0,r.useRef)(0),[i,n]=(0,r.useState)(!1),[c,b]=(0,r.useState)([]),[g,_]=(0,r.useState)(()=>new Map),[m,f]=(0,r.useState)(),[H,S]=(0,r.useState)(!0),[k,M]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[L,D]=(0,r.useState)(!1),I=(0,r.useMemo)(()=>K(c,g),[c,g]);(0,r.useEffect)(()=>{a.current=!0;let s=z();async function d(){S(!0);try{let[l,y]=await Promise.all([fetch("/api/whiteboards"),fetch("/api/groups").catch(()=>null)]),w=await l.json().catch(()=>({}));if(!l.ok)throw new Error(w?.error??`HTTP ${l.status}`);let q=await J(y),$=Array.isArray(w.whiteboards)?w.whiteboards:[],A;if(s&&(A=await E(s,$)),!a.current)return;n(w.enabled===!0),b($),_(q),f(A),M(null)}catch(l){a.current&&M(l instanceof Error?l.message:String(l))}finally{a.current&&S(!1)}}return d(),()=>{a.current=!1,o.current+=1}},[]);async function U(s){let d=o.current+1;o.current=d;let l=await E(s,c);!a.current||o.current!==d||!l||(f(l),window.history.replaceState(null,"",`#/whiteboards/${encodeURIComponent(s)}`))}async function j(){if(u){D(!0);try{let s=await fetch(`/api/whiteboards/${encodeURIComponent(u.id)}`,{method:"DELETE"}),d=await s.json().catch(()=>({}));if(!s.ok||d.ok===!1)throw new Error(d?.error??`HTTP ${s.status}`);if(!a.current)return;b(l=>l.filter(y=>y.id!==u.id)),m?.id===u.id&&(f(void 0),window.history.replaceState(null,"","#/whiteboards")),h(null)}catch(s){a.current&&window.alert(`\u5220\u9664\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`)}finally{a.current&&D(!1)}}}let v="\u767D\u677F\u80FD\u529B\u5F53\u524D\u5173\u95ED\uFF1A\u4E0D\u4F1A\u81EA\u52A8\u521B\u5EFA/\u7ED1\u5B9A\u767D\u677F\uFF0C\u4E5F\u4E0D\u4F1A\u6CE8\u5165\u5230 agent prompt\u3002\u5386\u53F2\u767D\u677F\u4EC5\u5728 dashboard \u4E2D\u53EA\u8BFB\u53EF\u89C1\uFF0C\u53EF\u5728\u6B64\u6E05\u7406\u3002",N=(s=!1)=>(0,e.jsx)("div",{className:"page-heading",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("nav.whiteboards")}),(0,e.jsx)("h1",{children:t("nav.whiteboards")}),s?(0,e.jsx)("span",{className:"wb-disabled-pill",title:v,"aria-label":v,children:v}):null]})});return k?(0,e.jsxs)("section",{className:"page whiteboards-page",children:[N(),(0,e.jsxs)("p",{className:"hint-warn",children:["\u52A0\u8F7D\u767D\u677F\u5931\u8D25\uFF1A",k]})]}):H?(0,e.jsxs)("section",{className:"page whiteboards-page","data-whiteboards-host":!0,children:[N(),(0,e.jsx)(W,{label:t("common.loading")})]}):(0,e.jsxs)("section",{className:"page whiteboards-page",children:[N(!i),(0,e.jsxs)("div",{className:"wb-split",children:[(0,e.jsx)("section",{className:"overview-block wb-list-block",children:(0,e.jsx)("div",{className:"wb-list-panel",children:I.length===0?(0,e.jsx)("p",{className:"empty wb-empty",children:"\u6682\u65E0\u767D\u677F\u3002\u6253\u5F00\u80FD\u529B\u540E\uFF0C\u6BCF\u4E2A\u7FA4\u9996\u6B21\u9700\u8981\u767D\u677F\u65F6\u624D\u4F1A\u521B\u5EFA\u9ED8\u8BA4\u767D\u677F\u3002"}):I.map(s=>(0,e.jsxs)("details",{className:"wb-group",open:!0,children:[(0,e.jsxs)("summary",{children:[(0,e.jsx)("span",{className:"wb-group-title",children:(0,e.jsx)(C,{text:s.label,textClassName:"wb-group-title-scroll"})}),(0,e.jsx)("small",{children:s.rows.length})]}),(0,e.jsx)("div",{className:"wb-group-items",children:s.rows.map(d=>(0,e.jsx)(Q,{row:d,active:m?.id===d.id,onSelect:l=>{U(l)}},d.id))})]},s.chatId))})}),(0,e.jsx)("section",{className:"overview-block wb-detail-block",children:(0,e.jsx)("div",{className:"wb-detail-panel",id:"whiteboard-detail",children:(0,e.jsx)(V,{selected:m,groupNames:g,onDelete:()=>{m&&h(m)}})})})]}),u?(0,e.jsx)(X,{selected:u,deleting:L,onCancel:()=>h(null),onConfirm:()=>{j()}}):null]})}function ae(t){return P(t,(0,e.jsx)(Y,{}))}export{ae as renderWhiteboardsPage};
1
+ import{c as B}from"./chunk-VA6QWSGQ.js";import{c as W,k as C}from"./chunk-5CJMHTT4.js";import"./chunk-DLZK52JU.js";import{a as P}from"./chunk-SYC6D5XU.js";import{a as O,d as T}from"./chunk-5THX4DI2.js";import{c as R}from"./chunk-7SZRL6FY.js";var r=R(O(),1);var e=R(T(),1);function x(t){let a=Date.parse(t);if(!a)return t||"-";let o=Math.max(0,Math.floor((Date.now()-a)/1e3));if(o<60)return`${o}s ago`;let i=Math.floor(o/60);if(i<60)return`${i}m ago`;let n=Math.floor(i/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function F(t){return t.chatId?.trim()||"__local__"}function G(t,a){if(t==="__local__")return"\u672A\u7ED1\u5B9A\u7FA4 / \u672C\u5730\u767D\u677F";let o=a.get(t);return o&&o!==t?`${o} (${t})`:t}function K(t,a){let o=new Map;for(let i of t){let n=F(i),c=o.get(n)??[];c.push(i),o.set(n,c)}return[...o.entries()].map(([i,n])=>({chatId:i,label:G(i,a),rows:[...n].sort((c,b)=>b.updatedAt.localeCompare(c.updatedAt))})).sort((i,n)=>i.label.localeCompare(n.label))}function z(){return decodeURIComponent((location.hash.match(/^#\/whiteboards\/([^/]+)/)?.[1]??"").trim())}async function E(t,a){let o=await fetch(`/api/whiteboards/${encodeURIComponent(t)}`),i=await o.json().catch(()=>({}));if(o.ok)return{id:t,content:String(i.content??""),row:a.find(n=>n.id===t)}}async function J(t){let a=new Map;if(!t?.ok)return a;let o=await t.json().catch(()=>({})),i=Array.isArray(o.chats)?o.chats:[];for(let n of i)n.chatId&&a.set(String(n.chatId),String(n.name||n.chatId));return a}function Q(t){let a=t.row,o=a.title||a.id;return(0,e.jsxs)("a",{className:`wb-item${t.active?" active":""}`,"data-whiteboard-id":a.id,href:`#/whiteboards/${encodeURIComponent(a.id)}`,onClick:i=>{i.preventDefault(),t.onSelect(a.id)},children:[(0,e.jsx)("div",{className:"wb-item-head",children:(0,e.jsxs)("div",{className:"wb-item-main",children:[(0,e.jsx)("strong",{children:(0,e.jsx)(C,{text:o,textClassName:"wb-title-scroll"})}),(0,e.jsx)("span",{className:"wb-id-text",title:a.id,children:a.id})]})}),(0,e.jsxs)("div",{className:"wb-item-foot",children:[(0,e.jsxs)("div",{className:"wb-item-meta",children:[(0,e.jsx)("span",{children:x(a.updatedAt)}),(0,e.jsx)("span",{children:"\xB7"}),(0,e.jsxs)("span",{children:["log ",a.logCount]})]}),(0,e.jsx)("span",{className:"wb-scope",title:a.scope,children:a.scope})]})]})}function p(t){let a=t.value||"-";return(0,e.jsxs)("div",{className:"wb-meta-card",title:a,children:[(0,e.jsx)("span",{children:t.label}),(0,e.jsx)("strong",{children:a})]})}function V(t){let a=t.selected;if(!a)return(0,e.jsx)("p",{className:"empty",children:"\u9009\u62E9\u5DE6\u4FA7\u767D\u677F\u67E5\u770B meta \u548C board.md\u3002"});let o=a.row,i=o?.chatId?G(o.chatId,t.groupNames):"\u672A\u7ED1\u5B9A\u7FA4 / \u672C\u5730\u767D\u677F",n=o?.title||a.id;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"wb-detail-head",children:[(0,e.jsxs)("div",{className:"wb-detail-title",children:[(0,e.jsx)("p",{className:"eyebrow",children:"WHITEBOARD"}),(0,e.jsx)("h2",{title:n,children:n}),(0,e.jsx)("code",{title:a.id,children:a.id})]}),(0,e.jsx)("button",{type:"button",className:"danger","data-delete-whiteboard":!0,onClick:t.onDelete,children:"\u5220\u9664\u767D\u677F"})]}),(0,e.jsxs)("div",{className:"wb-meta-grid",children:[(0,e.jsx)(p,{label:"\u6240\u5C5E\u7FA4",value:i}),(0,e.jsx)(p,{label:"\u8303\u56F4",value:o?.scope??"-"}),(0,e.jsx)(p,{label:"\u6700\u8FD1\u66F4\u65B0",value:o?.updatedAt?x(o.updatedAt):"-"}),(0,e.jsx)(p,{label:"\u6765\u6E90\u76EE\u5F55",value:o?.workingDir??"-"})]}),(0,e.jsxs)("details",{className:"wb-admin-info",children:[(0,e.jsx)("summary",{children:"\u7BA1\u7406\u4FE1\u606F / \u6587\u4EF6\u8DEF\u5F84"}),(0,e.jsx)("code",{children:o?.path??""})]}),(0,e.jsxs)("section",{className:"wb-board-panel",children:[(0,e.jsxs)("div",{className:"wb-board-panel-head",children:[(0,e.jsx)("strong",{children:"board.md"}),(0,e.jsx)("span",{children:"\u53EA\u8BFB\u9884\u89C8"})]}),(0,e.jsx)("pre",{children:a.content||"\uFF08\u6682\u65E0\u5185\u5BB9\uFF09"})]})]})}function X(t){let a=t.selected.row?.title||t.selected.id;return(0,e.jsx)("div",{className:"wb-delete-backdrop","data-delete-modal":!0,onClick:o=>{o.target===o.currentTarget&&t.onCancel()},children:(0,e.jsxs)("div",{className:"wb-delete-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"wb-delete-title",children:[(0,e.jsxs)("div",{className:"wb-delete-body",children:[(0,e.jsx)("div",{className:"wb-delete-mark","aria-hidden":"true",children:"!"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{id:"wb-delete-title",children:"\u5220\u9664\u767D\u677F\uFF1F"}),(0,e.jsxs)("p",{children:["\u5C06\u5220\u9664 ",(0,e.jsx)("strong",{children:a}),"\uFF08",(0,e.jsx)("code",{children:t.selected.id}),"\uFF09\u7684 board\u3001log\u3001meta\uFF0C\u5E76\u6E05\u7406\u9ED8\u8BA4\u7ED1\u5B9A\u548C\u4F1A\u8BDD\u5F15\u7528\u3002\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002"]})]})]}),(0,e.jsxs)("div",{className:"actions wb-delete-actions",children:[(0,e.jsx)("button",{type:"button","data-delete-cancel":!0,onClick:t.onCancel,disabled:t.deleting,children:"\u53D6\u6D88"}),(0,e.jsx)("button",{type:"button",className:"danger","data-delete-confirm":!0,onClick:t.onConfirm,disabled:t.deleting,children:t.deleting?"\u5220\u9664\u4E2D...":"\u786E\u8BA4\u5220\u9664"})]})]})})}function Y(){let t=B(),a=(0,r.useRef)(!1),o=(0,r.useRef)(0),[i,n]=(0,r.useState)(!1),[c,b]=(0,r.useState)([]),[g,_]=(0,r.useState)(()=>new Map),[m,f]=(0,r.useState)(),[H,S]=(0,r.useState)(!0),[k,M]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[L,D]=(0,r.useState)(!1),I=(0,r.useMemo)(()=>K(c,g),[c,g]);(0,r.useEffect)(()=>{a.current=!0;let s=z();async function d(){S(!0);try{let[l,y]=await Promise.all([fetch("/api/whiteboards"),fetch("/api/groups").catch(()=>null)]),w=await l.json().catch(()=>({}));if(!l.ok)throw new Error(w?.error??`HTTP ${l.status}`);let q=await J(y),$=Array.isArray(w.whiteboards)?w.whiteboards:[],A;if(s&&(A=await E(s,$)),!a.current)return;n(w.enabled===!0),b($),_(q),f(A),M(null)}catch(l){a.current&&M(l instanceof Error?l.message:String(l))}finally{a.current&&S(!1)}}return d(),()=>{a.current=!1,o.current+=1}},[]);async function U(s){let d=o.current+1;o.current=d;let l=await E(s,c);!a.current||o.current!==d||!l||(f(l),window.history.replaceState(null,"",`#/whiteboards/${encodeURIComponent(s)}`))}async function j(){if(u){D(!0);try{let s=await fetch(`/api/whiteboards/${encodeURIComponent(u.id)}`,{method:"DELETE"}),d=await s.json().catch(()=>({}));if(!s.ok||d.ok===!1)throw new Error(d?.error??`HTTP ${s.status}`);if(!a.current)return;b(l=>l.filter(y=>y.id!==u.id)),m?.id===u.id&&(f(void 0),window.history.replaceState(null,"","#/whiteboards")),h(null)}catch(s){a.current&&window.alert(`\u5220\u9664\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`)}finally{a.current&&D(!1)}}}let v="\u767D\u677F\u80FD\u529B\u5F53\u524D\u5173\u95ED\uFF1A\u4E0D\u4F1A\u81EA\u52A8\u521B\u5EFA/\u7ED1\u5B9A\u767D\u677F\uFF0C\u4E5F\u4E0D\u4F1A\u6CE8\u5165\u5230 agent prompt\u3002\u5386\u53F2\u767D\u677F\u4EC5\u5728 dashboard \u4E2D\u53EA\u8BFB\u53EF\u89C1\uFF0C\u53EF\u5728\u6B64\u6E05\u7406\u3002",N=(s=!1)=>(0,e.jsx)("div",{className:"page-heading",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("nav.whiteboards")}),(0,e.jsx)("h1",{children:t("nav.whiteboards")}),s?(0,e.jsx)("span",{className:"wb-disabled-pill",title:v,"aria-label":v,children:v}):null]})});return k?(0,e.jsxs)("section",{className:"page whiteboards-page",children:[N(),(0,e.jsxs)("p",{className:"hint-warn",children:["\u52A0\u8F7D\u767D\u677F\u5931\u8D25\uFF1A",k]})]}):H?(0,e.jsxs)("section",{className:"page whiteboards-page","data-whiteboards-host":!0,children:[N(),(0,e.jsx)(W,{label:t("common.loading")})]}):(0,e.jsxs)("section",{className:"page whiteboards-page",children:[N(!i),(0,e.jsxs)("div",{className:"wb-split",children:[(0,e.jsx)("section",{className:"overview-block wb-list-block",children:(0,e.jsx)("div",{className:"wb-list-panel",children:I.length===0?(0,e.jsx)("p",{className:"empty wb-empty",children:"\u6682\u65E0\u767D\u677F\u3002\u6253\u5F00\u80FD\u529B\u540E\uFF0C\u6BCF\u4E2A\u7FA4\u9996\u6B21\u9700\u8981\u767D\u677F\u65F6\u624D\u4F1A\u521B\u5EFA\u9ED8\u8BA4\u767D\u677F\u3002"}):I.map(s=>(0,e.jsxs)("details",{className:"wb-group",open:!0,children:[(0,e.jsxs)("summary",{children:[(0,e.jsx)("span",{className:"wb-group-title",children:(0,e.jsx)(C,{text:s.label,textClassName:"wb-group-title-scroll"})}),(0,e.jsx)("small",{children:s.rows.length})]}),(0,e.jsx)("div",{className:"wb-group-items",children:s.rows.map(d=>(0,e.jsx)(Q,{row:d,active:m?.id===d.id,onSelect:l=>{U(l)}},d.id))})]},s.chatId))})}),(0,e.jsx)("section",{className:"overview-block wb-detail-block",children:(0,e.jsx)("div",{className:"wb-detail-panel",id:"whiteboard-detail",children:(0,e.jsx)(V,{selected:m,groupNames:g,onDelete:()=>{m&&h(m)}})})})]}),u?(0,e.jsx)(X,{selected:u,deleting:L,onCancel:()=>h(null),onConfirm:()=>{j()}}):null]})}function ae(t){return P(t,(0,e.jsx)(Y,{}))}export{ae as renderWhiteboardsPage};