botmux 3.14.0 → 3.16.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 (812) hide show
  1. package/README.en.md +2 -2
  2. package/README.md +2 -2
  3. package/dist/.runtime-build-id +1 -1
  4. package/dist/adapters/backend/destroy-result.d.ts +159 -0
  5. package/dist/adapters/backend/destroy-result.d.ts.map +1 -0
  6. package/dist/adapters/backend/destroy-result.js +223 -0
  7. package/dist/adapters/backend/destroy-result.js.map +1 -0
  8. package/dist/adapters/backend/herdr-backend.d.ts +4 -0
  9. package/dist/adapters/backend/herdr-backend.d.ts.map +1 -1
  10. package/dist/adapters/backend/herdr-backend.js +23 -1
  11. package/dist/adapters/backend/herdr-backend.js.map +1 -1
  12. package/dist/adapters/backend/mojo-backend.d.ts +577 -0
  13. package/dist/adapters/backend/mojo-backend.d.ts.map +1 -0
  14. package/dist/adapters/backend/mojo-backend.js +2471 -0
  15. package/dist/adapters/backend/mojo-backend.js.map +1 -0
  16. package/dist/adapters/backend/mojo-budgets.d.ts +21 -0
  17. package/dist/adapters/backend/mojo-budgets.d.ts.map +1 -0
  18. package/dist/adapters/backend/mojo-budgets.js +22 -0
  19. package/dist/adapters/backend/mojo-budgets.js.map +1 -0
  20. package/dist/adapters/backend/mojo-isolated-workspace.d.ts +69 -0
  21. package/dist/adapters/backend/mojo-isolated-workspace.d.ts.map +1 -0
  22. package/dist/adapters/backend/mojo-isolated-workspace.js +213 -0
  23. package/dist/adapters/backend/mojo-isolated-workspace.js.map +1 -0
  24. package/dist/adapters/backend/mojo-process-tree.d.ts +292 -0
  25. package/dist/adapters/backend/mojo-process-tree.d.ts.map +1 -0
  26. package/dist/adapters/backend/mojo-process-tree.js +486 -0
  27. package/dist/adapters/backend/mojo-process-tree.js.map +1 -0
  28. package/dist/adapters/backend/mojo-types.d.ts +542 -0
  29. package/dist/adapters/backend/mojo-types.d.ts.map +1 -0
  30. package/dist/adapters/backend/mojo-types.js +682 -0
  31. package/dist/adapters/backend/mojo-types.js.map +1 -0
  32. package/dist/adapters/backend/reproduce-command.js +3 -3
  33. package/dist/adapters/backend/reproduce-command.js.map +1 -1
  34. package/dist/adapters/backend/riff-backend.js +1 -1
  35. package/dist/adapters/backend/riff-backend.js.map +1 -1
  36. package/dist/adapters/backend/sandbox.d.ts +44 -7
  37. package/dist/adapters/backend/sandbox.d.ts.map +1 -1
  38. package/dist/adapters/backend/sandbox.js +30 -7
  39. package/dist/adapters/backend/sandbox.js.map +1 -1
  40. package/dist/adapters/backend/session-backend-selector.d.ts +14 -1
  41. package/dist/adapters/backend/session-backend-selector.d.ts.map +1 -1
  42. package/dist/adapters/backend/session-backend-selector.js +82 -10
  43. package/dist/adapters/backend/session-backend-selector.js.map +1 -1
  44. package/dist/adapters/backend/tmux-pipe-backend.d.ts +30 -0
  45. package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -1
  46. package/dist/adapters/backend/tmux-pipe-backend.js +60 -0
  47. package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -1
  48. package/dist/adapters/backend/types.d.ts +108 -6
  49. package/dist/adapters/backend/types.d.ts.map +1 -1
  50. package/dist/adapters/backend/types.js.map +1 -1
  51. package/dist/adapters/backend/zmx-backend.d.ts +11 -0
  52. package/dist/adapters/backend/zmx-backend.d.ts.map +1 -1
  53. package/dist/adapters/backend/zmx-backend.js +16 -1
  54. package/dist/adapters/backend/zmx-backend.js.map +1 -1
  55. package/dist/adapters/cli/codex-app.d.ts.map +1 -1
  56. package/dist/adapters/cli/codex-app.js +2 -2
  57. package/dist/adapters/cli/codex-app.js.map +1 -1
  58. package/dist/adapters/cli/codex.d.ts.map +1 -1
  59. package/dist/adapters/cli/codex.js +7 -0
  60. package/dist/adapters/cli/codex.js.map +1 -1
  61. package/dist/adapters/cli/copilot.d.ts +3 -1
  62. package/dist/adapters/cli/copilot.d.ts.map +1 -1
  63. package/dist/adapters/cli/copilot.js +23 -5
  64. package/dist/adapters/cli/copilot.js.map +1 -1
  65. package/dist/adapters/cli/cursor.d.ts.map +1 -1
  66. package/dist/adapters/cli/cursor.js +26 -4
  67. package/dist/adapters/cli/cursor.js.map +1 -1
  68. package/dist/adapters/cli/dsh.d.ts.map +1 -1
  69. package/dist/adapters/cli/dsh.js +5 -1
  70. package/dist/adapters/cli/dsh.js.map +1 -1
  71. package/dist/adapters/cli/grok.d.ts.map +1 -1
  72. package/dist/adapters/cli/grok.js +24 -5
  73. package/dist/adapters/cli/grok.js.map +1 -1
  74. package/dist/adapters/cli/kimi.d.ts.map +1 -1
  75. package/dist/adapters/cli/kimi.js +19 -1
  76. package/dist/adapters/cli/kimi.js.map +1 -1
  77. package/dist/adapters/cli/mojo.d.ts +28 -0
  78. package/dist/adapters/cli/mojo.d.ts.map +1 -0
  79. package/dist/adapters/cli/mojo.js +58 -0
  80. package/dist/adapters/cli/mojo.js.map +1 -0
  81. package/dist/adapters/cli/pi.d.ts +20 -5
  82. package/dist/adapters/cli/pi.d.ts.map +1 -1
  83. package/dist/adapters/cli/pi.js +27 -5
  84. package/dist/adapters/cli/pi.js.map +1 -1
  85. package/dist/adapters/cli/read-isolation.d.ts +251 -1
  86. package/dist/adapters/cli/read-isolation.d.ts.map +1 -1
  87. package/dist/adapters/cli/read-isolation.js +254 -1
  88. package/dist/adapters/cli/read-isolation.js.map +1 -1
  89. package/dist/adapters/cli/registry.d.ts +13 -1
  90. package/dist/adapters/cli/registry.d.ts.map +1 -1
  91. package/dist/adapters/cli/registry.js +19 -1
  92. package/dist/adapters/cli/registry.js.map +1 -1
  93. package/dist/adapters/cli/runner-input.d.ts +3 -3
  94. package/dist/adapters/cli/runner-input.d.ts.map +1 -1
  95. package/dist/adapters/cli/runner-input.js +4 -3
  96. package/dist/adapters/cli/runner-input.js.map +1 -1
  97. package/dist/adapters/cli/shared-hints.d.ts +3 -1
  98. package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
  99. package/dist/adapters/cli/shared-hints.js +51 -30
  100. package/dist/adapters/cli/shared-hints.js.map +1 -1
  101. package/dist/adapters/cli/types.d.ts +33 -4
  102. package/dist/adapters/cli/types.d.ts.map +1 -1
  103. package/dist/bot-registry.d.ts +42 -0
  104. package/dist/bot-registry.d.ts.map +1 -1
  105. package/dist/bot-registry.js +54 -4
  106. package/dist/bot-registry.js.map +1 -1
  107. package/dist/cli/arg-utils.d.ts +5 -0
  108. package/dist/cli/arg-utils.d.ts.map +1 -1
  109. package/dist/cli/arg-utils.js +7 -0
  110. package/dist/cli/arg-utils.js.map +1 -1
  111. package/dist/cli/bots-list-output.d.ts +130 -2
  112. package/dist/cli/bots-list-output.d.ts.map +1 -1
  113. package/dist/cli/bots-list-output.js +173 -27
  114. package/dist/cli/bots-list-output.js.map +1 -1
  115. package/dist/cli/daemon-lifecycle-env.d.ts +10 -3
  116. package/dist/cli/daemon-lifecycle-env.d.ts.map +1 -1
  117. package/dist/cli/daemon-lifecycle-env.js +38 -11
  118. package/dist/cli/daemon-lifecycle-env.js.map +1 -1
  119. package/dist/cli/dashboard-command.d.ts +15 -0
  120. package/dist/cli/dashboard-command.d.ts.map +1 -1
  121. package/dist/cli/dashboard-command.js +22 -0
  122. package/dist/cli/dashboard-command.js.map +1 -1
  123. package/dist/cli/log-tail.d.ts +54 -0
  124. package/dist/cli/log-tail.d.ts.map +1 -0
  125. package/dist/cli/log-tail.js +167 -0
  126. package/dist/cli/log-tail.js.map +1 -0
  127. package/dist/cli/pm2-env.d.ts +16 -0
  128. package/dist/cli/pm2-env.d.ts.map +1 -0
  129. package/dist/cli/pm2-env.js +63 -0
  130. package/dist/cli/pm2-env.js.map +1 -0
  131. package/dist/cli/pm2-fleet-lock.d.ts +26 -0
  132. package/dist/cli/pm2-fleet-lock.d.ts.map +1 -0
  133. package/dist/cli/pm2-fleet-lock.js +50 -0
  134. package/dist/cli/pm2-fleet-lock.js.map +1 -0
  135. package/dist/cli/pm2-god-retirement.d.ts +59 -0
  136. package/dist/cli/pm2-god-retirement.d.ts.map +1 -0
  137. package/dist/cli/pm2-god-retirement.js +95 -0
  138. package/dist/cli/pm2-god-retirement.js.map +1 -0
  139. package/dist/cli/session-list-wake.d.ts +41 -0
  140. package/dist/cli/session-list-wake.d.ts.map +1 -0
  141. package/dist/cli/session-list-wake.js +102 -0
  142. package/dist/cli/session-list-wake.js.map +1 -0
  143. package/dist/cli/workflow.d.ts.map +1 -1
  144. package/dist/cli/workflow.js +26 -0
  145. package/dist/cli/workflow.js.map +1 -1
  146. package/dist/cli.d.ts.map +1 -1
  147. package/dist/cli.js +941 -118
  148. package/dist/cli.js.map +1 -1
  149. package/dist/codex-app-runner.js +261 -49
  150. package/dist/codex-app-runner.js.map +1 -1
  151. package/dist/core/cli-runtime-update.d.ts +8 -0
  152. package/dist/core/cli-runtime-update.d.ts.map +1 -1
  153. package/dist/core/cli-runtime-update.js +127 -8
  154. package/dist/core/cli-runtime-update.js.map +1 -1
  155. package/dist/core/close-residual.d.ts +64 -0
  156. package/dist/core/close-residual.d.ts.map +1 -0
  157. package/dist/core/close-residual.js +93 -0
  158. package/dist/core/close-residual.js.map +1 -0
  159. package/dist/core/closed-session-card.d.ts.map +1 -1
  160. package/dist/core/closed-session-card.js +11 -3
  161. package/dist/core/closed-session-card.js.map +1 -1
  162. package/dist/core/command-discovery.d.ts.map +1 -1
  163. package/dist/core/command-discovery.js +4 -1
  164. package/dist/core/command-discovery.js.map +1 -1
  165. package/dist/core/command-handler.d.ts.map +1 -1
  166. package/dist/core/command-handler.js +129 -27
  167. package/dist/core/command-handler.js.map +1 -1
  168. package/dist/core/cost-calculator.d.ts +3 -1
  169. package/dist/core/cost-calculator.d.ts.map +1 -1
  170. package/dist/core/cost-calculator.js +230 -1
  171. package/dist/core/cost-calculator.js.map +1 -1
  172. package/dist/core/daemon-background-close.d.ts +19 -0
  173. package/dist/core/daemon-background-close.d.ts.map +1 -0
  174. package/dist/core/daemon-background-close.js +39 -0
  175. package/dist/core/daemon-background-close.js.map +1 -0
  176. package/dist/core/dashboard-command/overview.d.ts +4 -0
  177. package/dist/core/dashboard-command/overview.d.ts.map +1 -1
  178. package/dist/core/dashboard-command/overview.js +8 -1
  179. package/dist/core/dashboard-command/overview.js.map +1 -1
  180. package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
  181. package/dist/core/dashboard-ipc-server.js +415 -42
  182. package/dist/core/dashboard-ipc-server.js.map +1 -1
  183. package/dist/core/dashboard-rows.d.ts +4 -0
  184. package/dist/core/dashboard-rows.d.ts.map +1 -1
  185. package/dist/core/dashboard-rows.js +3 -0
  186. package/dist/core/dashboard-rows.js.map +1 -1
  187. package/dist/core/dashboard-url.d.ts +37 -0
  188. package/dist/core/dashboard-url.d.ts.map +1 -1
  189. package/dist/core/dashboard-url.js +71 -0
  190. package/dist/core/dashboard-url.js.map +1 -1
  191. package/dist/core/deferred-schedule-settlement.d.ts +15 -1
  192. package/dist/core/deferred-schedule-settlement.d.ts.map +1 -1
  193. package/dist/core/deferred-schedule-settlement.js +4 -1
  194. package/dist/core/deferred-schedule-settlement.js.map +1 -1
  195. package/dist/core/device-isolation-daemon.d.ts +91 -1
  196. package/dist/core/device-isolation-daemon.d.ts.map +1 -1
  197. package/dist/core/device-isolation-daemon.js +346 -2
  198. package/dist/core/device-isolation-daemon.js.map +1 -1
  199. package/dist/core/local-terminal-opener.d.ts.map +1 -1
  200. package/dist/core/local-terminal-opener.js +5 -1
  201. package/dist/core/local-terminal-opener.js.map +1 -1
  202. package/dist/core/loopback-target.d.ts +14 -0
  203. package/dist/core/loopback-target.d.ts.map +1 -0
  204. package/dist/core/loopback-target.js +20 -0
  205. package/dist/core/loopback-target.js.map +1 -0
  206. package/dist/core/maintenance.d.ts.map +1 -1
  207. package/dist/core/maintenance.js +16 -2
  208. package/dist/core/maintenance.js.map +1 -1
  209. package/dist/core/mojo-containment-command.d.ts +20 -0
  210. package/dist/core/mojo-containment-command.d.ts.map +1 -0
  211. package/dist/core/mojo-containment-command.js +266 -0
  212. package/dist/core/mojo-containment-command.js.map +1 -0
  213. package/dist/core/mojo-containment.d.ts +575 -0
  214. package/dist/core/mojo-containment.d.ts.map +1 -0
  215. package/dist/core/mojo-containment.js +1158 -0
  216. package/dist/core/mojo-containment.js.map +1 -0
  217. package/dist/core/mojo-launcher-env-quarantine.d.ts +30 -0
  218. package/dist/core/mojo-launcher-env-quarantine.d.ts.map +1 -0
  219. package/dist/core/mojo-launcher-env-quarantine.js +175 -0
  220. package/dist/core/mojo-launcher-env-quarantine.js.map +1 -0
  221. package/dist/core/mojo-session-identity.d.ts +3 -0
  222. package/dist/core/mojo-session-identity.d.ts.map +1 -0
  223. package/dist/core/mojo-session-identity.js +126 -0
  224. package/dist/core/mojo-session-identity.js.map +1 -0
  225. package/dist/core/persistent-backend.d.ts +32 -8
  226. package/dist/core/persistent-backend.d.ts.map +1 -1
  227. package/dist/core/persistent-backend.js +55 -17
  228. package/dist/core/persistent-backend.js.map +1 -1
  229. package/dist/core/plugins/mcp/gateway.d.ts +14 -1
  230. package/dist/core/plugins/mcp/gateway.d.ts.map +1 -1
  231. package/dist/core/plugins/mcp/gateway.js +70 -3
  232. package/dist/core/plugins/mcp/gateway.js.map +1 -1
  233. package/dist/core/plugins/mcp/host.d.ts +2 -0
  234. package/dist/core/plugins/mcp/host.d.ts.map +1 -1
  235. package/dist/core/plugins/mcp/host.js +2 -0
  236. package/dist/core/plugins/mcp/host.js.map +1 -1
  237. package/dist/core/plugins/pm2.d.ts.map +1 -1
  238. package/dist/core/plugins/pm2.js +16 -3
  239. package/dist/core/plugins/pm2.js.map +1 -1
  240. package/dist/core/plugins/service-manager.d.ts +9 -0
  241. package/dist/core/plugins/service-manager.d.ts.map +1 -1
  242. package/dist/core/plugins/service-manager.js +33 -16
  243. package/dist/core/plugins/service-manager.js.map +1 -1
  244. package/dist/core/preview-port-owner.d.ts +109 -0
  245. package/dist/core/preview-port-owner.d.ts.map +1 -0
  246. package/dist/core/preview-port-owner.js +320 -0
  247. package/dist/core/preview-port-owner.js.map +1 -0
  248. package/dist/core/remote-cli-ids.d.ts +5 -0
  249. package/dist/core/remote-cli-ids.d.ts.map +1 -0
  250. package/dist/core/remote-cli-ids.js +24 -0
  251. package/dist/core/remote-cli-ids.js.map +1 -0
  252. package/dist/core/{riff-shutdown-detach.d.ts → remote-shutdown-detach.d.ts} +40 -39
  253. package/dist/core/remote-shutdown-detach.d.ts.map +1 -0
  254. package/dist/core/{riff-shutdown-detach.js → remote-shutdown-detach.js} +85 -83
  255. package/dist/core/remote-shutdown-detach.js.map +1 -0
  256. package/dist/core/{riff-worker-shutdown-readiness.d.ts → remote-worker-shutdown-readiness.d.ts} +5 -4
  257. package/dist/core/remote-worker-shutdown-readiness.d.ts.map +1 -0
  258. package/dist/core/{riff-worker-shutdown-readiness.js → remote-worker-shutdown-readiness.js} +4 -3
  259. package/dist/core/remote-worker-shutdown-readiness.js.map +1 -0
  260. package/dist/core/reply-target.d.ts +16 -1
  261. package/dist/core/reply-target.d.ts.map +1 -1
  262. package/dist/core/reply-target.js +61 -0
  263. package/dist/core/reply-target.js.map +1 -1
  264. package/dist/core/session-group-birth.d.ts +26 -0
  265. package/dist/core/session-group-birth.d.ts.map +1 -1
  266. package/dist/core/session-group-birth.js +81 -4
  267. package/dist/core/session-group-birth.js.map +1 -1
  268. package/dist/core/session-manager.d.ts +15 -2
  269. package/dist/core/session-manager.d.ts.map +1 -1
  270. package/dist/core/session-manager.js +259 -5
  271. package/dist/core/session-manager.js.map +1 -1
  272. package/dist/core/session-model.d.ts +46 -0
  273. package/dist/core/session-model.d.ts.map +1 -0
  274. package/dist/core/session-model.js +42 -0
  275. package/dist/core/session-model.js.map +1 -0
  276. package/dist/core/session-owner-reminder.d.ts +63 -0
  277. package/dist/core/session-owner-reminder.d.ts.map +1 -0
  278. package/dist/core/session-owner-reminder.js +196 -0
  279. package/dist/core/session-owner-reminder.js.map +1 -0
  280. package/dist/core/session-preview-registry.d.ts +53 -0
  281. package/dist/core/session-preview-registry.d.ts.map +1 -0
  282. package/dist/core/session-preview-registry.js +82 -0
  283. package/dist/core/session-preview-registry.js.map +1 -0
  284. package/dist/core/session-preview.d.ts +114 -0
  285. package/dist/core/session-preview.d.ts.map +1 -0
  286. package/dist/core/session-preview.js +184 -0
  287. package/dist/core/session-preview.js.map +1 -0
  288. package/dist/core/session-rename.d.ts.map +1 -1
  289. package/dist/core/session-rename.js +5 -3
  290. package/dist/core/session-rename.js.map +1 -1
  291. package/dist/core/session-wake-deadline.d.ts +5 -0
  292. package/dist/core/session-wake-deadline.d.ts.map +1 -0
  293. package/dist/core/session-wake-deadline.js +13 -0
  294. package/dist/core/session-wake-deadline.js.map +1 -0
  295. package/dist/core/shutdown-budgets.d.ts +7 -6
  296. package/dist/core/shutdown-budgets.d.ts.map +1 -1
  297. package/dist/core/shutdown-budgets.js +11 -10
  298. package/dist/core/shutdown-budgets.js.map +1 -1
  299. package/dist/core/skills/frontmatter.d.ts.map +1 -1
  300. package/dist/core/skills/frontmatter.js +6 -1
  301. package/dist/core/skills/frontmatter.js.map +1 -1
  302. package/dist/core/terminal-control-grant.d.ts +74 -0
  303. package/dist/core/terminal-control-grant.d.ts.map +1 -0
  304. package/dist/core/terminal-control-grant.js +183 -0
  305. package/dist/core/terminal-control-grant.js.map +1 -0
  306. package/dist/core/terminal-proxy.d.ts.map +1 -1
  307. package/dist/core/terminal-proxy.js +4 -5
  308. package/dist/core/terminal-proxy.js.map +1 -1
  309. package/dist/core/terminal-write-auth.d.ts +4 -11
  310. package/dist/core/terminal-write-auth.d.ts.map +1 -1
  311. package/dist/core/terminal-write-auth.js +19 -16
  312. package/dist/core/terminal-write-auth.js.map +1 -1
  313. package/dist/core/trigger-session.d.ts.map +1 -1
  314. package/dist/core/trigger-session.js +36 -29
  315. package/dist/core/trigger-session.js.map +1 -1
  316. package/dist/core/types.d.ts +88 -10
  317. package/dist/core/types.d.ts.map +1 -1
  318. package/dist/core/types.js +9 -7
  319. package/dist/core/types.js.map +1 -1
  320. package/dist/core/workbench-link.d.ts +81 -0
  321. package/dist/core/workbench-link.d.ts.map +1 -0
  322. package/dist/core/workbench-link.js +109 -0
  323. package/dist/core/workbench-link.js.map +1 -0
  324. package/dist/core/worker-pool.d.ts +312 -11
  325. package/dist/core/worker-pool.d.ts.map +1 -1
  326. package/dist/core/worker-pool.js +2515 -217
  327. package/dist/core/worker-pool.js.map +1 -1
  328. package/dist/daemon.d.ts +6 -0
  329. package/dist/daemon.d.ts.map +1 -1
  330. package/dist/daemon.js +447 -116
  331. package/dist/daemon.js.map +1 -1
  332. package/dist/dashboard/aggregator.d.ts +33 -3
  333. package/dist/dashboard/aggregator.d.ts.map +1 -1
  334. package/dist/dashboard/aggregator.js +93 -17
  335. package/dist/dashboard/aggregator.js.map +1 -1
  336. package/dist/dashboard/auth-session-connections.d.ts +59 -0
  337. package/dist/dashboard/auth-session-connections.d.ts.map +1 -0
  338. package/dist/dashboard/auth-session-connections.js +109 -0
  339. package/dist/dashboard/auth-session-connections.js.map +1 -0
  340. package/dist/dashboard/auth.d.ts +99 -1
  341. package/dist/dashboard/auth.d.ts.map +1 -1
  342. package/dist/dashboard/auth.js +176 -64
  343. package/dist/dashboard/auth.js.map +1 -1
  344. package/dist/dashboard/bot-payload.d.ts +5 -0
  345. package/dist/dashboard/bot-payload.d.ts.map +1 -1
  346. package/dist/dashboard/bot-payload.js +4 -0
  347. package/dist/dashboard/bot-payload.js.map +1 -1
  348. package/dist/dashboard/control-audit.d.ts +112 -0
  349. package/dist/dashboard/control-audit.d.ts.map +1 -0
  350. package/dist/dashboard/control-audit.js +195 -0
  351. package/dist/dashboard/control-audit.js.map +1 -0
  352. package/dist/dashboard/control-csrf.d.ts +123 -0
  353. package/dist/dashboard/control-csrf.d.ts.map +1 -0
  354. package/dist/dashboard/control-csrf.js +392 -0
  355. package/dist/dashboard/control-csrf.js.map +1 -0
  356. package/dist/dashboard/daemon-reconcile.d.ts +26 -0
  357. package/dist/dashboard/daemon-reconcile.d.ts.map +1 -0
  358. package/dist/dashboard/daemon-reconcile.js +46 -0
  359. package/dist/dashboard/daemon-reconcile.js.map +1 -0
  360. package/dist/dashboard/debug-terminal.d.ts.map +1 -1
  361. package/dist/dashboard/debug-terminal.js +18 -4
  362. package/dist/dashboard/debug-terminal.js.map +1 -1
  363. package/dist/dashboard/events-sse.d.ts +60 -0
  364. package/dist/dashboard/events-sse.d.ts.map +1 -0
  365. package/dist/dashboard/events-sse.js +63 -0
  366. package/dist/dashboard/events-sse.js.map +1 -0
  367. package/dist/dashboard/h5-auth.d.ts +256 -0
  368. package/dist/dashboard/h5-auth.d.ts.map +1 -0
  369. package/dist/dashboard/h5-auth.js +825 -0
  370. package/dist/dashboard/h5-auth.js.map +1 -0
  371. package/dist/dashboard/managed-spawn.d.ts +36 -0
  372. package/dist/dashboard/managed-spawn.d.ts.map +1 -0
  373. package/dist/dashboard/managed-spawn.js +169 -0
  374. package/dist/dashboard/managed-spawn.js.map +1 -0
  375. package/dist/dashboard/preview-content-capability.d.ts +41 -0
  376. package/dist/dashboard/preview-content-capability.d.ts.map +1 -0
  377. package/dist/dashboard/preview-content-capability.js +127 -0
  378. package/dist/dashboard/preview-content-capability.js.map +1 -0
  379. package/dist/dashboard/preview-contract.d.ts +85 -0
  380. package/dist/dashboard/preview-contract.d.ts.map +1 -0
  381. package/dist/dashboard/preview-contract.js +198 -0
  382. package/dist/dashboard/preview-contract.js.map +1 -0
  383. package/dist/dashboard/preview-guard-page.d.ts +52 -0
  384. package/dist/dashboard/preview-guard-page.d.ts.map +1 -0
  385. package/dist/dashboard/preview-guard-page.js +162 -0
  386. package/dist/dashboard/preview-guard-page.js.map +1 -0
  387. package/dist/dashboard/preview-interaction.d.ts +57 -0
  388. package/dist/dashboard/preview-interaction.d.ts.map +1 -0
  389. package/dist/dashboard/preview-interaction.js +198 -0
  390. package/dist/dashboard/preview-interaction.js.map +1 -0
  391. package/dist/dashboard/preview-proxy.d.ts +113 -0
  392. package/dist/dashboard/preview-proxy.d.ts.map +1 -0
  393. package/dist/dashboard/preview-proxy.js +543 -0
  394. package/dist/dashboard/preview-proxy.js.map +1 -0
  395. package/dist/dashboard/public-redact.d.ts +23 -0
  396. package/dist/dashboard/public-redact.d.ts.map +1 -1
  397. package/dist/dashboard/public-redact.js +90 -21
  398. package/dist/dashboard/public-redact.js.map +1 -1
  399. package/dist/dashboard/request-identity.d.ts +77 -0
  400. package/dist/dashboard/request-identity.d.ts.map +1 -0
  401. package/dist/dashboard/request-identity.js +72 -0
  402. package/dist/dashboard/request-identity.js.map +1 -0
  403. package/dist/dashboard/session-cleanup.d.ts +5 -0
  404. package/dist/dashboard/session-cleanup.d.ts.map +1 -1
  405. package/dist/dashboard/session-cleanup.js +4 -0
  406. package/dist/dashboard/session-cleanup.js.map +1 -1
  407. package/dist/dashboard/settings-write-applier.d.ts +5 -1
  408. package/dist/dashboard/settings-write-applier.d.ts.map +1 -1
  409. package/dist/dashboard/settings-write-applier.js +14 -0
  410. package/dist/dashboard/settings-write-applier.js.map +1 -1
  411. package/dist/dashboard/standing-link.d.ts +76 -0
  412. package/dist/dashboard/standing-link.d.ts.map +1 -0
  413. package/dist/dashboard/standing-link.js +111 -0
  414. package/dist/dashboard/standing-link.js.map +1 -0
  415. package/dist/dashboard/terminal-control.d.ts +105 -0
  416. package/dist/dashboard/terminal-control.d.ts.map +1 -0
  417. package/dist/dashboard/terminal-control.js +296 -0
  418. package/dist/dashboard/terminal-control.js.map +1 -0
  419. package/dist/dashboard/terminal-front-proxy.d.ts +55 -0
  420. package/dist/dashboard/terminal-front-proxy.d.ts.map +1 -0
  421. package/dist/dashboard/terminal-front-proxy.js +397 -0
  422. package/dist/dashboard/terminal-front-proxy.js.map +1 -0
  423. package/dist/dashboard/terminal-view-capability.d.ts +97 -0
  424. package/dist/dashboard/terminal-view-capability.d.ts.map +1 -0
  425. package/dist/dashboard/terminal-view-capability.js +145 -0
  426. package/dist/dashboard/terminal-view-capability.js.map +1 -0
  427. package/dist/dashboard/web/agent-workbench-api.d.ts +59 -0
  428. package/dist/dashboard/web/agent-workbench-api.d.ts.map +1 -0
  429. package/dist/dashboard/web/agent-workbench-api.js +227 -0
  430. package/dist/dashboard/web/agent-workbench-api.js.map +1 -0
  431. package/dist/dashboard/web/agent-workbench-appearance-menu.d.ts +59 -0
  432. package/dist/dashboard/web/agent-workbench-appearance-menu.d.ts.map +1 -0
  433. package/dist/dashboard/web/agent-workbench-appearance-menu.js +195 -0
  434. package/dist/dashboard/web/agent-workbench-appearance-menu.js.map +1 -0
  435. package/dist/dashboard/web/agent-workbench-appearance.d.ts +222 -0
  436. package/dist/dashboard/web/agent-workbench-appearance.d.ts.map +1 -0
  437. package/dist/dashboard/web/agent-workbench-appearance.js +499 -0
  438. package/dist/dashboard/web/agent-workbench-appearance.js.map +1 -0
  439. package/dist/dashboard/web/agent-workbench-capabilities.d.ts +13 -0
  440. package/dist/dashboard/web/agent-workbench-capabilities.d.ts.map +1 -0
  441. package/dist/dashboard/web/agent-workbench-capabilities.js +24 -0
  442. package/dist/dashboard/web/agent-workbench-capabilities.js.map +1 -0
  443. package/dist/dashboard/web/agent-workbench-chat.d.ts +90 -0
  444. package/dist/dashboard/web/agent-workbench-chat.d.ts.map +1 -0
  445. package/dist/dashboard/web/agent-workbench-chat.js +168 -0
  446. package/dist/dashboard/web/agent-workbench-chat.js.map +1 -0
  447. package/dist/dashboard/web/agent-workbench-dock-page.d.ts +3 -0
  448. package/dist/dashboard/web/agent-workbench-dock-page.d.ts.map +1 -0
  449. package/dist/dashboard/web/agent-workbench-dock-page.js +23 -0
  450. package/dist/dashboard/web/agent-workbench-dock-page.js.map +1 -0
  451. package/dist/dashboard/web/agent-workbench-dock-view.d.ts +22 -0
  452. package/dist/dashboard/web/agent-workbench-dock-view.d.ts.map +1 -0
  453. package/dist/dashboard/web/agent-workbench-dock-view.js +76 -0
  454. package/dist/dashboard/web/agent-workbench-dock-view.js.map +1 -0
  455. package/dist/dashboard/web/agent-workbench-model.d.ts +196 -0
  456. package/dist/dashboard/web/agent-workbench-model.d.ts.map +1 -0
  457. package/dist/dashboard/web/agent-workbench-model.js +529 -0
  458. package/dist/dashboard/web/agent-workbench-model.js.map +1 -0
  459. package/dist/dashboard/web/agent-workbench-page.d.ts +3 -0
  460. package/dist/dashboard/web/agent-workbench-page.d.ts.map +1 -0
  461. package/dist/dashboard/web/agent-workbench-page.js +27 -0
  462. package/dist/dashboard/web/agent-workbench-page.js.map +1 -0
  463. package/dist/dashboard/web/agent-workbench-panes.d.ts +49 -0
  464. package/dist/dashboard/web/agent-workbench-panes.d.ts.map +1 -0
  465. package/dist/dashboard/web/agent-workbench-panes.js +468 -0
  466. package/dist/dashboard/web/agent-workbench-panes.js.map +1 -0
  467. package/dist/dashboard/web/agent-workbench-session-list.d.ts +42 -0
  468. package/dist/dashboard/web/agent-workbench-session-list.d.ts.map +1 -0
  469. package/dist/dashboard/web/agent-workbench-session-list.js +353 -0
  470. package/dist/dashboard/web/agent-workbench-session-list.js.map +1 -0
  471. package/dist/dashboard/web/agent-workbench-storage.d.ts +49 -0
  472. package/dist/dashboard/web/agent-workbench-storage.d.ts.map +1 -0
  473. package/dist/dashboard/web/agent-workbench-storage.js +197 -0
  474. package/dist/dashboard/web/agent-workbench-storage.js.map +1 -0
  475. package/dist/dashboard/web/agent-workbench-touch.d.ts +46 -0
  476. package/dist/dashboard/web/agent-workbench-touch.d.ts.map +1 -0
  477. package/dist/dashboard/web/agent-workbench-touch.js +96 -0
  478. package/dist/dashboard/web/agent-workbench-touch.js.map +1 -0
  479. package/dist/dashboard/web/agent-workbench-view.d.ts +34 -0
  480. package/dist/dashboard/web/agent-workbench-view.d.ts.map +1 -0
  481. package/dist/dashboard/web/agent-workbench-view.js +439 -0
  482. package/dist/dashboard/web/agent-workbench-view.js.map +1 -0
  483. package/dist/dashboard/web/app.d.ts.map +1 -1
  484. package/dist/dashboard/web/app.js +63 -2
  485. package/dist/dashboard/web/app.js.map +1 -1
  486. package/dist/dashboard/web/bot-defaults-page.d.ts +18 -0
  487. package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
  488. package/dist/dashboard/web/bot-defaults-page.js +362 -36
  489. package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
  490. package/dist/dashboard/web/bot-defaults.d.ts +8 -0
  491. package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
  492. package/dist/dashboard/web/bot-defaults.js.map +1 -1
  493. package/dist/dashboard/web/control-csrf.d.ts +4 -0
  494. package/dist/dashboard/web/control-csrf.d.ts.map +1 -0
  495. package/dist/dashboard/web/control-csrf.js +26 -0
  496. package/dist/dashboard/web/control-csrf.js.map +1 -0
  497. package/dist/dashboard/web/dashboard-routes.d.ts.map +1 -1
  498. package/dist/dashboard/web/dashboard-routes.js +2 -0
  499. package/dist/dashboard/web/dashboard-routes.js.map +1 -1
  500. package/dist/dashboard/web/groups-page.d.ts.map +1 -1
  501. package/dist/dashboard/web/groups-page.js +11 -2
  502. package/dist/dashboard/web/groups-page.js.map +1 -1
  503. package/dist/dashboard/web/i18n.d.ts.map +1 -1
  504. package/dist/dashboard/web/i18n.js +140 -6
  505. package/dist/dashboard/web/i18n.js.map +1 -1
  506. package/dist/dashboard/web/overview-page.d.ts.map +1 -1
  507. package/dist/dashboard/web/overview-page.js +3 -2
  508. package/dist/dashboard/web/overview-page.js.map +1 -1
  509. package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
  510. package/dist/dashboard/web/sessions-page.js +41 -1
  511. package/dist/dashboard/web/sessions-page.js.map +1 -1
  512. package/dist/dashboard/web/sessions.d.ts.map +1 -1
  513. package/dist/dashboard/web/sessions.js +5 -1
  514. package/dist/dashboard/web/sessions.js.map +1 -1
  515. package/dist/dashboard/web/settings-page.d.ts +3 -0
  516. package/dist/dashboard/web/settings-page.d.ts.map +1 -1
  517. package/dist/dashboard/web/settings-page.js +56 -10
  518. package/dist/dashboard/web/settings-page.js.map +1 -1
  519. package/dist/dashboard/web/skills-page.d.ts.map +1 -1
  520. package/dist/dashboard/web/skills-page.js +4 -2
  521. package/dist/dashboard/web/skills-page.js.map +1 -1
  522. package/dist/dashboard/web/store.d.ts +27 -2
  523. package/dist/dashboard/web/store.d.ts.map +1 -1
  524. package/dist/dashboard/web/store.js +43 -4
  525. package/dist/dashboard/web/store.js.map +1 -1
  526. package/dist/dashboard/web/ui.d.ts +3 -0
  527. package/dist/dashboard/web/ui.d.ts.map +1 -1
  528. package/dist/dashboard/web/ui.js +11 -0
  529. package/dist/dashboard/web/ui.js.map +1 -1
  530. package/dist/dashboard/web/update-action.d.ts +12 -0
  531. package/dist/dashboard/web/update-action.d.ts.map +1 -1
  532. package/dist/dashboard/web/update-action.js +11 -0
  533. package/dist/dashboard/web/update-action.js.map +1 -1
  534. package/dist/dashboard/workbench-doctor.d.ts +114 -0
  535. package/dist/dashboard/workbench-doctor.d.ts.map +1 -0
  536. package/dist/dashboard/workbench-doctor.js +620 -0
  537. package/dist/dashboard/workbench-doctor.js.map +1 -0
  538. package/dist/dashboard/workbench-ticket.d.ts +165 -0
  539. package/dist/dashboard/workbench-ticket.d.ts.map +1 -0
  540. package/dist/dashboard/workbench-ticket.js +495 -0
  541. package/dist/dashboard/workbench-ticket.js.map +1 -0
  542. package/dist/dashboard-web/app.js +1 -1
  543. package/dist/dashboard-web/chunks/agent-workbench-dock-page-IKAC5CFL.js +1 -0
  544. package/dist/dashboard-web/chunks/agent-workbench-page-M53UN5EB.js +1 -0
  545. package/dist/dashboard-web/chunks/bot-defaults-page-YKE5SDZF.js +10 -0
  546. package/dist/dashboard-web/chunks/chunk-22WIADUT.js +2 -0
  547. package/dist/dashboard-web/chunks/chunk-24ONYQMR.js +1 -0
  548. package/dist/dashboard-web/chunks/{chunk-6O7KXFD2.js → chunk-2W6SCN3M.js} +1 -1
  549. package/dist/dashboard-web/chunks/chunk-4XNJX6B3.js +1 -0
  550. package/dist/dashboard-web/chunks/{chunk-Q2MT4VWH.js → chunk-F6KNPF4R.js} +11 -9
  551. package/dist/dashboard-web/chunks/chunk-FXW3V4JR.js +1 -0
  552. package/dist/dashboard-web/chunks/chunk-G5ZS2YUS.js +1 -0
  553. package/dist/dashboard-web/chunks/chunk-KTQ7B6ZR.js +1 -0
  554. package/dist/dashboard-web/chunks/{chunk-U3ZFSO7E.js → chunk-NACP7BMR.js} +1 -1
  555. package/dist/dashboard-web/chunks/{connectors-page-2KZO5KSJ.js → connectors-page-VOISXXII.js} +1 -1
  556. package/dist/dashboard-web/chunks/{feedback-page-CLVTOLLO.js → feedback-page-RN6HRZMS.js} +1 -1
  557. package/dist/dashboard-web/chunks/groups-page-UQT6DCB7.js +8 -0
  558. package/dist/dashboard-web/chunks/{insights-page-4RPU2CRU.js → insights-page-HJFDYR5N.js} +3 -3
  559. package/dist/dashboard-web/chunks/{monitor-room-OTKQ2CXK.js → monitor-room-V7PCP47V.js} +1 -1
  560. package/dist/dashboard-web/chunks/{monitoring-page-IJPUB6JT.js → monitoring-page-NKEKVQAP.js} +1 -1
  561. package/dist/dashboard-web/chunks/{office-page-QSR3J44Y.js → office-page-GVJF73XW.js} +1 -1
  562. package/dist/dashboard-web/chunks/overview-page-KHLV6VTI.js +1 -0
  563. package/dist/dashboard-web/chunks/{plugin-page-VEGTCEAS.js → plugin-page-J3OF5IY4.js} +1 -1
  564. package/dist/dashboard-web/chunks/{roles-page-6NWJMOB5.js → roles-page-WQIRSOLZ.js} +1 -1
  565. package/dist/dashboard-web/chunks/{schedules-page-6I3LNXD4.js → schedules-page-J2DEY2X6.js} +1 -1
  566. package/dist/dashboard-web/chunks/sessions-page-7BQFEA5P.js +8 -0
  567. package/dist/dashboard-web/chunks/settings-page-BJEIOFJH.js +2 -0
  568. package/dist/dashboard-web/chunks/{skills-page-M2Q6L5CB.js → skills-page-HGIFR3IU.js} +2 -2
  569. package/dist/dashboard-web/chunks/{team-federation-page-7I7FDE3B.js → team-federation-page-MR5ZPL4B.js} +1 -1
  570. package/dist/dashboard-web/chunks/{v3-page-HQXRL65L.js → v3-page-GBR5JWPE.js} +2 -2
  571. package/dist/dashboard-web/chunks/{whiteboards-page-LQKC4TAZ.js → whiteboards-page-QAZM4BN3.js} +1 -1
  572. package/dist/dashboard-web/index.html +8 -1
  573. package/dist/dashboard-web/style.css +2006 -10
  574. package/dist/dashboard.js +1017 -264
  575. package/dist/dashboard.js.map +1 -1
  576. package/dist/dsh-runner.js +8 -1
  577. package/dist/dsh-runner.js.map +1 -1
  578. package/dist/global-config.d.ts +30 -0
  579. package/dist/global-config.d.ts.map +1 -1
  580. package/dist/global-config.js +33 -0
  581. package/dist/global-config.js.map +1 -1
  582. package/dist/i18n/en.d.ts.map +1 -1
  583. package/dist/i18n/en.js +46 -27
  584. package/dist/i18n/en.js.map +1 -1
  585. package/dist/i18n/zh.d.ts.map +1 -1
  586. package/dist/i18n/zh.js +43 -27
  587. package/dist/i18n/zh.js.map +1 -1
  588. package/dist/im/lark/card-builder.d.ts +1 -1
  589. package/dist/im/lark/card-builder.d.ts.map +1 -1
  590. package/dist/im/lark/card-builder.js +22 -6
  591. package/dist/im/lark/card-builder.js.map +1 -1
  592. package/dist/im/lark/card-handler.d.ts.map +1 -1
  593. package/dist/im/lark/card-handler.js +118 -24
  594. package/dist/im/lark/card-handler.js.map +1 -1
  595. package/dist/im/lark/client.d.ts +15 -0
  596. package/dist/im/lark/client.d.ts.map +1 -1
  597. package/dist/im/lark/client.js +30 -0
  598. package/dist/im/lark/client.js.map +1 -1
  599. package/dist/im/lark/event-dispatcher.d.ts +48 -0
  600. package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
  601. package/dist/im/lark/event-dispatcher.js +138 -41
  602. package/dist/im/lark/event-dispatcher.js.map +1 -1
  603. package/dist/im/lark/identity-cache.d.ts +14 -6
  604. package/dist/im/lark/identity-cache.d.ts.map +1 -1
  605. package/dist/im/lark/identity-cache.js +69 -26
  606. package/dist/im/lark/identity-cache.js.map +1 -1
  607. package/dist/im/lark/lark-hosts.d.ts +13 -0
  608. package/dist/im/lark/lark-hosts.d.ts.map +1 -1
  609. package/dist/im/lark/lark-hosts.js +16 -0
  610. package/dist/im/lark/lark-hosts.js.map +1 -1
  611. package/dist/im/lark/overview-card.d.ts +22 -0
  612. package/dist/im/lark/overview-card.d.ts.map +1 -1
  613. package/dist/im/lark/overview-card.js +53 -3
  614. package/dist/im/lark/overview-card.js.map +1 -1
  615. package/dist/im/lark/sessions-card.d.ts.map +1 -1
  616. package/dist/im/lark/sessions-card.js +26 -3
  617. package/dist/im/lark/sessions-card.js.map +1 -1
  618. package/dist/im/lark/workflow-slash-command.d.ts +6 -0
  619. package/dist/im/lark/workflow-slash-command.d.ts.map +1 -1
  620. package/dist/im/lark/workflow-slash-command.js +7 -0
  621. package/dist/im/lark/workflow-slash-command.js.map +1 -1
  622. package/dist/index-daemon.js +27 -4
  623. package/dist/index-daemon.js.map +1 -1
  624. package/dist/index-dashboard.d.ts +3 -0
  625. package/dist/index-dashboard.d.ts.map +1 -0
  626. package/dist/index-dashboard.js +94 -0
  627. package/dist/index-dashboard.js.map +1 -0
  628. package/dist/platform/team-agents-client.d.ts +199 -0
  629. package/dist/platform/team-agents-client.d.ts.map +1 -0
  630. package/dist/platform/team-agents-client.js +263 -0
  631. package/dist/platform/team-agents-client.js.map +1 -0
  632. package/dist/platform/tunnel-client.d.ts +6 -0
  633. package/dist/platform/tunnel-client.d.ts.map +1 -1
  634. package/dist/platform/tunnel-client.js.map +1 -1
  635. package/dist/services/async-trigger-state.d.ts +7 -3
  636. package/dist/services/async-trigger-state.d.ts.map +1 -1
  637. package/dist/services/async-trigger-state.js +28 -0
  638. package/dist/services/async-trigger-state.js.map +1 -1
  639. package/dist/services/async-trigger-store.d.ts +13 -4
  640. package/dist/services/async-trigger-store.d.ts.map +1 -1
  641. package/dist/services/async-trigger-store.js +55 -8
  642. package/dist/services/async-trigger-store.js.map +1 -1
  643. package/dist/services/bot-config-store.d.ts +1 -11
  644. package/dist/services/bot-config-store.d.ts.map +1 -1
  645. package/dist/services/bot-config-store.js +27 -3
  646. package/dist/services/bot-config-store.js.map +1 -1
  647. package/dist/services/bot-profile-store.d.ts +17 -2
  648. package/dist/services/bot-profile-store.d.ts.map +1 -1
  649. package/dist/services/bot-profile-store.js +93 -12
  650. package/dist/services/bot-profile-store.js.map +1 -1
  651. package/dist/services/bridge-fallback-gate.d.ts +15 -7
  652. package/dist/services/bridge-fallback-gate.d.ts.map +1 -1
  653. package/dist/services/bridge-fallback-gate.js +43 -16
  654. package/dist/services/bridge-fallback-gate.js.map +1 -1
  655. package/dist/services/bridge-turn-queue.d.ts +10 -1
  656. package/dist/services/bridge-turn-queue.d.ts.map +1 -1
  657. package/dist/services/bridge-turn-queue.js +29 -9
  658. package/dist/services/bridge-turn-queue.js.map +1 -1
  659. package/dist/services/claude-transcript.d.ts +19 -0
  660. package/dist/services/claude-transcript.d.ts.map +1 -1
  661. package/dist/services/claude-transcript.js +57 -5
  662. package/dist/services/claude-transcript.js.map +1 -1
  663. package/dist/services/codex-app-threads.d.ts +2 -0
  664. package/dist/services/codex-app-threads.d.ts.map +1 -1
  665. package/dist/services/codex-app-threads.js +1 -1
  666. package/dist/services/codex-app-threads.js.map +1 -1
  667. package/dist/services/codex-reasoning-effort.d.ts +8 -0
  668. package/dist/services/codex-reasoning-effort.d.ts.map +1 -1
  669. package/dist/services/codex-reasoning-effort.js +24 -0
  670. package/dist/services/codex-reasoning-effort.js.map +1 -1
  671. package/dist/services/cursor-resume-policy.d.ts.map +1 -1
  672. package/dist/services/cursor-resume-policy.js +15 -3
  673. package/dist/services/cursor-resume-policy.js.map +1 -1
  674. package/dist/services/open-platform-rename.d.ts.map +1 -1
  675. package/dist/services/open-platform-rename.js +3 -2
  676. package/dist/services/open-platform-rename.js.map +1 -1
  677. package/dist/services/ordinary-turn-recovery.d.ts +76 -0
  678. package/dist/services/ordinary-turn-recovery.d.ts.map +1 -0
  679. package/dist/services/ordinary-turn-recovery.js +349 -0
  680. package/dist/services/ordinary-turn-recovery.js.map +1 -0
  681. package/dist/services/peer-cross-ref-store.d.ts +8 -0
  682. package/dist/services/peer-cross-ref-store.d.ts.map +1 -0
  683. package/dist/services/peer-cross-ref-store.js +95 -0
  684. package/dist/services/peer-cross-ref-store.js.map +1 -0
  685. package/dist/services/pi-transcript.d.ts.map +1 -1
  686. package/dist/services/pi-transcript.js +10 -6
  687. package/dist/services/pi-transcript.js.map +1 -1
  688. package/dist/services/resume-fresh-policy.d.ts +17 -0
  689. package/dist/services/resume-fresh-policy.d.ts.map +1 -0
  690. package/dist/services/resume-fresh-policy.js +24 -0
  691. package/dist/services/resume-fresh-policy.js.map +1 -0
  692. package/dist/services/session-group-title.d.ts +1 -0
  693. package/dist/services/session-group-title.d.ts.map +1 -1
  694. package/dist/services/session-group-title.js +16 -1
  695. package/dist/services/session-group-title.js.map +1 -1
  696. package/dist/services/session-groups-store.d.ts +30 -0
  697. package/dist/services/session-groups-store.d.ts.map +1 -1
  698. package/dist/services/session-groups-store.js +26 -4
  699. package/dist/services/session-groups-store.js.map +1 -1
  700. package/dist/services/session-owner-notification.d.ts +9 -0
  701. package/dist/services/session-owner-notification.d.ts.map +1 -0
  702. package/dist/services/session-owner-notification.js +10 -0
  703. package/dist/services/session-owner-notification.js.map +1 -0
  704. package/dist/services/session-owner-reminder-config-store.d.ts +9 -0
  705. package/dist/services/session-owner-reminder-config-store.d.ts.map +1 -0
  706. package/dist/services/session-owner-reminder-config-store.js +24 -0
  707. package/dist/services/session-owner-reminder-config-store.js.map +1 -0
  708. package/dist/services/session-owner-reminder-store.d.ts +5 -0
  709. package/dist/services/session-owner-reminder-store.d.ts.map +1 -0
  710. package/dist/services/session-owner-reminder-store.js +54 -0
  711. package/dist/services/session-owner-reminder-store.js.map +1 -0
  712. package/dist/services/session-store.d.ts +98 -21
  713. package/dist/services/session-store.d.ts.map +1 -1
  714. package/dist/services/session-store.js +406 -48
  715. package/dist/services/session-store.js.map +1 -1
  716. package/dist/services/structured-bridge-clis.d.ts +15 -2
  717. package/dist/services/structured-bridge-clis.d.ts.map +1 -1
  718. package/dist/services/structured-bridge-clis.js +16 -1
  719. package/dist/services/structured-bridge-clis.js.map +1 -1
  720. package/dist/services/transcript-resolver.d.ts +1 -1
  721. package/dist/services/transcript-resolver.d.ts.map +1 -1
  722. package/dist/services/transcript-resolver.js +6 -1
  723. package/dist/services/transcript-resolver.js.map +1 -1
  724. package/dist/setup/bot-config-editor.d.ts.map +1 -1
  725. package/dist/setup/bot-config-editor.js +7 -2
  726. package/dist/setup/bot-config-editor.js.map +1 -1
  727. package/dist/setup/ensure-herdr-integrations.d.ts +13 -0
  728. package/dist/setup/ensure-herdr-integrations.d.ts.map +1 -1
  729. package/dist/setup/ensure-herdr-integrations.js +21 -3
  730. package/dist/setup/ensure-herdr-integrations.js.map +1 -1
  731. package/dist/setup/open-platform-automation.d.ts +1 -0
  732. package/dist/setup/open-platform-automation.d.ts.map +1 -1
  733. package/dist/setup/open-platform-automation.js +107 -7
  734. package/dist/setup/open-platform-automation.js.map +1 -1
  735. package/dist/skills/definitions.d.ts +17 -0
  736. package/dist/skills/definitions.d.ts.map +1 -1
  737. package/dist/skills/definitions.js +78 -8
  738. package/dist/skills/definitions.js.map +1 -1
  739. package/dist/skills/injection-mode.d.ts +24 -3
  740. package/dist/skills/injection-mode.d.ts.map +1 -1
  741. package/dist/skills/injection-mode.js +64 -15
  742. package/dist/skills/injection-mode.js.map +1 -1
  743. package/dist/skills/installer.d.ts +18 -0
  744. package/dist/skills/installer.d.ts.map +1 -1
  745. package/dist/skills/installer.js +45 -1
  746. package/dist/skills/installer.js.map +1 -1
  747. package/dist/types.d.ts +222 -10
  748. package/dist/types.d.ts.map +1 -1
  749. package/dist/utils/bot-routing.d.ts +1 -1
  750. package/dist/utils/bot-routing.d.ts.map +1 -1
  751. package/dist/utils/bot-routing.js.map +1 -1
  752. package/dist/utils/child-env.d.ts +92 -2
  753. package/dist/utils/child-env.d.ts.map +1 -1
  754. package/dist/utils/child-env.js +195 -1
  755. package/dist/utils/child-env.js.map +1 -1
  756. package/dist/utils/cli-usage-limit.d.ts +25 -14
  757. package/dist/utils/cli-usage-limit.d.ts.map +1 -1
  758. package/dist/utils/cli-usage-limit.js +25 -15
  759. package/dist/utils/cli-usage-limit.js.map +1 -1
  760. package/dist/utils/daemon-rejection-guard.d.ts +35 -0
  761. package/dist/utils/daemon-rejection-guard.d.ts.map +1 -0
  762. package/dist/utils/daemon-rejection-guard.js +101 -0
  763. package/dist/utils/daemon-rejection-guard.js.map +1 -0
  764. package/dist/utils/dashboard-env.d.ts +53 -0
  765. package/dist/utils/dashboard-env.d.ts.map +1 -0
  766. package/dist/utils/dashboard-env.js +116 -0
  767. package/dist/utils/dashboard-env.js.map +1 -0
  768. package/dist/utils/global-install.d.ts.map +1 -1
  769. package/dist/utils/global-install.js +61 -5
  770. package/dist/utils/global-install.js.map +1 -1
  771. package/dist/utils/install-diagnostics.d.ts +14 -7
  772. package/dist/utils/install-diagnostics.d.ts.map +1 -1
  773. package/dist/utils/install-diagnostics.js +20 -11
  774. package/dist/utils/install-diagnostics.js.map +1 -1
  775. package/dist/utils/local-dev-update.d.ts +132 -0
  776. package/dist/utils/local-dev-update.d.ts.map +1 -0
  777. package/dist/utils/local-dev-update.js +176 -0
  778. package/dist/utils/local-dev-update.js.map +1 -0
  779. package/dist/utils/pending-input-queue.d.ts +12 -1
  780. package/dist/utils/pending-input-queue.d.ts.map +1 -1
  781. package/dist/utils/pending-input-queue.js.map +1 -1
  782. package/dist/worker.js +1517 -236
  783. package/dist/worker.js.map +1 -1
  784. package/dist/workflows/definition.d.ts +68 -68
  785. package/dist/workflows/events/payloads.d.ts +14 -14
  786. package/dist/workflows/events/schema.d.ts +312 -312
  787. package/dist/workflows/migration/v2-run-archive-schema.d.ts +40 -40
  788. package/dist/workflows/v3/cli-run.d.ts.map +1 -1
  789. package/dist/workflows/v3/cli-run.js +7 -0
  790. package/dist/workflows/v3/cli-run.js.map +1 -1
  791. package/dist/workflows/v3/goal-cli.d.ts +3 -0
  792. package/dist/workflows/v3/goal-cli.d.ts.map +1 -1
  793. package/dist/workflows/v3/goal-cli.js +11 -0
  794. package/dist/workflows/v3/goal-cli.js.map +1 -1
  795. package/dist/workflows/v3/run-envelope.d.ts +144 -144
  796. package/package.json +7 -2
  797. package/dist/cli/pm2-god-admission.d.ts +0 -8
  798. package/dist/cli/pm2-god-admission.d.ts.map +0 -1
  799. package/dist/cli/pm2-god-admission.js +0 -25
  800. package/dist/cli/pm2-god-admission.js.map +0 -1
  801. package/dist/core/riff-shutdown-detach.d.ts.map +0 -1
  802. package/dist/core/riff-shutdown-detach.js.map +0 -1
  803. package/dist/core/riff-worker-shutdown-readiness.d.ts.map +0 -1
  804. package/dist/core/riff-worker-shutdown-readiness.js.map +0 -1
  805. package/dist/dashboard-web/chunks/bot-defaults-page-4RENHE7J.js +0 -10
  806. package/dist/dashboard-web/chunks/chunk-2WQDS65D.js +0 -1
  807. package/dist/dashboard-web/chunks/chunk-G5XGBCM6.js +0 -1
  808. package/dist/dashboard-web/chunks/chunk-WLIVBPJC.js +0 -1
  809. package/dist/dashboard-web/chunks/groups-page-HLASRTSY.js +0 -8
  810. package/dist/dashboard-web/chunks/overview-page-6OK63V4V.js +0 -1
  811. package/dist/dashboard-web/chunks/sessions-page-B2TXGJDO.js +0 -8
  812. package/dist/dashboard-web/chunks/settings-page-6KJADSC6.js +0 -2
@@ -1,4 +1,4 @@
1
- import{c as Z}from"./chunk-2WQDS65D.js";import{b as Ye,c as vl,d as ue,h as bl,l as hl}from"./chunk-5CJMHTT4.js";import"./chunk-G5XGBCM6.js";import{x as Ve}from"./chunk-Q2MT4VWH.js";import{a as fl}from"./chunk-SYC6D5XU.js";import{a as Ae,b as ds,d as de}from"./chunk-5THX4DI2.js";import{c as ee}from"./chunk-7SZRL6FY.js";var c=ee(Ae(),1),Bl=ee(ds(),1);var J=ee(Ae(),1);var k=ee(de(),1);function us(e){return(e.missingSkills?.length??0)>0?"missing":(e.references?.length??0)===0?"unassigned":"complete"}function yl(e){let l=Z(),n=e.packs??[],m=e.skills??[],[f,p]=(0,J.useState)(!1),[g,S]=(0,J.useState)(null),[o,D]=(0,J.useState)(null),[B,v]=(0,J.useState)(null),[C,w]=(0,J.useState)(!1),h=()=>{S(null),p(!0)},x=y=>{S(y),p(!0)},[E,T]=(0,J.useState)(()=>new Set),{focusPackId:L,focusPackIds:A,onFocusConsumed:$}=e;(0,J.useEffect)(()=>{if(!(!L&&(A?.length??0)===0)){if(L){let y=n.find(b=>b.id===L);y&&(S(y),p(!0)),T(new Set([L]))}else A&&T(new Set(A));$?.()}},[L,A]);let H=()=>{p(!1),S(null),D({text:l("skills.saved"),ok:!0}),e.onRefresh()},K=async y=>{try{let b=await fetch(`/api/skill-packs/${encodeURIComponent(y.id)}`,{method:"DELETE"}),I=await b.json().catch(()=>({}));if(b.ok){D({text:l("skills.packDeleted",{name:y.name}),ok:!0}),e.onRefresh();return}if(b.status===409&&I?.error==="SKILL_PACK_IN_USE"){let d=Array.isArray(I?.references)?I.references:y.references??[];v({pack:y,references:d});return}throw new Error(I?.error??`HTTP ${b.status}`)}catch(b){D({text:`${l("skills.failed")}: ${b?.message??b}`,ok:!1})}},F=async()=>{if(B){w(!0);try{let y=await fetch(`/api/skill-packs/${encodeURIComponent(B.pack.id)}?force=1`,{method:"DELETE"}),b=await y.json().catch(()=>({}));if(!y.ok)throw new Error(b?.error??`HTTP ${y.status}`);D({text:l("skills.packDeleted",{name:B.pack.name}),ok:!0}),v(null),e.onRefresh()}catch(y){D({text:`${l("skills.failed")}: ${y?.message??y}`,ok:!1})}finally{w(!1)}}};return(0,k.jsxs)("section",{className:"skills-config-block",children:[(0,k.jsx)(ue,{title:l("skills.packs"),count:e.packsKnown===!1?"\u2014":l("skills.packCount",{count:n.length}),hint:l("skills.packsHelp")}),o&&(0,k.jsx)("p",{className:`hint-${o.ok?"ok":"warn"}`,children:o.text}),(0,k.jsx)("div",{className:"bd-card skills-config-card",children:e.packsKnown===!1&&n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state","data-packs-unknown":!0,children:[(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packsUnknown")}),(0,k.jsx)("button",{className:"bd-button",onClick:()=>e.onRefresh(),children:l("skills.refresh")})]}):n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state",children:[(0,k.jsx)("p",{children:l("skills.packsEmpty")}),(0,k.jsx)("button",{className:"bd-button primary",onClick:h,children:l("skills.packCreate")})]}):(0,k.jsxs)("div",{className:"skills-pack-grid",children:[(0,k.jsxs)("button",{className:"skills-pack-create-tile",onClick:h,children:[(0,k.jsx)("span",{className:"skills-pack-create-plus",children:"+"}),(0,k.jsx)("span",{children:l("skills.packCreate")})]}),n.map(y=>{let b=us(y);return(0,k.jsxs)("div",{className:`skills-pack-card${E.has(y.id)?" skills-pack-card-focus":""}`,children:[(0,k.jsxs)("div",{className:"skills-pack-card-head",children:[(0,k.jsxs)("div",{className:"skills-pack-title",children:[(0,k.jsx)("strong",{children:y.name}),(0,k.jsx)("code",{className:"skills-pack-id",children:y.id})]}),(0,k.jsx)("span",{className:`skills-pack-health skills-pack-health-${b}`,children:b==="complete"?"\u2713":b==="missing"?"!":"\u25CB"})]}),y.description&&(0,k.jsx)("p",{className:"skills-pack-desc",children:y.description}),(0,k.jsxs)("div",{className:"skills-pack-meta",children:[(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.skillCount",{count:y.include.length})}),(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.packRefCount",{count:y.references?.length??0})})]}),y.tags&&y.tags.length>0&&(0,k.jsx)("div",{className:"skills-pack-tags",children:y.tags.map(I=>(0,k.jsx)("span",{className:"skills-pack-tag",children:I},I))}),(y.references?.length??0)>0&&(0,k.jsx)("div",{className:"skills-pack-refs",children:y.references.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-pack-ref-chip","data-action":"open-pack-bot",disabled:!e.onOpenBot,onClick:()=>e.onOpenBot?.(I.larkAppId),children:I.botName},I.larkAppId))}),(y.missingSkills?.length??0)>0&&(0,k.jsxs)("div",{className:"skills-pack-missing",children:[l("skills.packMissing"),":"," ",y.missingSkills.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-missing-skill-chip","data-action":"install-missing-skill",title:l("skills.installMissingHint",{skill:I}),disabled:!e.onInstallMissingSkill,onClick:()=>e.onInstallMissingSkill?.(I),children:I},I))]}),(0,k.jsxs)("div",{className:"skills-pack-actions",children:[(0,k.jsx)("button",{className:"bd-button small",onClick:()=>x(y),children:l("skills.packEdit")}),(0,k.jsx)("button",{className:"bd-button small danger",onClick:()=>{K(y)},children:l("skills.remove")})]})]},y.id)})]})}),f&&(0,k.jsx)(ks,{pack:g,skills:m,onClose:()=>{p(!1),S(null)},onSaved:H}),B&&(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-delete-confirm",open:!0,onClose:()=>!C&&v(null),children:(0,k.jsxs)("form",{method:"dialog",onSubmit:y=>{y.preventDefault(),F()},children:[(0,k.jsx)("h3",{children:l("skills.packDeleteConfirmTitle")}),(0,k.jsx)("p",{children:l("skills.packDeleteConfirmBody",{name:B.pack.name})}),B.references.length>0&&(0,k.jsxs)("div",{className:"skills-pack-delete-refs",children:[(0,k.jsx)("p",{children:(0,k.jsxs)("strong",{children:[l("skills.packDeleteAffectedBots"),":"]})}),(0,k.jsx)("ul",{children:B.references.map(y=>(0,k.jsx)("li",{children:y.botName},y.larkAppId))})]}),(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packDeleteForceWarning")}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:()=>v(null),disabled:C,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button danger",disabled:C,children:l(C?"skills.removing":"skills.removeAnyway")})]})]})})]})}function ks(e){let l=Z(),n=e.skills??[],[m,f]=(0,J.useState)(e.pack?.id??""),[p,g]=(0,J.useState)(e.pack?.name??""),[S,o]=(0,J.useState)(e.pack?.description??""),[D,B]=(0,J.useState)((e.pack?.tags??[]).join(", ")),[v,C]=(0,J.useState)(()=>new Set(e.pack?.include.map(d=>d.replace("skill:",""))??[])),[w,h]=(0,J.useState)(!1),[x,E]=(0,J.useState)(null),[T,L]=(0,J.useState)(""),A=(0,J.useRef)(null),$=(0,J.useMemo)(()=>new Set(n.map(d=>d.name)),[n]),H=(0,J.useMemo)(()=>[...v].filter(d=>!$.has(d)).sort(),[$,v]);(0,J.useEffect)(()=>{let d=A.current;d&&!d.open&&d.showModal()},[]);let K=(0,J.useMemo)(()=>{let d=T.trim().toLowerCase();return d?n.filter(U=>`${U.name} ${U.description??""}`.toLowerCase().includes(d)):n},[n,T]),F=K.length>0&&K.every(d=>v.has(d.name)),y=d=>{C(U=>{let G=new Set(U);return G.has(d)?G.delete(d):G.add(d),G})},b=()=>{C(d=>{let U=new Set(d);if(F)for(let G of K)U.delete(G.name);else for(let G of K)U.add(G.name);return U})},I=async()=>{h(!0),E(null);try{let d={id:m,name:p,description:S||void 0,tags:D.split(",").map(r=>r.trim()).filter(Boolean),include:[...v].map(r=>`skill:${r}`),...e.pack?{expectedRevision:e.pack.revision}:{}},U=e.pack?`/api/skill-packs/${encodeURIComponent(e.pack.id)}`:"/api/skill-packs",G=await fetch(U,{method:e.pack?"PUT":"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)}),te=await G.json().catch(()=>({}));if(!G.ok)throw new Error(te?.error??te?.reason??`HTTP ${G.status}`);e.onSaved()}catch(d){E(d?.message??String(d))}finally{h(!1)}};return(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-editor",ref:A,onClose:e.onClose,children:(0,k.jsxs)("form",{method:"dialog",onSubmit:d=>{d.preventDefault(),I()},children:[(0,k.jsx)("h3",{children:e.pack?l("skills.packEdit"):l("skills.packCreate")}),x&&(0,k.jsx)("p",{className:"hint-warn",children:x}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packId")}),(0,k.jsx)("input",{value:m,onChange:d=>f(d.target.value),disabled:!!e.pack,placeholder:l("skills.packIdPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packName")}),(0,k.jsx)("input",{value:p,onChange:d=>g(d.target.value)})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packDescription")}),(0,k.jsx)("textarea",{value:S,onChange:d=>o(d.target.value),rows:2})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packTags")}),(0,k.jsx)("input",{value:D,onChange:d=>B(d.target.value),placeholder:l("skills.packTagsPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsxs)("div",{className:"skills-pack-include-head",children:[(0,k.jsxs)("label",{children:[l("skills.packInclude")," (",v.size,"/",n.length+H.length,")"]}),(0,k.jsx)("input",{className:"skills-pack-skill-search",type:"text",placeholder:l("skills.searchPlaceholder"),value:T,onChange:d=>L(d.target.value)})]}),K.length>0&&(0,k.jsxs)("label",{className:"skills-pack-select-all",children:[(0,k.jsx)("input",{type:"checkbox",checked:F,onChange:b}),l(F?"skills.deselectAll":"skills.selectAll")]}),H.length>0&&(0,k.jsxs)("div",{className:"skills-pack-missing-editor",children:[(0,k.jsx)("small",{className:"muted",children:l("skills.packMissing")}),H.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item skills-pack-skill-missing","data-missing-skill":d,children:[(0,k.jsx)("input",{type:"checkbox",checked:!0,onChange:()=>y(d)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d}),(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:l("skills.packMissing")})]},d))]}),(0,k.jsxs)("div",{className:"skills-pack-skill-list",children:[K.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,k.jsx)("input",{type:"checkbox",checked:v.has(d.name),onChange:()=>y(d.name)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d.name}),d.description&&(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:d.description})]},d.name)),K.length===0&&(0,k.jsx)("p",{className:"muted",children:l("skills.noResults")})]})]}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:e.onClose,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button primary",disabled:w||v.size===0||!p.trim(),children:l(w?"skills.saving":"skills.saveSelection")})]})]})})}var oe=ee(Ae(),1);var Nl=new Set(["-y","--yes","-g","--global"]);function ms(e){let l=[],n="",m,f=!1;for(let p=0;p<e.length;p++){let g=e[p];if(m){if(g===m){m=void 0;continue}if(g==="\\"&&m==='"'){if(p+1>=e.length)return null;n+=e[++p];continue}n+=g;continue}if(/\s/.test(g)){f&&(l.push(n),n="",f=!1);continue}if(g==="'"||g==='"'){m=g,f=!0;continue}if(g==="\\"){if(p+1>=e.length)return null;n+=e[++p],f=!0;continue}n+=g,f=!0}return m?null:(f&&l.push(n),l)}function Sl(e){for(let l of e)if(!Nl.has(l))return l.startsWith("-")?null:l||null;return null}function wl(e){let l=ms(e);if(!l)return null;let n=l.findIndex(g=>g==="skills"||g==="add-skill"||g.startsWith("skills@"));if(n<0)return null;let m=l[n],f=l.slice(n+1);if(m==="add-skill")return Sl(f);let p=0;for(;Nl.has(f[p]);)p++;return f[p]!=="add"?null:Sl(f.slice(p+1))}var q=ee(de(),1);function Il(e){let[l,n]=(0,oe.useState)(null),m=(0,oe.useRef)(null),{navIntent:f,onNavIntentConsumed:p}=e;(0,oe.useEffect)(()=>{if(f){if(f.openInstallWizard){let S=m.current;S?.scrollIntoView?.({behavior:"smooth",block:"start"}),S?.querySelector('input[data-install="source"]')?.focus()}p?.()}},[f,p]);let g=S=>{!S||S.length===0||S.length>1&&n(S)};return(0,q.jsxs)("div",{className:"skills-page-stack",children:[(0,q.jsx)("div",{className:"skills-install-anchor",ref:m,children:(0,q.jsx)(e.InstallPanel,{installSource:e.installSource,installPath:e.installPath,installRef:e.installRef,installFullDepth:e.installFullDepth,installTargetSkill:e.installTargetSkill??null,installStatus:e.installStatus,installBusy:e.installBusy,installDiscovering:e.installDiscovering,installSelectionOpen:e.installSelectionOpen,installCandidates:e.installCandidates,selectedInstallSkills:e.selectedInstallSkills,onInstallSourceChange:e.onInstallSourceChange,onInstallPathChange:e.onInstallPathChange,onInstallRefChange:e.onInstallRefChange,onInstallFullDepthChange:e.onInstallFullDepthChange,onClearInstallTarget:e.onClearInstallTarget,onToggleInstallSkill:e.onToggleInstallSkill,onSelectAllInstallSkills:e.onSelectAllInstallSkills,onConfirmInstallSelection:()=>{e.onConfirmInstallSelection().then(g)},onCloseInstallSelection:e.onCloseInstallSelection,onInstall:()=>{e.onInstall().then(g)},onOpenNativeDiscovery:e.onOpenNativeDiscovery})}),l&&(0,q.jsx)(gs,{skillNames:l,onClose:()=>n(null),onCreate:async S=>{await e.onCreatePack(S),n(null)}}),(0,q.jsx)(e.InstalledLibrary,{skills:e.skills,busySkill:e.skillBusy,removingNames:e.removingNames,status:e.installedStatus,onUpdate:e.onUpdateSkill,onRequestRemove:e.onRequestRemove,externalQuery:e.navIntent?.librarySearch??null,externalFilterNames:e.navIntent?.libraryFilterSkills??null,packsKnown:e.packsKnown,onInstallMissing:e.onInstallMissing,graph:e.graph,packNames:e.packNames,onShowSkillPacks:e.onShowSkillPacks,onShowSkillBots:e.onShowSkillBots}),(0,q.jsx)(e.RemoveDialog,{names:e.removalDialogOpen?e.pendingRemoval:null,references:e.removalReferences,busy:e.removingNames.size>0,error:e.removalError,onCancel:e.onCancelRemoval,onConfirm:e.onConfirmRemoval})]})}function gs(e){let l=Z(),[n,m]=(0,oe.useState)(""),[f,p]=(0,oe.useState)(""),[g,S]=(0,oe.useState)(!1),[o,D]=(0,oe.useState)(null),B=(0,oe.useRef)(null);(0,oe.useEffect)(()=>{let C=B.current;if(C&&!C.open)try{C.showModal()}catch{}},[]);let v=async()=>{if(!(!n.trim()||!f.trim())){S(!0),D(null);try{await e.onCreate({id:n.trim(),name:f.trim(),skillNames:e.skillNames})}catch(C){D(C?.message??String(C))}finally{S(!1)}}};return(0,q.jsx)("dialog",{className:"bd-dialog skills-post-install-pack",ref:B,onClose:()=>!g&&e.onClose(),children:(0,q.jsxs)("form",{method:"dialog",onSubmit:C=>{C.preventDefault(),v()},children:[(0,q.jsx)("h3",{children:l("skills.postInstallPackTitle")}),(0,q.jsx)("p",{children:l("skills.postInstallPackHelp",{count:e.skillNames.length})}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packId")}),(0,q.jsx)("input",{autoFocus:!0,required:!0,value:n,onChange:C=>m(C.target.value)})]}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packName")}),(0,q.jsx)("input",{required:!0,value:f,onChange:C=>p(C.target.value)})]}),(0,q.jsxs)("div",{className:"skills-resolved-preview",children:[(0,q.jsx)("strong",{children:l("skills.postInstallPackSkills")}),(0,q.jsx)("ul",{children:e.skillNames.map(C=>(0,q.jsx)("li",{children:(0,q.jsx)("code",{children:C})},C))})]}),o&&(0,q.jsx)("p",{className:"hint-warn",children:o}),(0,q.jsxs)("div",{className:"skills-dialog-actions",children:[(0,q.jsx)("button",{type:"button",className:"bd-button",disabled:g,onClick:e.onClose,children:l("skills.postInstallPackSkip")}),(0,q.jsx)("button",{type:"submit",className:"bd-button primary",disabled:g||!n.trim()||!f.trim(),children:l(g?"skills.saving":"skills.postInstallPackCreate")})]})]})})}function el(e){let l=e.trim(),n=l.toLowerCase();if(!l)return"unknown";if(/^agentbuddy:/i.test(l)||/(?:^|\s)(?:npx\s+)?agentbuddy(?:@[\w.-]+)?\s+(?:skill|plugin)\s/i.test(l))return"agentbuddy";let m=wl(l);return m?el(m):n.startsWith("github:")?"github":n.startsWith("git+")||n.startsWith("git@")||n.startsWith("git://")?"git":n.includes("github.com")?"github":n.startsWith("http://")||n.startsWith("https://")||n.endsWith(".git")?"git":/^[/~.]/.test(l)?"local":/^[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9._-]+(?:\/[\w./-]+)?$/.test(l)?"github":l.includes("://")?"unknown":"local"}var Q=ee(Ae(),1);function ps(e,l){let n=String(e??"").replace(/\\/g,"/");return n.includes("/.codex/skills/")?l("skills.sourceCodex"):n.includes("/.claude/skills/")?l("skills.sourceClaude"):n.includes("/.trae/skills/")?l("skills.sourceTrae"):n.includes("/.cursor/skills/")?l("skills.sourceCursor"):n.includes("/.gemini/skills/")?l("skills.sourceGemini"):n.includes("/.config/opencode/skills/")?l("skills.sourceOpenCode"):null}function ll(e,l){let n=e.source??{};return n.type==="github"?`github:${n.owner}/${n.repo}/${n.path??""}`:n.type==="git"?`${n.url??"git"}#${n.path??""}`:n.type==="local-link"?ps(n.path,l)??l("skills.sourceLocalLink"):n.type==="local-copy"?l("skills.sourceBotmuxCopy"):String(n.type??"unknown")}function ke(e){return(e?.include??[]).filter(l=>l.startsWith("skill:")).map(l=>l.slice(6))}function be(e){return(e?.include??[]).filter(l=>l.startsWith("pack:")).map(l=>l.slice(5))}function Cl(e,l,n){let m=(e?.include??[]).filter(g=>!g.startsWith("skill:")&&!g.startsWith("pack:")),f=[...new Set(l.map(g=>g.trim()).filter(Boolean))].map(g=>`skill:${g}`),p=[...new Set(n.map(g=>g.trim()).filter(Boolean))].map(g=>`pack:${g}`);return[...f,...p,...m]}function Pl(e){return(e?.include?.length??0)>0}function Be(e){return`${e.cliId}
1
+ import{b as Ye,c as vl,d as ue,h as bl,l as hl}from"./chunk-5CJMHTT4.js";import{d as Z}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import{C as Ve}from"./chunk-F6KNPF4R.js";import{a as fl}from"./chunk-SYC6D5XU.js";import{a as Ae,b as ds,d as de}from"./chunk-5THX4DI2.js";import{c as ee}from"./chunk-7SZRL6FY.js";var c=ee(Ae(),1),Bl=ee(ds(),1);var J=ee(Ae(),1);var k=ee(de(),1);function us(e){return(e.missingSkills?.length??0)>0?"missing":(e.references?.length??0)===0?"unassigned":"complete"}function yl(e){let l=Z(),n=e.packs??[],m=e.skills??[],[f,p]=(0,J.useState)(!1),[g,S]=(0,J.useState)(null),[o,D]=(0,J.useState)(null),[B,v]=(0,J.useState)(null),[C,w]=(0,J.useState)(!1),h=()=>{S(null),p(!0)},x=y=>{S(y),p(!0)},[E,T]=(0,J.useState)(()=>new Set),{focusPackId:L,focusPackIds:A,onFocusConsumed:$}=e;(0,J.useEffect)(()=>{if(!(!L&&(A?.length??0)===0)){if(L){let y=n.find(b=>b.id===L);y&&(S(y),p(!0)),T(new Set([L]))}else A&&T(new Set(A));$?.()}},[L,A]);let H=()=>{p(!1),S(null),D({text:l("skills.saved"),ok:!0}),e.onRefresh()},K=async y=>{try{let b=await fetch(`/api/skill-packs/${encodeURIComponent(y.id)}`,{method:"DELETE"}),I=await b.json().catch(()=>({}));if(b.ok){D({text:l("skills.packDeleted",{name:y.name}),ok:!0}),e.onRefresh();return}if(b.status===409&&I?.error==="SKILL_PACK_IN_USE"){let d=Array.isArray(I?.references)?I.references:y.references??[];v({pack:y,references:d});return}throw new Error(I?.error??`HTTP ${b.status}`)}catch(b){D({text:`${l("skills.failed")}: ${b?.message??b}`,ok:!1})}},F=async()=>{if(B){w(!0);try{let y=await fetch(`/api/skill-packs/${encodeURIComponent(B.pack.id)}?force=1`,{method:"DELETE"}),b=await y.json().catch(()=>({}));if(!y.ok)throw new Error(b?.error??`HTTP ${y.status}`);D({text:l("skills.packDeleted",{name:B.pack.name}),ok:!0}),v(null),e.onRefresh()}catch(y){D({text:`${l("skills.failed")}: ${y?.message??y}`,ok:!1})}finally{w(!1)}}};return(0,k.jsxs)("section",{className:"skills-config-block",children:[(0,k.jsx)(ue,{title:l("skills.packs"),count:e.packsKnown===!1?"\u2014":l("skills.packCount",{count:n.length}),hint:l("skills.packsHelp")}),o&&(0,k.jsx)("p",{className:`hint-${o.ok?"ok":"warn"}`,children:o.text}),(0,k.jsx)("div",{className:"bd-card skills-config-card",children:e.packsKnown===!1&&n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state","data-packs-unknown":!0,children:[(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packsUnknown")}),(0,k.jsx)("button",{className:"bd-button",onClick:()=>e.onRefresh(),children:l("skills.refresh")})]}):n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state",children:[(0,k.jsx)("p",{children:l("skills.packsEmpty")}),(0,k.jsx)("button",{className:"bd-button primary",onClick:h,children:l("skills.packCreate")})]}):(0,k.jsxs)("div",{className:"skills-pack-grid",children:[(0,k.jsxs)("button",{className:"skills-pack-create-tile",onClick:h,children:[(0,k.jsx)("span",{className:"skills-pack-create-plus",children:"+"}),(0,k.jsx)("span",{children:l("skills.packCreate")})]}),n.map(y=>{let b=us(y);return(0,k.jsxs)("div",{className:`skills-pack-card${E.has(y.id)?" skills-pack-card-focus":""}`,children:[(0,k.jsxs)("div",{className:"skills-pack-card-head",children:[(0,k.jsxs)("div",{className:"skills-pack-title",children:[(0,k.jsx)("strong",{children:y.name}),(0,k.jsx)("code",{className:"skills-pack-id",children:y.id})]}),(0,k.jsx)("span",{className:`skills-pack-health skills-pack-health-${b}`,children:b==="complete"?"\u2713":b==="missing"?"!":"\u25CB"})]}),y.description&&(0,k.jsx)("p",{className:"skills-pack-desc",children:y.description}),(0,k.jsxs)("div",{className:"skills-pack-meta",children:[(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.skillCount",{count:y.include.length})}),(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.packRefCount",{count:y.references?.length??0})})]}),y.tags&&y.tags.length>0&&(0,k.jsx)("div",{className:"skills-pack-tags",children:y.tags.map(I=>(0,k.jsx)("span",{className:"skills-pack-tag",children:I},I))}),(y.references?.length??0)>0&&(0,k.jsx)("div",{className:"skills-pack-refs",children:y.references.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-pack-ref-chip","data-action":"open-pack-bot",disabled:!e.onOpenBot,onClick:()=>e.onOpenBot?.(I.larkAppId),children:I.botName},I.larkAppId))}),(y.missingSkills?.length??0)>0&&(0,k.jsxs)("div",{className:"skills-pack-missing",children:[l("skills.packMissing"),":"," ",y.missingSkills.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-missing-skill-chip","data-action":"install-missing-skill",title:l("skills.installMissingHint",{skill:I}),disabled:!e.onInstallMissingSkill,onClick:()=>e.onInstallMissingSkill?.(I),children:I},I))]}),(0,k.jsxs)("div",{className:"skills-pack-actions",children:[(0,k.jsx)("button",{className:"bd-button small",onClick:()=>x(y),children:l("skills.packEdit")}),(0,k.jsx)("button",{className:"bd-button small danger",onClick:()=>{K(y)},children:l("skills.remove")})]})]},y.id)})]})}),f&&(0,k.jsx)(ks,{pack:g,skills:m,onClose:()=>{p(!1),S(null)},onSaved:H}),B&&(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-delete-confirm",open:!0,onClose:()=>!C&&v(null),children:(0,k.jsxs)("form",{method:"dialog",onSubmit:y=>{y.preventDefault(),F()},children:[(0,k.jsx)("h3",{children:l("skills.packDeleteConfirmTitle")}),(0,k.jsx)("p",{children:l("skills.packDeleteConfirmBody",{name:B.pack.name})}),B.references.length>0&&(0,k.jsxs)("div",{className:"skills-pack-delete-refs",children:[(0,k.jsx)("p",{children:(0,k.jsxs)("strong",{children:[l("skills.packDeleteAffectedBots"),":"]})}),(0,k.jsx)("ul",{children:B.references.map(y=>(0,k.jsx)("li",{children:y.botName},y.larkAppId))})]}),(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packDeleteForceWarning")}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:()=>v(null),disabled:C,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button danger",disabled:C,children:l(C?"skills.removing":"skills.removeAnyway")})]})]})})]})}function ks(e){let l=Z(),n=e.skills??[],[m,f]=(0,J.useState)(e.pack?.id??""),[p,g]=(0,J.useState)(e.pack?.name??""),[S,o]=(0,J.useState)(e.pack?.description??""),[D,B]=(0,J.useState)((e.pack?.tags??[]).join(", ")),[v,C]=(0,J.useState)(()=>new Set(e.pack?.include.map(d=>d.replace("skill:",""))??[])),[w,h]=(0,J.useState)(!1),[x,E]=(0,J.useState)(null),[T,L]=(0,J.useState)(""),A=(0,J.useRef)(null),$=(0,J.useMemo)(()=>new Set(n.map(d=>d.name)),[n]),H=(0,J.useMemo)(()=>[...v].filter(d=>!$.has(d)).sort(),[$,v]);(0,J.useEffect)(()=>{let d=A.current;d&&!d.open&&d.showModal()},[]);let K=(0,J.useMemo)(()=>{let d=T.trim().toLowerCase();return d?n.filter(U=>`${U.name} ${U.description??""}`.toLowerCase().includes(d)):n},[n,T]),F=K.length>0&&K.every(d=>v.has(d.name)),y=d=>{C(U=>{let G=new Set(U);return G.has(d)?G.delete(d):G.add(d),G})},b=()=>{C(d=>{let U=new Set(d);if(F)for(let G of K)U.delete(G.name);else for(let G of K)U.add(G.name);return U})},I=async()=>{h(!0),E(null);try{let d={id:m,name:p,description:S||void 0,tags:D.split(",").map(r=>r.trim()).filter(Boolean),include:[...v].map(r=>`skill:${r}`),...e.pack?{expectedRevision:e.pack.revision}:{}},U=e.pack?`/api/skill-packs/${encodeURIComponent(e.pack.id)}`:"/api/skill-packs",G=await fetch(U,{method:e.pack?"PUT":"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)}),te=await G.json().catch(()=>({}));if(!G.ok)throw new Error(te?.error??te?.reason??`HTTP ${G.status}`);e.onSaved()}catch(d){E(d?.message??String(d))}finally{h(!1)}};return(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-editor",ref:A,onClose:e.onClose,children:(0,k.jsxs)("form",{method:"dialog",onSubmit:d=>{d.preventDefault(),I()},children:[(0,k.jsx)("h3",{children:e.pack?l("skills.packEdit"):l("skills.packCreate")}),x&&(0,k.jsx)("p",{className:"hint-warn",children:x}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packId")}),(0,k.jsx)("input",{value:m,onChange:d=>f(d.target.value),disabled:!!e.pack,placeholder:l("skills.packIdPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packName")}),(0,k.jsx)("input",{value:p,onChange:d=>g(d.target.value)})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packDescription")}),(0,k.jsx)("textarea",{value:S,onChange:d=>o(d.target.value),rows:2})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packTags")}),(0,k.jsx)("input",{value:D,onChange:d=>B(d.target.value),placeholder:l("skills.packTagsPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsxs)("div",{className:"skills-pack-include-head",children:[(0,k.jsxs)("label",{children:[l("skills.packInclude")," (",v.size,"/",n.length+H.length,")"]}),(0,k.jsx)("input",{className:"skills-pack-skill-search",type:"text",placeholder:l("skills.searchPlaceholder"),value:T,onChange:d=>L(d.target.value)})]}),K.length>0&&(0,k.jsxs)("label",{className:"skills-pack-select-all",children:[(0,k.jsx)("input",{type:"checkbox",checked:F,onChange:b}),l(F?"skills.deselectAll":"skills.selectAll")]}),H.length>0&&(0,k.jsxs)("div",{className:"skills-pack-missing-editor",children:[(0,k.jsx)("small",{className:"muted",children:l("skills.packMissing")}),H.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item skills-pack-skill-missing","data-missing-skill":d,children:[(0,k.jsx)("input",{type:"checkbox",checked:!0,onChange:()=>y(d)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d}),(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:l("skills.packMissing")})]},d))]}),(0,k.jsxs)("div",{className:"skills-pack-skill-list",children:[K.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,k.jsx)("input",{type:"checkbox",checked:v.has(d.name),onChange:()=>y(d.name)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d.name}),d.description&&(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:d.description})]},d.name)),K.length===0&&(0,k.jsx)("p",{className:"muted",children:l("skills.noResults")})]})]}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:e.onClose,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button primary",disabled:w||v.size===0||!p.trim(),children:l(w?"skills.saving":"skills.saveSelection")})]})]})})}var oe=ee(Ae(),1);var Nl=new Set(["-y","--yes","-g","--global"]);function ms(e){let l=[],n="",m,f=!1;for(let p=0;p<e.length;p++){let g=e[p];if(m){if(g===m){m=void 0;continue}if(g==="\\"&&m==='"'){if(p+1>=e.length)return null;n+=e[++p];continue}n+=g;continue}if(/\s/.test(g)){f&&(l.push(n),n="",f=!1);continue}if(g==="'"||g==='"'){m=g,f=!0;continue}if(g==="\\"){if(p+1>=e.length)return null;n+=e[++p],f=!0;continue}n+=g,f=!0}return m?null:(f&&l.push(n),l)}function Sl(e){for(let l of e)if(!Nl.has(l))return l.startsWith("-")?null:l||null;return null}function wl(e){let l=ms(e);if(!l)return null;let n=l.findIndex(g=>g==="skills"||g==="add-skill"||g.startsWith("skills@"));if(n<0)return null;let m=l[n],f=l.slice(n+1);if(m==="add-skill")return Sl(f);let p=0;for(;Nl.has(f[p]);)p++;return f[p]!=="add"?null:Sl(f.slice(p+1))}var q=ee(de(),1);function Il(e){let[l,n]=(0,oe.useState)(null),m=(0,oe.useRef)(null),{navIntent:f,onNavIntentConsumed:p}=e;(0,oe.useEffect)(()=>{if(f){if(f.openInstallWizard){let S=m.current;S?.scrollIntoView?.({behavior:"smooth",block:"start"}),S?.querySelector('input[data-install="source"]')?.focus()}p?.()}},[f,p]);let g=S=>{!S||S.length===0||S.length>1&&n(S)};return(0,q.jsxs)("div",{className:"skills-page-stack",children:[(0,q.jsx)("div",{className:"skills-install-anchor",ref:m,children:(0,q.jsx)(e.InstallPanel,{installSource:e.installSource,installPath:e.installPath,installRef:e.installRef,installFullDepth:e.installFullDepth,installTargetSkill:e.installTargetSkill??null,installStatus:e.installStatus,installBusy:e.installBusy,installDiscovering:e.installDiscovering,installSelectionOpen:e.installSelectionOpen,installCandidates:e.installCandidates,selectedInstallSkills:e.selectedInstallSkills,onInstallSourceChange:e.onInstallSourceChange,onInstallPathChange:e.onInstallPathChange,onInstallRefChange:e.onInstallRefChange,onInstallFullDepthChange:e.onInstallFullDepthChange,onClearInstallTarget:e.onClearInstallTarget,onToggleInstallSkill:e.onToggleInstallSkill,onSelectAllInstallSkills:e.onSelectAllInstallSkills,onConfirmInstallSelection:()=>{e.onConfirmInstallSelection().then(g)},onCloseInstallSelection:e.onCloseInstallSelection,onInstall:()=>{e.onInstall().then(g)},onOpenNativeDiscovery:e.onOpenNativeDiscovery})}),l&&(0,q.jsx)(gs,{skillNames:l,onClose:()=>n(null),onCreate:async S=>{await e.onCreatePack(S),n(null)}}),(0,q.jsx)(e.InstalledLibrary,{skills:e.skills,busySkill:e.skillBusy,removingNames:e.removingNames,status:e.installedStatus,onUpdate:e.onUpdateSkill,onRequestRemove:e.onRequestRemove,externalQuery:e.navIntent?.librarySearch??null,externalFilterNames:e.navIntent?.libraryFilterSkills??null,packsKnown:e.packsKnown,onInstallMissing:e.onInstallMissing,graph:e.graph,packNames:e.packNames,onShowSkillPacks:e.onShowSkillPacks,onShowSkillBots:e.onShowSkillBots}),(0,q.jsx)(e.RemoveDialog,{names:e.removalDialogOpen?e.pendingRemoval:null,references:e.removalReferences,busy:e.removingNames.size>0,error:e.removalError,onCancel:e.onCancelRemoval,onConfirm:e.onConfirmRemoval})]})}function gs(e){let l=Z(),[n,m]=(0,oe.useState)(""),[f,p]=(0,oe.useState)(""),[g,S]=(0,oe.useState)(!1),[o,D]=(0,oe.useState)(null),B=(0,oe.useRef)(null);(0,oe.useEffect)(()=>{let C=B.current;if(C&&!C.open)try{C.showModal()}catch{}},[]);let v=async()=>{if(!(!n.trim()||!f.trim())){S(!0),D(null);try{await e.onCreate({id:n.trim(),name:f.trim(),skillNames:e.skillNames})}catch(C){D(C?.message??String(C))}finally{S(!1)}}};return(0,q.jsx)("dialog",{className:"bd-dialog skills-post-install-pack",ref:B,onClose:()=>!g&&e.onClose(),children:(0,q.jsxs)("form",{method:"dialog",onSubmit:C=>{C.preventDefault(),v()},children:[(0,q.jsx)("h3",{children:l("skills.postInstallPackTitle")}),(0,q.jsx)("p",{children:l("skills.postInstallPackHelp",{count:e.skillNames.length})}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packId")}),(0,q.jsx)("input",{autoFocus:!0,required:!0,value:n,onChange:C=>m(C.target.value)})]}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packName")}),(0,q.jsx)("input",{required:!0,value:f,onChange:C=>p(C.target.value)})]}),(0,q.jsxs)("div",{className:"skills-resolved-preview",children:[(0,q.jsx)("strong",{children:l("skills.postInstallPackSkills")}),(0,q.jsx)("ul",{children:e.skillNames.map(C=>(0,q.jsx)("li",{children:(0,q.jsx)("code",{children:C})},C))})]}),o&&(0,q.jsx)("p",{className:"hint-warn",children:o}),(0,q.jsxs)("div",{className:"skills-dialog-actions",children:[(0,q.jsx)("button",{type:"button",className:"bd-button",disabled:g,onClick:e.onClose,children:l("skills.postInstallPackSkip")}),(0,q.jsx)("button",{type:"submit",className:"bd-button primary",disabled:g||!n.trim()||!f.trim(),children:l(g?"skills.saving":"skills.postInstallPackCreate")})]})]})})}function el(e){let l=e.trim(),n=l.toLowerCase();if(!l)return"unknown";if(/^agentbuddy:/i.test(l)||/(?:^|\s)(?:npx\s+)?agentbuddy(?:@[\w.-]+)?\s+(?:skill|plugin)\s/i.test(l))return"agentbuddy";let m=wl(l);return m?el(m):n.startsWith("github:")?"github":n.startsWith("git+")||n.startsWith("git@")||n.startsWith("git://")?"git":n.includes("github.com")?"github":n.startsWith("http://")||n.startsWith("https://")||n.endsWith(".git")?"git":/^[/~.]/.test(l)?"local":/^[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9._-]+(?:\/[\w./-]+)?$/.test(l)?"github":l.includes("://")?"unknown":"local"}var Q=ee(Ae(),1);function ps(e,l){let n=String(e??"").replace(/\\/g,"/");return n.includes("/.codex/skills/")?l("skills.sourceCodex"):n.includes("/.claude/skills/")?l("skills.sourceClaude"):n.includes("/.trae/skills/")?l("skills.sourceTrae"):n.includes("/.cursor/skills/")?l("skills.sourceCursor"):n.includes("/.gemini/skills/")?l("skills.sourceGemini"):n.includes("/.config/opencode/skills/")?l("skills.sourceOpenCode"):null}function ll(e,l){let n=e.source??{};return n.type==="github"?`github:${n.owner}/${n.repo}/${n.path??""}`:n.type==="git"?`${n.url??"git"}#${n.path??""}`:n.type==="local-link"?ps(n.path,l)??l("skills.sourceLocalLink"):n.type==="local-copy"?l("skills.sourceBotmuxCopy"):String(n.type??"unknown")}function ke(e){return(e?.include??[]).filter(l=>l.startsWith("skill:")).map(l=>l.slice(6))}function be(e){return(e?.include??[]).filter(l=>l.startsWith("pack:")).map(l=>l.slice(5))}function Cl(e,l,n){let m=(e?.include??[]).filter(g=>!g.startsWith("skill:")&&!g.startsWith("pack:")),f=[...new Set(l.map(g=>g.trim()).filter(Boolean))].map(g=>`skill:${g}`),p=[...new Set(n.map(g=>g.trim()).filter(Boolean))].map(g=>`pack:${g}`);return[...f,...p,...m]}function Pl(e){return(e?.include?.length??0)>0}function Be(e){return`${e.cliId}
2
2
  ${e.rootDir}`}function Ge(e,l,n,m){let f=m?.packsKnown!==!1,p=new Set(e.map(v=>v.name)),g=new Map,S=v=>{let C=g.get(v);return C||(C={name:v,installed:p.has(v),packIds:[],directBotIds:[],viaPackBotIds:[]},g.set(v,C)),C};for(let v of p)S(v);let o=new Map,D=new Map;for(let v of l){D.set(v.id,v);let C=[],w=[];for(let h of v.include){if(!h.startsWith("skill:"))continue;let x=h.slice(6),E=S(x);E.packIds.includes(v.id)||E.packIds.push(v.id),(p.has(x)?C:w).push(x)}o.set(v.id,{id:v.id,resolved:C,missing:w,botIds:[]})}let B=new Map;for(let v of n){let C=v.skills?.include??[],w=new Map,h=new Set,x=[],E=!1;for(let L of C)if(L.startsWith("skill:")){let A=L.slice(6),$=S(A);$.directBotIds.includes(v.larkAppId)||$.directBotIds.push(v.larkAppId),p.has(A)?w.set(A,"direct"):h.add(A)}else if(L.startsWith("pack:")){let A=L.slice(5),$=D.get(A);if(!$){f?x.push(A):E=!0;continue}let H=o.get(A);H.botIds.includes(v.larkAppId)||H.botIds.push(v.larkAppId);for(let K of $.include){if(!K.startsWith("skill:"))continue;let F=K.slice(6),y=S(F);y.viaPackBotIds.includes(v.larkAppId)||y.viaPackBotIds.push(v.larkAppId),p.has(F)?w.has(F)||w.set(F,`pack:${A}`):h.add(F)}}let T=x.length>0?"pack_missing":h.size>0?"missing":E?"unknown":C.length===0?"default":"ok";B.set(v.larkAppId,{larkAppId:v.larkAppId,resolved:[...w.entries()].map(([L,A])=>({name:L,source:A})),missingSkills:[...h],missingPacks:x,finalCount:w.size,health:T})}return{skills:g,packs:o,bots:B}}function Rl(e){return[...e.skills.values()].filter(l=>!l.installed).map(l=>l.name).sort()}function sl(e,l){if(l){let n=e.some(m=>m.name===l);return{selected:n?new Set([l]):new Set,targetMissing:!n}}return{selected:new Set(e.map(n=>n.name)),targetMissing:!1}}var u=ee(de(),1);function Dl(e){let l=Z(),[n,m]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[g,S]=(0,Q.useState)(!1),[o,D]=(0,Q.useState)(null),[B,v]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(""),[h,x]=(0,Q.useState)(null),[E,T]=(0,Q.useState)(()=>new Set),[L,A]=(0,Q.useState)(null),{focusBotIds:$,focusSkill:H,onFocusConsumed:K}=e;(0,Q.useEffect)(()=>{($?.length??0)===0&&!H||($&&$.length>0&&T(new Set($)),H&&(A(H),w(H)),K?.())},[$,H]),(0,Q.useEffect)(()=>{if(!B)return;let r=setTimeout(()=>v(null),1600);return()=>clearTimeout(r)},[B]);let F=(0,Q.useMemo)(()=>Ge(e.skills,e.packs,e.bots,{packsKnown:e.packsKnown!==!1}),[e.skills,e.packs,e.bots,e.packsKnown]),y=(0,Q.useMemo)(()=>{let r=new Set;for(let a of e.skills)for(let M of a.tags??[])r.add(M);return[...r].sort()},[e.skills]),b=(0,Q.useMemo)(()=>{let r=C.trim().toLowerCase();return e.skills.filter(a=>h&&!(a.tags??[]).includes(h)?!1:r?`${a.name} ${a.description??""}`.toLowerCase().includes(r):!0)},[e.skills,C,h]),I=async r=>{if(!o||o.sourceBotId)return;p(null),D(null);let a=ke(r.skills),M=be(r.skills);if(o.type==="skill"){if(a.includes(o.id)){v({botId:r.larkAppId,itemLabel:o.id});return}e.onMutate?await e.onMutate(r.larkAppId,`skill:${o.id}`,!0):await e.onSave(r.larkAppId,[...a,o.id],M)}else{if(M.includes(o.id)){v({botId:r.larkAppId,itemLabel:e.packs.find(P=>P.id===o.id)?.name??o.id});return}e.onMutate?await e.onMutate(r.larkAppId,`pack:${o.id}`,!0):await e.onSave(r.larkAppId,a,[...M,o.id])}},d=async()=>{let r=o;if(!r?.sourceBotId)return;S(!1),p(null),D(null);let a=e.bots.find(_=>_.larkAppId===r.sourceBotId);if(!a)return;let M=ke(a.skills),P=be(a.skills);if(r.type==="skill"){if(!M.includes(r.id))return;e.onMutate?await e.onMutate(a.larkAppId,`skill:${r.id}`,!1):await e.onSave(a.larkAppId,M.filter(_=>_!==r.id),P)}else{if(!P.includes(r.id))return;e.onMutate?await e.onMutate(a.larkAppId,`pack:${r.id}`,!1):await e.onSave(a.larkAppId,M,P.filter(_=>_!==r.id))}},U=()=>{D(null),p(null),S(!1)},G=(r,a,M)=>{r.dataTransfer.effectAllowed=M,r.dataTransfer.setData("text/plain",a.id),v(null),D(a)},te=o?.sourceBotId?e.bots.find(r=>r.larkAppId===o.sourceBotId):null;return(0,u.jsxs)("section",{className:"skills-config-block",children:[(0,u.jsx)(ue,{title:l("skills.bots"),count:l("skills.botCount",{count:e.bots.length}),hint:l("skills.botsHelp")}),(0,u.jsxs)("div",{className:"skills-bot-assign-layout",children:[(0,u.jsxs)("div",{className:"skills-bot-palette",children:[(0,u.jsxs)("div",{className:"skills-bot-palette-hint",children:[(0,u.jsx)("span",{className:"skills-drag-icon",children:"\u2927"}),(0,u.jsx)("span",{children:l("skills.dragHint")})]}),o?.sourceBotId?(0,u.jsxs)("div",{className:`skills-unassign-dropzone${g?" is-active":""}`,"data-action":"unassign-dropzone","data-drag-over":g||void 0,role:"status","aria-live":"polite",onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move",S(!0)},onDragLeave:r=>{r.currentTarget.contains(r.relatedTarget)||S(!1)},onDrop:r=>{r.preventDefault(),d().catch(()=>{})},children:[(0,u.jsx)("span",{className:"skills-unassign-icon","aria-hidden":"true",children:"\u21A9"}),(0,u.jsxs)("span",{children:[(0,u.jsx)("strong",{children:l("skills.unassignDropTitle")}),(0,u.jsx)("small",{children:l("skills.unassignDropHint",{bot:te?.botName??o.sourceBotId})})]})]}):null,e.packs.length>0&&(0,u.jsxs)("div",{className:"skills-bot-palette-group",children:[(0,u.jsx)("span",{className:"skills-bot-palette-label",children:l("skills.packChips")}),(0,u.jsx)("div",{className:"skills-bot-palette-items",children:e.packs.map(r=>(0,u.jsx)("span",{className:"skills-draggable-chip skills-pack-chip",draggable:!0,"data-palette-drag-type":"pack","data-palette-drag-id":r.id,onDragStart:a=>G(a,{type:"pack",id:r.id},"copy"),onDragEnd:U,title:`${r.name} (${l("skills.skillCount",{count:r.include.length})})`,children:r.name},r.id))})]}),(0,u.jsxs)("div",{className:"skills-bot-palette-group",children:[(0,u.jsx)("span",{className:"skills-bot-palette-label",children:l("skills.individualSkills")}),(0,u.jsx)("input",{className:"skills-bot-palette-search",type:"text",placeholder:l("skills.searchPlaceholder"),value:C,onChange:r=>w(r.target.value)}),y.length>0&&(0,u.jsxs)("div",{className:"skills-bot-palette-tags",children:[(0,u.jsx)("button",{className:`skills-tag-filter${h===null?" active":""}`,onClick:()=>x(null),children:l("skills.all")}),y.map(r=>(0,u.jsx)("button",{className:`skills-tag-filter${h===r?" active":""}`,onClick:()=>x(h===r?null:r),children:r},r))]}),(0,u.jsxs)("div",{className:"skills-bot-palette-items",children:[b.map(r=>(0,u.jsx)("span",{className:"skills-draggable-chip skills-skill-chip",draggable:!0,"data-palette-drag-type":"skill","data-palette-drag-id":r.name,onDragStart:a=>G(a,{type:"skill",id:r.name},"copy"),onDragEnd:U,title:r.description??r.name,children:r.name},r.name)),b.length===0&&(0,u.jsx)("span",{className:"muted",children:l("skills.noResults")})]})]})]}),(0,u.jsx)("article",{className:"bd-card skills-config-card skills-bot-table-wrap",children:(0,u.jsx)("div",{className:"skills-bot-table",children:(0,u.jsxs)("table",{children:[(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:l("skills.bot")}),(0,u.jsx)("th",{children:l("skills.packChips")}),(0,u.jsx)("th",{children:l("skills.individualSkills")}),(0,u.jsx)("th",{children:l("skills.finalCount")}),(0,u.jsx)("th",{children:l("skills.health")}),(0,u.jsx)("th",{})]})}),(0,u.jsx)("tbody",{children:e.bots.map(r=>{let a=ke(r.skills),M=be(r.skills),P=F.bots.get(r.larkAppId),_=P?.finalCount??0,V=fs(P,l),he=f===r.larkAppId,fe=E.has(r.larkAppId)||L!=null&&(P?.resolved.some(W=>W.name===L)??!1),ye=B?.botId===r.larkAppId?B:null,le=e.statuses[r.larkAppId]??null,se=e.busyBotIds?.has(r.larkAppId)===!0;return(0,u.jsxs)("tr",{className:`skills-bot-row${he?" drag-over":""}${fe?" skills-bot-row-focus":""}${se?" is-busy":""}`,"aria-busy":se,onDragOver:W=>{se||!o||o.sourceBotId||(W.preventDefault(),W.dataTransfer.dropEffect="copy",p(r.larkAppId))},onDragLeave:W=>{W.currentTarget.contains(W.relatedTarget)||p(Y=>Y===r.larkAppId?null:Y)},onDrop:W=>{se||!o||o.sourceBotId||(W.preventDefault(),I(r).catch(()=>{}))},children:[(0,u.jsx)("td",{children:r.botName??r.larkAppId}),(0,u.jsx)("td",{children:(0,u.jsx)("div",{className:"skills-pack-chips",children:M.length===0?(0,u.jsx)("span",{className:"muted",children:"\u2014"}):M.map(W=>{let Y=e.packs.find(Se=>Se.id===W),we=!Y&&e.packsKnown===!1,xe=!Y&&!we;return(0,u.jsx)("span",{className:`skills-assigned-draggable${o?.sourceBotId===r.larkAppId&&o.type==="pack"&&o.id===W?" is-dragging":""}`,draggable:!se,"data-assigned-drag-type":"pack","data-assigned-drag-id":W,"data-assigned-bot":r.larkAppId,title:l("skills.dragToRemove"),onDragStart:Se=>{se||G(Se,{type:"pack",id:W,sourceBotId:r.larkAppId},"move")},onDragEnd:U,children:(0,u.jsx)("button",{type:"button",className:`skills-pack-chip${xe?" skills-chip-missing":""}${we?" skills-chip-unknown":""}`,"data-action":"open-bot-pack",title:we?l("skills.healthUnknown"):void 0,disabled:!Y||!e.onOpenPack,onClick:()=>e.onOpenPack?.(W),children:Y?.name??W})},W)})})}),(0,u.jsx)("td",{children:a.length===0?(0,u.jsx)("span",{className:"muted",children:"\u2014"}):(0,u.jsxs)("span",{className:"skills-skill-chips",children:[a.slice(0,3).map(W=>(0,u.jsx)("span",{className:`skills-assigned-draggable${o?.sourceBotId===r.larkAppId&&o.type==="skill"&&o.id===W?" is-dragging":""}`,draggable:!se,"data-assigned-drag-type":"skill","data-assigned-drag-id":W,"data-assigned-bot":r.larkAppId,title:l("skills.dragToRemove"),onDragStart:Y=>{se||G(Y,{type:"skill",id:W,sourceBotId:r.larkAppId},"move")},onDragEnd:U,children:(0,u.jsx)("button",{type:"button",className:"skills-skill-chip","data-action":"open-bot-skill",disabled:!e.onOpenSkill,onClick:()=>e.onOpenSkill?.(W),children:W})},W)),a.length>3&&(0,u.jsxs)("span",{className:"muted",children:["+",a.length-3]})]})}),(0,u.jsx)("td",{children:P?.health==="unknown"?(0,u.jsx)("span",{className:"muted",title:l("skills.healthUnknown"),children:"\u2014"}):_}),(0,u.jsx)("td",{children:(0,u.jsx)("span",{className:`skills-health skills-health-${V.level}`,children:V.label})}),(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"skills-bot-row-actions",children:[ye?(0,u.jsx)("span",{className:"skills-duplicate-feedback",role:"status","aria-live":"polite",children:l("skills.alreadyAssigned",{item:ye.itemLabel})}):null,le?(0,u.jsx)("span",{className:`oncall-status ${le.ok?"hint-ok":"hint-warn-inline"}`,role:"status","aria-live":"polite",children:le.text}):se?(0,u.jsx)("span",{className:"oncall-status",role:"status","aria-live":"polite",children:l("skills.saving")}):null,(0,u.jsx)("button",{className:"bd-button",disabled:se,onClick:()=>m(r),children:l("skills.select")})]})})]},r.larkAppId)})})]})})})]}),n&&(0,u.jsx)(vs,{bot:n,skills:e.skills,packs:e.packs,status:e.statuses[n.larkAppId]??null,onClose:()=>m(null),onSave:(r,a)=>e.onSave(n.larkAppId,r,a)})]})}function fs(e,l){switch(e?.health){case"pack_missing":return{level:"error",label:l("skills.healthPackMissing")};case"missing":return{level:"warn",label:l("skills.healthMissing",{count:e.missingSkills.length})};case"unknown":return{level:"unknown",label:l("skills.healthUnknown")};case"default":case void 0:return{level:"ok",label:l("skills.healthDefault")};default:return{level:"ok",label:l("skills.healthOk")}}}function vs(e){let l=Z(),n=(0,Q.useMemo)(()=>ke(e.bot.skills),[e.bot.skills]),m=(0,Q.useMemo)(()=>be(e.bot.skills),[e.bot.skills]),[f,p]=(0,Q.useState)(()=>new Set(n)),[g,S]=(0,Q.useState)(()=>new Set(m)),[o,D]=(0,Q.useState)(!1),B=h=>{p(x=>{let E=new Set(x);return E.has(h)?E.delete(h):E.add(h),E})},v=h=>{S(x=>{let E=new Set(x);return E.has(h)?E.delete(h):E.add(h),E})},C=(0,Q.useMemo)(()=>{let h=new Map;for(let x of f)h.set(x,"direct");for(let x of g){let E=e.packs.find(T=>T.id===x);if(E)for(let T of E.include){let L=T.replace("skill:","");h.has(L)||h.set(L,`pack:${E.name}`)}}return[...h.entries()].map(([x,E])=>({name:x,source:E}))},[f,g,e.packs]),w=async()=>{D(!0);try{await e.onSave([...f],[...g]),e.onClose()}finally{D(!1)}};return(0,u.jsx)("dialog",{className:"bd-dialog skills-bot-editor",open:!0,onClose:e.onClose,children:(0,u.jsxs)("form",{method:"dialog","data-action":"save-bot-assignment",onSubmit:h=>{h.preventDefault(),w().catch(()=>{})},children:[(0,u.jsxs)("h3",{children:[l("skills.botEdit"),": ",e.bot.botName??e.bot.larkAppId]}),e.status&&(0,u.jsx)("p",{className:`hint-${e.status.ok?"ok":"warn"}`,children:e.status.text}),(0,u.jsxs)("div",{className:"skills-control-block",children:[(0,u.jsx)("label",{children:l("skills.packChips")}),(0,u.jsxs)("div",{className:"skills-pack-skill-list",children:[e.packs.map(h=>(0,u.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,u.jsx)("input",{type:"checkbox",checked:g.has(h.id),onChange:()=>v(h.id)}),(0,u.jsx)("span",{children:h.name}),(0,u.jsx)("small",{children:l("skills.skillCount",{count:h.include.length})})]},h.id)),e.packs.length===0&&(0,u.jsx)("small",{className:"muted",children:l("skills.packsEmpty")})]})]}),(0,u.jsxs)("div",{className:"skills-control-block",children:[(0,u.jsxs)("label",{children:[l("skills.individualSkills")," (",l("skills.advanced"),")"]}),(0,u.jsx)("div",{className:"skills-pack-skill-list",children:e.skills.map(h=>(0,u.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,u.jsx)("input",{type:"checkbox",checked:f.has(h.name),onChange:()=>B(h.name)}),(0,u.jsx)("span",{children:h.name})]},h.name))})]}),(0,u.jsxs)("div",{className:"skills-control-block",children:[(0,u.jsxs)("label",{children:[l("skills.resolvedPreview")," (",C.length,")"]}),(0,u.jsx)("div",{className:"skills-resolved-preview",children:C.map(({name:h,source:x})=>(0,u.jsxs)("div",{className:"skills-resolved-item",children:[(0,u.jsx)("span",{children:h}),(0,u.jsx)("small",{className:"muted",children:x})]},h))})]}),(0,u.jsxs)("div",{className:"skills-dialog-actions",children:[(0,u.jsx)("button",{type:"button",className:"bd-button",onClick:e.onClose,children:l("skills.cancel")}),(0,u.jsx)("button",{type:"submit",className:"bd-button primary",disabled:o,children:l(o?"skills.saving":"skills.saveSelection")})]})]})})}var O=ee(de(),1);function Tl(e){let l=Z(),{SkillSegmented:n}=e;return(0,O.jsxs)("div",{className:"skills-page-stack",children:[(0,O.jsxs)("section",{className:"skills-config-block",children:[(0,O.jsx)(ue,{title:l("skills.globalDefaults")}),(0,O.jsxs)("article",{className:"bd-card skills-defaults-panel skills-config-card",children:[(0,O.jsxs)("div",{className:"skills-control-block",children:[(0,O.jsx)("span",{className:"skills-control-label",children:l("skills.globalProject")}),(0,O.jsx)(n,{value:e.trustProjectSkills,disabled:e.globalBusy==="project",options:[{value:"off",label:l("skills.globalProjectOff"),help:l("skills.globalProjectOffHelp")},{value:"all",label:l("skills.globalProjectAll"),help:l("skills.globalProjectAllHelp")}],onChange:m=>e.onUpdateProject(m)})]}),(0,O.jsxs)("div",{className:"skills-control-block",children:[(0,O.jsxs)("span",{className:"skills-control-label",children:[l("skills.globalDelivery"),(0,O.jsx)("small",{className:"skills-scope-note",children:l("skills.scopeGlobal")})]}),(0,O.jsx)(n,{value:e.delivery,disabled:e.globalBusy==="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:m=>e.onUpdateDelivery(m)})]})]})]}),(0,O.jsxs)("section",{className:"skills-config-block",children:[(0,O.jsx)(ue,{title:l("skills.botInjection"),hint:l("skills.botInjectionHelp")}),(0,O.jsxs)("article",{className:"bd-card skills-config-card",children:[(0,O.jsx)("p",{className:"skills-injection-note",children:l("skills.botInjectionNote")}),(0,O.jsx)("div",{className:"skills-bot-injection-table",children:(0,O.jsxs)("table",{children:[(0,O.jsx)("thead",{children:(0,O.jsxs)("tr",{children:[(0,O.jsx)("th",{children:l("skills.bot")}),(0,O.jsx)("th",{children:l("skills.cli")}),(0,O.jsx)("th",{children:l("skills.injection")}),(0,O.jsx)("th",{children:l("skills.status")})]})}),(0,O.jsx)("tbody",{children:e.bots.map(m=>(0,O.jsxs)("tr",{children:[(0,O.jsx)("td",{children:m.botName??m.larkAppId}),(0,O.jsx)("td",{children:(0,O.jsx)("code",{children:m.cliId??""})}),(0,O.jsx)("td",{children:(0,O.jsx)(n,{value:m.skillInjection??m.skillInjectionDefault??"prompt",options:[{value:"global",label:l("skills.injectionGlobal"),help:l("skills.injectionGlobalHelp")},{value:"prompt",label:l("skills.injectionPrompt"),help:l("skills.injectionPromptHelp")},{value:"off",label:l("skills.injectionOff"),help:l("skills.injectionOffHelp")}],onChange:f=>e.onUpdateBotInjection(m.larkAppId,f)})}),(0,O.jsx)("td",{children:e.botStatuses[m.larkAppId]?(0,O.jsx)("span",{className:`hint-${e.botStatuses[m.larkAppId].ok?"ok":"warn"}`,children:e.botStatuses[m.larkAppId].text}):null})]},m.larkAppId))})]})})]})]})]})}var X=ee(Ae(),1);function Al(e){let l=(0,X.useRef)(!0),[n,m]=(0,X.useState)([]),[f,p]=(0,X.useState)([]),[g,S]=(0,X.useState)([]),[o,D]=(0,X.useState)([]),[B,v]=(0,X.useState)("off"),[C,w]=(0,X.useState)("auto"),[h,x]=(0,X.useState)(!0),[E,T]=(0,X.useState)(null),[L,A]=(0,X.useState)(null),[$,H]=(0,X.useState)(!1),K=(0,X.useRef)(e.apiUnavailableText);K.current=e.apiUnavailableText;let F=(0,X.useCallback)(async()=>{x(!0);try{let[y,b,I]=await Promise.all([fetch("/api/skills"),fetch("/api/bots"),fetch("/api/skill-packs").catch(()=>null)]),d=await y.json().catch(()=>({})),U=await b.json().catch(()=>({})),G=I?await I.json().catch(()=>({})):{};if(!y.ok){let te=d?.error??`skills HTTP ${y.status}`;throw new Error(te==="not_found_yet"||te==="not_found"?K.current:te)}if(!b.ok)throw new Error(U?.error??`bots HTTP ${b.status}`);if(!l.current)return;m(Array.isArray(d.skills)?d.skills:[]),p(Array.isArray(d.nativeSkillGroups)?d.nativeSkillGroups:[]),S(Array.isArray(U.bots)?U.bots:[]),I?.ok&&Array.isArray(G.packs)?(D(G.packs),A(null),H(!0)):I?.status===404?(D([]),A(null),H(!0)):A(I?G?.error??`HTTP ${I.status}`:"network_error"),v(d.trustProjectSkills==="all"?"all":"off"),w(d.delivery==="prompt"||d.delivery==="native"?d.delivery:"auto"),T(null)}catch(y){l.current&&T(y?.message??String(y))}finally{l.current&&x(!1)}},[]);return(0,X.useEffect)(()=>(l.current=!0,F(),()=>{l.current=!1}),[F]),{skills:n,nativeSkillGroups:f,bots:g,packs:o,trustProjectSkills:B,delivery:C,loading:h,loadError:E,packsError:L,packsKnown:$,refresh:F,setSkills:m,setBots:S,setTrustProjectSkills:v,setDelivery:w}}var s=ee(de(),1),bs=2;function hs(e){return e>=1600?4:e<=620?1:e<=980?2:3}async function re(e,l){let n=await fetch(e,{...l,headers:{"content-type":"application/json",...l.headers??{}}}),m=await n.json().catch(()=>({}));if(!n.ok||m.ok===!1){let f=new Error(m?.error??`HTTP ${n.status}`);throw f.status=n.status,f.body=m,f}return m}function tl(e){return`oncall-status${e?` ${e.ok?"hint-ok":"hint-warn-inline"}`:""}`}function ys(e){let l=e.options.find(n=>n.value===e.value);return(0,s.jsxs)("div",{className:"skills-segmented-control",children:[(0,s.jsx)("div",{className:"segmented skills-segmented",role:"group",children:e.options.map(n=>(0,s.jsx)("button",{type:"button",className:e.value===n.value?"active":"","aria-pressed":e.value===n.value?"true":"false",title:typeof n.help=="string"?n.help:void 0,disabled:e.disabled,onClick:()=>e.onChange(n.value),children:n.label},n.value))}),l?.help?(0,s.jsx)("span",{className:"skills-setting-hint",children:l.help}):null]})}function Ss(e){let l=Z(),n=(0,c.useRef)(null),m=(0,c.useRef)(null),f=(0,c.useId)(),p=`${f}-input`,g=`${f}-title`,[S,o]=(0,c.useState)(!1),D=e.installCandidates??[],B=e.selectedInstallSkills??new Set,v=D.length>0&&D.every(T=>B.has(T.name)),C=e.installBusy||e.installDiscovering,w=el(e.installSource),h=l(w==="github"?"skills.sourceDetectedGithub":w==="git"?"skills.sourceDetectedGit":w==="agentbuddy"?"skills.sourceDetectedAgentbuddy":w==="local"?"skills.sourceDetectedLocal":"skills.sourceDetectedUnknown"),x=l(w==="agentbuddy"?"skills.sourcePreflightAgentbuddy":w==="github"||w==="git"?"skills.sourcePreflightGit":w==="local"?"skills.sourcePreflightLocal":"skills.sourcePreflightUnknown"),E=l(w==="agentbuddy"?"skills.installDiagnosticAgentbuddy":w==="github"||w==="git"?"skills.installDiagnosticGit":w==="local"?"skills.installDiagnosticLocal":"skills.installDiagnosticUnknown");return(0,c.useEffect)(()=>{let T=n.current;if(T)if(e.installSelectionOpen&&!T.open)try{T.showModal()}catch{}else!e.installSelectionOpen&&T.open&&T.close()},[e.installSelectionOpen,D.length]),(0,c.useEffect)(()=>{if(!S||typeof document>"u")return;let T=A=>{m.current?.contains(A.target)||o(!1)},L=A=>{A.key==="Escape"&&o(!1)};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",L)}},[S]),(0,s.jsxs)("article",{className:"bd-card skills-install-panel",children:[e.showTitle===!1?null:(0,s.jsx)("div",{className:"skills-install-title",children:(0,s.jsx)("h3",{className:"bd-section-title",children:(0,s.jsx)(hl,{help:l("skills.installInfo"),helpLabel:l("skills.installInfoLabel"),children:l("skills.install")})})}),e.installTargetSkill?(0,s.jsxs)("div",{className:"skills-inline-target","data-install-target":e.installTargetSkill,children:[(0,s.jsx)("span",{children:l("skills.installTargetHint",{skill:e.installTargetSkill})}),(0,s.jsx)("button",{type:"button","data-action":"clear-install-target",onClick:()=>e.onClearInstallTarget?.(),children:l("skills.clearInstallTarget")})]}):null,(0,s.jsxs)("div",{className:"skills-install-grid",children:[(0,s.jsxs)("div",{className:"skills-source-label",children:[(0,s.jsxs)("div",{className:"skills-source-heading",ref:m,onKeyDown:T=>{T.key==="Escape"&&o(!1)},children:[(0,s.jsx)("label",{htmlFor:p,children:l("skills.source")}),(0,s.jsx)("button",{type:"button",className:"skills-source-help-trigger","data-action":"toggle-source-help","aria-label":l("skills.sourceHelpOpen"),"aria-expanded":S,"aria-controls":f,"aria-haspopup":"dialog",onClick:()=>o(T=>!T),children:"?"}),S?(0,s.jsxs)("aside",{className:"skills-source-help-popover",id:f,role:"dialog","aria-labelledby":g,"data-source-help-popover":!0,children:[(0,s.jsxs)("div",{className:"skills-source-help-head",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{id:g,children:l("skills.sourceHelpTitle")}),(0,s.jsx)("span",{children:l("skills.sourceHelpIntro")})]}),(0,s.jsx)("button",{type:"button",className:"skills-source-help-close","data-action":"close-source-help","aria-label":l("skills.sourceHelpClose"),onClick:()=>o(!1),children:"\xD7"})]}),(0,s.jsxs)("div",{className:"skills-source-help-list",children:[(0,s.jsxs)("section",{children:[(0,s.jsx)("strong",{children:l("skills.sourceHelpRemoteLabel")}),(0,s.jsx)("span",{children:l("skills.sourceHelpRemote")}),(0,s.jsx)("code",{children:l("skills.sourceHelpRemoteExample")})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)("strong",{children:l("skills.sourceHelpLocalLabel")}),(0,s.jsx)("span",{children:l("skills.sourceHelpLocal")}),(0,s.jsx)("code",{children:l("skills.sourceHelpLocalExample")})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)("strong",{children:l("skills.sourceHelpAgentbuddyLabel")}),(0,s.jsx)("span",{children:l("skills.sourceHelpAgentbuddy")}),(0,s.jsx)("code",{children:l("skills.sourceHelpAgentbuddyExample")})]})]})]}):null]}),(0,s.jsx)("div",{className:"skills-source-control",children:(0,s.jsx)("input",{id:p,type:"text","data-install":"source","aria-label":l("skills.source"),placeholder:l("skills.sourcePlaceholder"),value:e.installSource,onChange:T=>e.onInstallSourceChange(T.currentTarget.value)})}),e.installSource.trim()?(0,s.jsxs)("div",{className:`skills-source-feedback is-${w}`,"data-source-hint":w,children:[(0,s.jsx)("strong",{children:h}),(0,s.jsx)("span",{children:x})]}):null]}),(0,s.jsxs)("details",{className:"skills-install-advanced","data-install-advanced":!0,children:[(0,s.jsx)("summary",{children:l("skills.advancedOptions")}),(0,s.jsxs)("div",{className:"skills-install-advanced-body",children:[(0,s.jsxs)("label",{className:"skills-install-field",children:[(0,s.jsx)("span",{children:l("skills.path")}),(0,s.jsx)("input",{type:"text","data-install":"path",placeholder:l("skills.pathPlaceholder"),value:e.installPath,onChange:T=>e.onInstallPathChange(T.currentTarget.value)}),(0,s.jsx)("small",{children:l("skills.pathHelpInline")})]}),(0,s.jsxs)("label",{className:"skills-install-field",children:[(0,s.jsx)("span",{children:l("skills.ref")}),(0,s.jsx)("input",{type:"text","data-install":"ref",placeholder:l("skills.refPlaceholder"),value:e.installRef,onChange:T=>e.onInstallRefChange(T.currentTarget.value)}),(0,s.jsx)("small",{children:l("skills.refHelpInline")})]}),(0,s.jsxs)("label",{className:"skills-scan-toggle",children:[(0,s.jsx)("input",{type:"checkbox","data-install":"full-depth",checked:e.installFullDepth,disabled:C,onChange:T=>e.onInstallFullDepthChange(T.currentTarget.checked)}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:l("skills.deepScan")}),(0,s.jsx)("small",{children:l("skills.deepScanHelp")}),(0,s.jsx)("small",{className:"muted",children:l("skills.autoDeepScanHint")})]})]})]})]}),(0,s.jsxs)("div",{className:"skills-install-actions",children:[(0,s.jsx)("button",{type:"button",className:"skills-local-discovery-link","data-action":"open-native-skill-discovery",title:l("skills.localDiscoverHelp"),onClick:()=>e.onOpenNativeDiscovery(),children:l("skills.localDiscover")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"install",disabled:C||!e.installSource.trim(),onClick:()=>e.onInstall(),children:e.installDiscovering?l("skills.scanning"):e.installBusy?l("skills.jobRunning"):l("skills.installSubmit")})]})]}),e.installStatus?(0,s.jsx)("div",{className:"actions skills-install-status-row",children:(0,s.jsx)("span",{className:tl(e.installStatus),"data-skills-status":!0,children:e.installStatus.text})}):null,e.installStatus&&!e.installStatus.ok?(0,s.jsxs)("div",{className:"skills-install-diagnostic","data-install-diagnostic":w,role:"alert",children:[(0,s.jsx)("strong",{children:l("skills.installDiagnosticTitle")}),(0,s.jsx)("span",{children:E})]}):null,(0,s.jsx)("dialog",{className:"skills-discovery-dialog skills-install-selection-dialog","data-install-selection-dialog":!0,ref:n,onClose:()=>e.onCloseInstallSelection?.(),children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:l("skills.installSelectionTitle")}),(0,s.jsx)("p",{children:l("skills.installSelectionHelp",{count:D.length})})]}),(0,s.jsx)("div",{className:"skills-discovery-body skills-install-selection-body",children:(0,s.jsxs)("div",{className:"skills-candidate-list","data-install-candidates":!0,children:[(0,s.jsxs)("div",{className:"skills-candidate-list-head",children:[(0,s.jsx)("span",{children:l("skills.scanFound",{count:D.length})}),e.onSelectAllInstallSkills?(0,s.jsx)("button",{type:"button","data-action":"toggle-all-source-skills",disabled:e.installBusy,onClick:()=>e.onSelectAllInstallSkills?.(!v),children:l(v?"skills.discoverClearSelection":"skills.discoverSelectAll")}):null]}),D.map(T=>(0,s.jsxs)("label",{className:"skills-candidate-row",children:[(0,s.jsx)("input",{type:"checkbox",checked:B.has(T.name),disabled:e.installBusy,onChange:()=>e.onToggleInstallSkill?.(T.name)}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:T.name}),(0,s.jsxs)("small",{children:[T.path,T.description?` \xB7 ${T.description}`:""]})]})]},`${T.name}:${T.path}`))]})}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button","data-action":"close-install-selection",disabled:e.installBusy,onClick:()=>e.onCloseInstallSelection?.(),children:l("skills.installSelectionCancel")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"confirm-install-selection",disabled:e.installBusy||B.size===0,onClick:()=>e.onConfirmInstallSelection?.(),children:e.installBusy?l("skills.jobRunning"):l("skills.installSelected")})]})]})})]})}function Ns(e){let l=Z(),n=(0,c.useRef)(null),m=(0,c.useRef)(new Set(e.skills.map(a=>a.name))),f=(0,c.useRef)(""),p=(0,c.useRef)(!1),g=(0,c.useRef)(null),[S,o]=(0,c.useState)(""),[D,B]=(0,c.useState)(!1),[v,C]=(0,c.useState)(()=>new Set),[w,h]=(0,c.useState)(null),[x,E]=(0,c.useState)(0),[T,L]=(0,c.useState)(()=>typeof window>"u"?1200:window.innerWidth),A=S.trim().toLocaleLowerCase();f.current=S,p.current=D;let $=(0,c.useMemo)(()=>{let a=w?e.skills.filter(M=>w.has(M.name)):e.skills;return A?a.filter(M=>[M.name,M.displayName,M.description,...M.tags??[],ll(M,l)].filter(Boolean).join(`
3
- `).toLocaleLowerCase().includes(A)):a},[w,A,e.skills,l]),H=(0,c.useMemo)(()=>{if(!w)return[];let a=new Set(e.skills.map(M=>M.name));return[...w].filter(M=>!a.has(M)).sort()},[w,e.skills]),K=hs(T)*bs,F=Math.max(1,Math.ceil($.length/K)),y=$.slice(x*K,x*K+K),b=(0,c.useMemo)(()=>new Set($.map(a=>a.name)),[$]),I=$.filter(a=>v.has(a.name)).length,d=Math.max(0,v.size-I),U=$.length>0&&I===$.length;(0,c.useEffect)(()=>{if(typeof window>"u")return;let a=()=>L(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),(0,c.useEffect)(()=>{e.externalQuery!=null&&e.externalQuery!==""&&o(e.externalQuery)},[e.externalQuery]),(0,c.useEffect)(()=>{e.externalFilterNames&&e.externalFilterNames.length>0&&h(new Set(e.externalFilterNames))},[e.externalFilterNames]),(0,c.useEffect)(()=>E(0),[A,K,w]),(0,c.useEffect)(()=>{E(a=>Math.min(Math.max(0,a),F-1))},[F]),(0,c.useEffect)(()=>{let a=new Set(e.skills.map(P=>P.name)),M=[...m.current].some(P=>!a.has(P));C(P=>{let _=new Set([...P].filter(V=>a.has(V)));return _.size===P.size?P:_}),M&&(B(!1),C(new Set)),m.current=a},[e.skills]),(0,c.useEffect)(()=>{n.current&&(n.current.indeterminate=I>0&&!U)},[U,I]),(0,c.useEffect)(()=>{if(typeof document>"u")return;let a=P=>{if(P.key!=="Escape"||!p.current)return;let _=f.current;g.current=_,P.preventDefault(),P.stopPropagation(),B(!1),C(new Set),window.setTimeout(()=>{o(V=>V||_),g.current=null},50)},M=P=>{if(P.key!=="Escape"||g.current===null)return;let _=g.current;g.current=null,P.preventDefault(),P.stopPropagation(),o(_)};return document.addEventListener("keydown",a,!0),document.addEventListener("keyup",M,!0),()=>{document.removeEventListener("keydown",a,!0),document.removeEventListener("keyup",M,!0)}},[]);function G(a){C(M=>{let P=new Set(M);return P.has(a)?P.delete(a):P.add(a),P})}function te(){C(a=>{let M=new Set(a);if(U)for(let P of b)M.delete(P);else for(let P of b)M.add(P);return M})}function r(a=!1){let M=S;B(!1),C(new Set),a&&typeof window<"u"&&window.setTimeout(()=>o(M),0)}return(0,s.jsxs)("section",{className:"skills-installed-block",children:[(0,s.jsx)(ue,{title:l("skills.installed"),count:l("skills.installedCount",{count:e.skills.length}),hint:l("skills.installedHelp"),children:(0,s.jsx)("div",{className:"skills-installed-header-actions",children:D?(0,s.jsx)("button",{type:"button","data-action":"cancel-installed-selection",onClick:()=>r(),children:l("skills.cancel")}):(0,s.jsx)("button",{type:"button","data-action":"select-installed-skills",disabled:e.skills.length===0,onClick:()=>B(!0),children:l("skills.select")})})}),(0,s.jsxs)("section",{className:"bd-card skills-installed-panel",children:[(0,s.jsxs)("div",{className:"skills-library-toolbar",children:[(0,s.jsxs)("label",{className:"skills-installed-search",children:[(0,s.jsx)("span",{className:"sr-only",children:l("skills.searchLabel")}),(0,s.jsx)("input",{type:"text",role:"searchbox",inputMode:"search","data-action":"search-installed-skills",placeholder:l("skills.searchPlaceholder"),value:S,onChange:a=>o(a.currentTarget.value),onKeyDown:a=>{a.key!=="Escape"||!D||(a.preventDefault(),a.stopPropagation(),r(!0))}}),S?(0,s.jsx)("button",{type:"button","data-action":"clear-installed-search","aria-label":l("skills.clearSearch"),onClick:()=>o(""),children:"\xD7"}):null]}),D?(0,s.jsxs)("label",{className:"skills-select-all-results",children:[(0,s.jsx)("input",{ref:n,type:"checkbox",checked:U,disabled:$.length===0||e.removingNames.size>0,onChange:te}),(0,s.jsx)("span",{children:A?l("skills.selectSearchResults",{count:$.length}):l("skills.selectAllSkills",{count:$.length})})]}):null,w?(0,s.jsxs)("button",{type:"button",className:"skills-library-filter-chip","data-action":"clear-library-filter",title:[...w].join(", "),"aria-label":l("skills.clearFilter"),onClick:()=>h(null),children:[l("skills.libraryFilterActive",{count:w.size})," \xD7"]}):null,A?(0,s.jsx)("span",{className:"skills-filter-count",children:l("skills.resultCount",{count:$.length})}):null,F>1?(0,s.jsxs)("div",{className:"skills-pager",children:[(0,s.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"-1","aria-label":l("skills.prevPage"),title:l("skills.prevPage"),disabled:x===0,onClick:()=>E(a=>Math.max(0,a-1)),children:"\u2039"}),(0,s.jsx)("span",{children:l("skills.pageStatus",{page:x+1,pages:F})}),(0,s.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"1","aria-label":l("skills.nextPage"),title:l("skills.nextPage"),disabled:x>=F-1,onClick:()=>E(a=>Math.min(F-1,a+1)),children:"\u203A"})]}):null]}),(0,s.jsx)("div",{className:"skills-installed-live",role:"status","aria-live":"polite",children:e.status?(0,s.jsx)("span",{className:tl(e.status),children:e.status.text}):null}),H.length>0&&(0,s.jsxs)("div",{className:"skills-missing-list","data-missing-skills":!0,children:[(0,s.jsx)("strong",{children:l("skills.missingFilteredTitle")}),H.map(a=>(0,s.jsxs)("div",{className:"skills-missing-row","data-missing-skill":a,children:[(0,s.jsx)("span",{className:"skills-missing-row-name",children:a}),(0,s.jsx)("small",{className:"muted",children:l("skills.dangling")}),(0,s.jsx)("button",{type:"button","data-action":"install-dangling-skill",disabled:!e.onInstallMissing,onClick:()=>e.onInstallMissing?.(a),children:l("skills.installNow")})]},a))]}),e.skills.length===0?(0,s.jsxs)("div",{className:"skills-library-empty",children:[(0,s.jsx)("strong",{children:l("skills.emptyTitle")}),(0,s.jsx)("p",{children:l("skills.emptyHelp")})]}):$.length===0&&H.length>0?null:$.length===0?(0,s.jsxs)("div",{className:"skills-library-empty","data-empty":"search",children:[(0,s.jsx)("strong",{children:l("skills.noResultsTitle",{query:S.trim()})}),(0,s.jsx)("p",{children:l("skills.noResultsHelp")}),(0,s.jsx)("button",{type:"button","data-action":"clear-installed-search-empty",onClick:()=>o(""),children:l("skills.clearSearch")})]}):(0,s.jsx)("div",{className:"skills-list",children:y.map(a=>{let M=v.has(a.name),P=e.removingNames.has(a.name);return(0,s.jsxs)("article",{className:`skills-row skills-installed-card${D?" is-selectable":""}${M?" is-selected":""}${P?" is-removing":""}`,"data-skill":a.name,"data-selection-mode":D?"true":void 0,"aria-busy":P||void 0,onClick:D?()=>G(a.name):void 0,children:[(0,s.jsxs)("div",{className:"skills-row-body",children:[(0,s.jsxs)("div",{className:"skills-row-title",children:[D?(0,s.jsx)("input",{type:"checkbox","aria-label":l("skills.selectNamed",{skill:a.displayName??a.name}),checked:M,disabled:P,onClick:_=>_.stopPropagation(),onChange:()=>G(a.name)}):null,(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:a.displayName??a.name}),a.displayName&&a.displayName!==a.name?(0,s.jsx)("small",{className:"skills-canonical-name",children:a.name}):null]})]}),a.description?(0,s.jsx)("p",{children:a.description}):null,(0,s.jsx)("small",{className:"skills-source-badge",children:ll(a,l)}),e.graph?(()=>{let _=e.graph.skills.get(a.name),V=e.packsKnown===!1,he=_?.packIds.length??0,fe=_?new Set([..._.directBotIds,..._.viaPackBotIds]).size:0,ye=V?l("skills.healthUnknown"):(_?.packIds??[]).map(le=>e.packNames?.find(se=>se.id===le)?.name??le).join(", ");return(0,s.jsxs)("span",{className:"skills-usage-chips",children:[(0,s.jsx)("button",{type:"button",className:"skills-usage-chip","data-action":"show-skill-packs",disabled:V||he===0||!e.onShowSkillPacks,title:ye||void 0,onClick:le=>{le.stopPropagation(),e.onShowSkillPacks?.(a.name)},children:V?l("skills.usedInPacksUnknown"):l("skills.usedInPacks",{count:he})}),(0,s.jsx)("button",{type:"button",className:"skills-usage-chip","data-action":"show-skill-bots",disabled:fe===0||!e.onShowSkillBots,onClick:le=>{le.stopPropagation(),e.onShowSkillBots?.(a.name)},children:l("skills.usedByBots",{count:fe})})]})})():null,P?(0,s.jsx)("span",{className:"skills-removing-label",children:l("skills.removing")}):null]}),D?null:(0,s.jsxs)("div",{className:"skills-card-actions",children:[(0,s.jsx)("button",{type:"button","data-action":"update-skill",disabled:e.busySkill===`${a.name}:update`||P,onClick:()=>e.onUpdate(a.name),children:l("skills.update")}),(0,s.jsx)("button",{type:"button","data-action":"remove-skill",disabled:P,onClick:()=>e.onRequestRemove([a.name]),children:l("skills.remove")})]})]},a.name)})})]}),D?(0,s.jsxs)("div",{className:"skills-bulk-action-bar",role:"toolbar","aria-label":l("skills.bulkActions"),children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:l("skills.selectedCount",{count:v.size})}),d>0?(0,s.jsx)("small",{children:l("skills.selectedHidden",{count:d})}):null]}),(0,s.jsx)("button",{type:"button",className:"danger","data-action":"remove-selected-skills",disabled:v.size===0||e.removingNames.size>0,onClick:()=>e.onRequestRemove([...v]),children:l("skills.removeSelected",{count:v.size})})]}):null]})}function ws(e){let l=Z(),n=(0,c.useRef)(null),m=e.names??[],f=e.references.length>0,p=m.slice(0,3),g=new Set(e.references.flatMap(o=>o.bots)).size,S=new Set(e.references.flatMap(o=>o.packs)).size;return(0,c.useEffect)(()=>{let o=n.current;if(o)if(e.names&&!o.open)try{o.showModal()}catch{}else!e.names&&o.open&&o.close()},[e.names]),(0,s.jsx)("dialog",{className:"skills-remove-dialog","data-remove-skills-dialog":!0,ref:n,onCancel:o=>{o.preventDefault(),e.busy||e.onCancel()},onClick:o=>{o.target===o.currentTarget&&!e.busy&&e.onCancel()},children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:f?m.length===1?l("skills.removeInUseOneTitle",{skill:m[0]}):l("skills.removeInUseManyTitle",{count:m.length}):m.length===1?l("skills.removeOneTitle",{skill:m[0]}):l("skills.removeManyTitle",{count:m.length})}),(0,s.jsx)("p",{children:f?m.length===1?S>0?l("skills.removeInUseOneHelpWithPacks",{botCount:g,packCount:S}):l("skills.removeInUseOneHelp",{count:g}):S>0?l("skills.removeInUseManyHelpWithPacks",{botCount:g,packCount:S}):l("skills.removeInUseManyHelp",{count:g}):m.length===1?l("skills.removeOnePermanentHelp"):l("skills.removePermanentHelp")})]}),(0,s.jsxs)("div",{className:"skills-remove-dialog-body",children:[m.length>1?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("ul",{children:p.map(o=>(0,s.jsx)("li",{children:o},o))}),m.length>p.length?(0,s.jsx)("p",{children:l("skills.removeMore",{count:m.length-p.length})}):null]}):null,e.references.length>0?(0,s.jsxs)("div",{className:"skills-remove-reference-warning",role:"alert",children:[(0,s.jsx)("strong",{children:l("skills.removeReferencesDetail")}),(0,s.jsx)("ul",{children:e.references.map(o=>(0,s.jsxs)("li",{children:[(0,s.jsx)("strong",{children:o.name}),(0,s.jsxs)("span",{children:[o.bots.join(", "),o.bots.length>0&&o.packs.length>0?" \xB7 ":"",o.packs.length>0?`${l("skills.packChips")}: ${o.packs.join(", ")}`:""]})]},o.name))})]}):null,e.error?(0,s.jsx)("p",{className:"hint-warn",role:"alert",children:e.error}):null]}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button",autoFocus:!0,disabled:e.busy,onClick:e.onCancel,children:l("skills.cancel")}),(0,s.jsx)("button",{type:"button",className:"danger",disabled:e.busy,onClick:()=>e.onConfirm(f),children:e.busy?l("skills.removing"):f?l("skills.removeAnyway"):m.length===1?l("skills.removeOneConfirm"):l("skills.removeSelected",{count:m.length})})]})]})})}function Is(){let e=Z(),l=(0,c.useRef)(!0),n=(0,c.useRef)(new Set),m=(0,c.useRef)(null),{skills:f,nativeSkillGroups:p,bots:g,packs:S,trustProjectSkills:o,delivery:D,loading:B,loadError:v,packsError:C,packsKnown:w,refresh:h,setSkills:x,setBots:E,setTrustProjectSkills:T,setDelivery:L}=Al({apiUnavailableText:e("skills.apiUnavailable")}),[A,$]=(0,c.useState)("library"),[H,K]=(0,c.useState)(null),[F,y]=(0,c.useState)(null),b=(0,c.useCallback)(t=>{K(t),y(t.installTargetSkill??null),$(t.tab)},[]),I=(0,c.useCallback)(()=>K(null),[]),[d,U]=(0,c.useState)(""),[G,te]=(0,c.useState)(""),[r,a]=(0,c.useState)(""),[M,P]=(0,c.useState)(null),[_,V]=(0,c.useState)(!1),[he,fe]=(0,c.useState)(!1),[ye,le]=(0,c.useState)(!1),[se,W]=(0,c.useState)([]),[Y,we]=(0,c.useState)(!1),[xe,Se]=(0,c.useState)(!1),[ze,Me]=(0,c.useState)(()=>new Set),[Ke,Ie]=(0,c.useState)(!1),[xl,nl]=(0,c.useState)(!1),[_e,Ml]=(0,c.useState)(null),[We,qe]=(0,c.useState)(()=>new Set),[El,Ee]=(0,c.useState)(null),[$l,al]=(0,c.useState)(null),[Ll,il]=(0,c.useState)(()=>new Set),[ol,Ne]=(0,c.useState)({}),[Je,Ce]=(0,c.useState)(null),[rl,Qe]=(0,c.useState)(null),[Hl,Pe]=(0,c.useState)(!1),[Ol,$e]=(0,c.useState)([]),[jl,Le]=(0,c.useState)(null),[He,cl]=(0,c.useState)(()=>new Set),Re=(0,c.useRef)(g),Oe=(0,c.useRef)(new Map);(0,c.useEffect)(()=>{Re.current=g},[g]);let je=(0,c.useMemo)(()=>new Set(f.map(t=>t.name)),[f]),ve=(0,c.useMemo)(()=>p.length===0?void 0:(_e?p.find(i=>Be(i)===_e):void 0)??p.find(i=>i.skills.length>0)??p[0],[_e,p]),Xe=ve?Be(ve):"",De=(0,c.useMemo)(()=>ve?ve.skills.filter(t=>!je.has(t.name)).map(t=>t.rootDir??t.source?.root??"").filter(Boolean):[],[ve,je]),dl=De.length>0&&De.every(t=>We.has(t)),ul=(0,c.useCallback)(()=>{for(let t of n.current)window.clearTimeout(t);n.current.clear()},[]),Fl=(0,c.useCallback)(t=>new Promise(i=>{let N=window.setTimeout(()=>{n.current.delete(N),i()},t);n.current.add(N)}),[]);(0,c.useEffect)(()=>(l.current=!0,()=>{l.current=!1,ul()}),[ul]),(0,c.useEffect)(()=>{qe(t=>{let i=new Set,N=new Set(f.map(R=>R.name));for(let R of p)for(let z of R.skills){let j=z.rootDir??z.source?.root??"";j&&!N.has(z.name)&&t.has(j)&&i.add(j)}return i.size===t.size?t:i})},[f,p]),(0,c.useEffect)(()=>{if(!Je||He.size>0)return;let t=window.setTimeout(()=>{l.current&&Ce(null)},6e3);return()=>window.clearTimeout(t)},[Je,He]),(0,c.useEffect)(()=>{let t=m.current;if(t)if(Ke&&!t.open)try{t.showModal()}catch{}else!Ke&&t.open&&t.close()},[Ke,Xe]);async function kl(t,i,N=!0){let R=t;for(i({text:e("skills.jobRunning"),ok:!0});;){if(!l.current)return null;if(R.status==="succeeded")return i({text:e("skills.saved"),ok:!0}),N&&await h(),R;if(R.status==="failed")throw new Error(R.error??"job_failed");if(await Fl(800),!l.current)return null;let z=await re(`/api/skills/jobs/${encodeURIComponent(R.id)}`,{method:"GET"});if(!l.current)return null;R=z.job}}function Ul(t){return g.filter(i=>ke(i.skills).includes(t)).map(i=>i.botName??i.larkAppId)}function Te(){W([]),Me(new Set),le(!1),Se(!1)}function ml(){return{source:d.trim(),path:G.trim()||void 0,ref:r.trim()||void 0,...Y?{fullDepth:!0}:{}}}function Gl(t,i=Y||xe){let N=t??[...ze];return{...ml(),skillNames:N.length>0?N:void 0,...i?{fullDepth:!0}:{}}}async function zl(){fe(!0),P({text:e("skills.scanning"),ok:!0});try{let t=await re("/api/skills/discover",{method:"POST",body:JSON.stringify(ml())});if(!l.current)return{skills:[],directInstall:!1,fullDepth:Y};let i=t.discovery?.directInstall===!0,N=Array.isArray(t.discovery?.skills)?t.discovery.skills:[],R=t.discovery?.deepScanned===!0;return Se(R),W(N),Me(sl(N,F).selected),{skills:N,directInstall:i,fullDepth:Y||R}}finally{l.current&&fe(!1)}}function me(t){let i=t||"";return i.startsWith("skill_git_command_failed")&&/authentication failed|could not read username|repository not found|unauthor|\b401\b|\b403\b/i.test(i)?e("skills.gitNeedsAuth"):i.startsWith("agentbuddy_not_found")?e("skills.agentbuddyNotFound"):i.startsWith("agentbuddy_login_required")?e("skills.agentbuddyNeedsLogin"):i.startsWith("agentbuddy_command_failed")?/login|credential|unauthor|not logged|401|403/i.test(i)?e("skills.agentbuddyNeedsLogin"):e("skills.agentbuddyCommandFailed"):i.startsWith("agentbuddy_clear_telemetry_failed")||i.startsWith("agentbuddy_telemetry_not_stripped")?e("skills.agentbuddyTelemetryFailed"):i.startsWith("agentbuddy_no_skill_produced")?e("skills.agentbuddyNoSkill"):i.startsWith("invalid_agentbuddy")?e("skills.agentbuddyInvalid"):i}async function Ze(t,i=Y||xe){V(!0);try{let N=await re("/api/skills/install",{method:"POST",body:JSON.stringify(Gl(t,i))});if(!l.current)return null;let R=await kl(N.job,P);if(!l.current||!R)return null;let z=(R.skills??(R.skill?[R.skill]:[])).map(j=>j.name).filter(Boolean);return Te(),y(null),[...new Set(z.length>0?z:t??[])]}catch(N){return l.current&&P({text:`${e("skills.failed")}: ${me(N?.message??String(N))}`,ok:!1}),null}finally{l.current&&V(!1)}}function Kl(t){Me(i=>{let N=new Set(i);return N.has(t)?N.delete(t):N.add(t),N})}function _l(t){Me(t?new Set(se.map(i=>i.name)):new Set)}async function Wl(){if(!d.trim())return P({text:e("skills.sourceRequired"),ok:!1}),null;try{le(!1);let{skills:t,directInstall:i,fullDepth:N}=await zl();if(!l.current)return null;if(i)return await Ze(void 0,N);if(t.length===0)return P({text:e("skills.scanEmpty"),ok:!1}),null;let{targetMissing:R}=sl(t,F);return t.length===1&&!R?await Ze([t[0].name],N):(P(R?{text:e("skills.installTargetNotFound",{skill:F}),ok:!1}:{text:e("skills.scanFound",{count:t.length}),ok:!0}),le(!0),null)}catch(t){return l.current&&P({text:`${e("skills.failed")}: ${me(t?.message??String(t))}`,ok:!1}),null}}async function ql(){let t=[...ze];return t.length===0?(P({text:e("skills.discoverNothingSelected"),ok:!1}),null):await Ze(t)}async function Jl(t){await re("/api/skill-packs",{method:"POST",body:JSON.stringify({id:t.id,name:t.name,include:t.skillNames.map(i=>`skill:${i}`)})}),l.current&&(await h(),l.current&&$("packs"))}async function Ql(){let t=[...We].filter(Boolean);if(t.length===0){P({text:e("skills.discoverNothingSelected"),ok:!1});return}nl(!0);try{if(P({text:e("skills.discoverRegisteringBatch",{total:t.length}),ok:!0}),await re("/api/skills/install-local-links",{method:"POST",body:JSON.stringify({sources:t})}),!l.current)return;Ie(!1),await h(),l.current&&P({text:e("skills.saved"),ok:!0})}catch(i){l.current&&P({text:`${e("skills.failed")}: ${me(i?.message??String(i))}`,ok:!1})}finally{l.current&&nl(!1)}}async function Xl(t){if(o!==t){Ee("project");try{let i=await re("/api/skills/global",{method:"PUT",body:JSON.stringify({trustProjectSkills:t})});if(!l.current)return;T(i.trustProjectSkills==="all"?"all":t)}catch(i){l.current&&window.alert(`${e("skills.failed")}: ${me(i?.message??String(i))}`)}finally{l.current&&Ee(null)}}}async function Zl(t){if(D!==t){Ee("delivery");try{let i=await re("/api/skills/global",{method:"PUT",body:JSON.stringify({delivery:t})});if(!l.current)return;L(i.delivery==="prompt"||i.delivery==="native"?i.delivery:t)}catch(i){l.current&&window.alert(`${e("skills.failed")}: ${me(i?.message??String(i))}`)}finally{l.current&&Ee(null)}}}async function Vl(t){al(`${t}:update`);try{let i=await re(`/api/skills/${encodeURIComponent(t)}/update`,{method:"POST",body:"{}"});if(!l.current)return;await kl(i.job,P)}catch(i){l.current&&window.alert(`${e("skills.failed")}: ${me(i?.message??String(i))}`)}finally{l.current&&al(null)}}function Yl(t){let i=[...new Set(t.filter(N=>je.has(N)))];i.length!==0&&(Qe(i),Pe(!0),$e([]),Le(null))}function es(){He.size>0||(Pe(!1),Qe(null),$e([]),Le(null))}async function ls(t){let i=rl??[];if(i.length!==0){cl(new Set(i)),Pe(!1),Le(null),Ce({text:e("skills.removingCount",{count:i.length}),ok:!0});try{let N=await re("/api/skills",{method:"DELETE",body:JSON.stringify({names:i,force:t})});if(!l.current)return;let R=Array.isArray(N.removed)?N.removed.filter(j=>typeof j=="string"):i,z=new Set(R);x(j=>j.filter(ne=>!z.has(ne.name))),Ce({text:R.length===1?e("skills.removedOne",{skill:R[0]}):e("skills.removedMany",{count:R.length}),ok:!0}),Qe(null),$e([])}catch(N){if(!l.current)return;if(N?.status===409&&N?.body?.error==="skills_in_use"){let z=Array.isArray(N.body.affectedSkills)?N.body.affectedSkills.map(j=>{let ne=typeof j?.name=="string"?j.name:"",ie=Array.isArray(j?.affectedBots)?j.affectedBots.map(ae=>ae?.botName||ae?.larkAppId||"").filter(Boolean):Ul(ne),ce=Array.isArray(j?.affectedPacks)?j.affectedPacks.filter(ae=>typeof ae=="string"):[];return ne?{name:ne,bots:ie,packs:ce}:null}).filter(j=>j!==null):[];$e(z),Pe(!0),Ce(null);return}let R=e("skills.removeFailed",{detail:me(N?.message??String(N))});Le(R),Pe(!0),Ce({text:R,ok:!1})}finally{l.current&&cl(new Set)}}}function gl(t,i){let N=Oe.current.get(t)??Promise.resolve();il(z=>new Set(z).add(t));let R=N.catch(()=>{}).then(i);return Oe.current.set(t,R),R.finally(()=>{Oe.current.get(t)===R&&(Oe.current.delete(t),l.current&&il(z=>{let j=new Set(z);return j.delete(t),j}))})}async function pl(t,i,N){Ne(R=>({...R,[t]:null}));try{let R=Re.current.find(ie=>ie.larkAppId===t),z=Cl(R?.skills,i,N),j=await re(`/api/bots/${encodeURIComponent(t)}/skills`,{method:"PUT",body:JSON.stringify({action:"set",policy:z.length>0?{include:z}:null})});if(!l.current)return;let ne=ie=>ie.map(ce=>ce.larkAppId===t?{...ce,skills:j.skills??null}:ce);Re.current=ne(Re.current),E(ne),Ne(ie=>({...ie,[t]:{text:e("skills.policySaved"),ok:!0}}))}catch(R){throw l.current&&Ne(z=>({...z,[t]:{text:`${e("skills.failed")}: ${me(R?.message??String(R))}`,ok:!1}})),R}}function ss(t,i,N){return gl(t,()=>pl(t,i,N))}function ts(t,i,N){return gl(t,async()=>{let R=Re.current.find(ae=>ae.larkAppId===t),z=ke(R?.skills),j=be(R?.skills),[ne,ie]=i.split(":",2),ce=ae=>N?[...new Set([...ae,ie])]:ae.filter(cs=>cs!==ie);await pl(t,ne==="skill"?ce(z):z,ne==="pack"?ce(j):j)})}async function ns(t,i){Ne(N=>({...N,[t]:null}));try{if(await re(`/api/bots/${encodeURIComponent(t)}/skill-injection`,{method:"PUT",body:JSON.stringify({skillInjection:i})}),!l.current)return;E(N=>N.map(R=>R.larkAppId===t?{...R,skillInjection:i}:R)),Ne(N=>({...N,[t]:{text:e("skills.saved"),ok:!0}}))}catch(N){l.current&&Ne(R=>({...R,[t]:{text:`${e("skills.failed")}: ${N?.message??N}`,ok:!1}}))}}let as=g.filter(t=>Pl(t.skills)).length,is=g.reduce((t,i)=>t+(i.skills?.include?.length??0),0),ge=(0,c.useMemo)(()=>Ge(f,S,g,{packsKnown:w}),[f,S,g,w]),pe=(0,c.useMemo)(()=>Rl(ge),[ge]),Fe=(0,c.useMemo)(()=>[...ge.packs.values()].filter(t=>t.botIds.length===0).map(t=>t.id),[ge]),Ue=(0,c.useMemo)(()=>[...ge.bots.values()].filter(t=>t.health==="missing"||t.health==="pack_missing").map(t=>t.larkAppId),[ge]),os=(0,s.jsxs)("div",{className:"page-heading-actions skills-heading-actions",children:[(0,s.jsxs)("div",{className:"skills-metric-strip",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricInstalled")}),(0,s.jsx)("strong",{children:f.length})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricPacks")}),(0,s.jsx)("strong",{children:w?S.length:"\u2014"})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricBots")}),(0,s.jsxs)("strong",{children:[as,"/",g.length]})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricAttached")}),(0,s.jsx)("strong",{children:is})]})]}),(0,s.jsxs)("div",{className:"skills-issue-strip",role:"group","aria-label":e("skills.issuesLabel"),children:[pe.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-warn","data-action":"issue-dangling-skills",title:pe.join(", "),onClick:()=>b(pe.length===1?{tab:"library",librarySearch:pe[0],openInstallWizard:!0,installTargetSkill:pe[0]}:{tab:"library",libraryFilterSkills:pe}),children:e("skills.issueDangling",{count:pe.length})}),Fe.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-info","data-action":"issue-unassigned-packs",onClick:()=>b({tab:"packs",focusPackIds:Fe}),children:e("skills.issueUnassignedPacks",{count:Fe.length})}),Ue.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-warn","data-action":"issue-bots-missing",onClick:()=>b({tab:"bots",focusBotIds:Ue}),children:e("skills.issueBotsMissing",{count:Ue.length})}),!B&&w&&pe.length===0&&Fe.length===0&&Ue.length===0&&(0,s.jsx)("span",{className:"skills-issue-badge skills-issue-ok","data-skills-healthy":!0,children:e("skills.issueNone")})]}),(0,s.jsx)(bl,{id:"skills-refresh",label:e("skills.refresh"),busy:B,disabled:B,onClick:()=>{h()}})]}),rs=(0,s.jsx)("div",{className:"skills-page-stack",children:B?(0,s.jsx)(vl,{label:e("common.loading")}):v?(0,s.jsx)("p",{className:"hint-warn",children:v}):(0,s.jsxs)(s.Fragment,{children:[C&&(0,s.jsx)("p",{className:"hint-warn","data-packs-error":!0,role:"alert",children:e(w?"skills.packsLoadError":"skills.packsLoadErrorFirst",{error:C})}),(0,s.jsxs)("div",{className:"skills-tabs",role:"tablist",children:[(0,s.jsx)("button",{role:"tab","aria-selected":A==="library",className:A==="library"?"active":"",onClick:()=>$("library"),children:e("skills.tabLibrary")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="packs",className:A==="packs"?"active":"",onClick:()=>$("packs"),children:e("skills.tabPacks")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="bots",className:A==="bots"?"active":"",onClick:()=>$("bots"),children:e("skills.tabBots")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="delivery",className:A==="delivery"?"active":"",onClick:()=>$("delivery"),children:e("skills.tabDelivery")})]}),A==="packs"&&(0,s.jsx)(yl,{skills:f,packs:S,packsKnown:w,onRefresh:()=>{h()},focusPackId:H?.tab==="packs"?H.focusPackId??null:null,focusPackIds:H?.tab==="packs"?H.focusPackIds??null:null,onFocusConsumed:I,onOpenBot:t=>b({tab:"bots",focusBotIds:[t]}),onInstallMissingSkill:t=>b({tab:"library",librarySearch:t,openInstallWizard:!0,installTargetSkill:t})}),A==="library"&&(0,s.jsx)(Il,{skills:f,nativeSkillGroups:p,installSource:d,installPath:G,installRef:r,installFullDepth:Y,installStatus:M,installBusy:_,installDiscovering:he,installSelectionOpen:ye,installCandidates:se,selectedInstallSkills:ze,onInstallSourceChange:t=>{U(t),Te()},onInstallPathChange:t=>{te(t),Te()},onInstallRefChange:t=>{a(t),Te()},onInstallFullDepthChange:t=>{we(t),Te()},onToggleInstallSkill:Kl,onSelectAllInstallSkills:_l,onConfirmInstallSelection:ql,onCloseInstallSelection:()=>le(!1),onInstall:Wl,onOpenNativeDiscovery:()=>Ie(!0),onCreatePack:Jl,InstallPanel:Ss,InstalledLibrary:Ns,RemoveDialog:ws,removingNames:He,removalDialogOpen:Hl,pendingRemoval:rl,removalReferences:Ol,removalError:jl,skillBusy:$l,installedStatus:Je,onUpdateSkill:t=>{Vl(t)},onRequestRemove:Yl,onCancelRemoval:es,onConfirmRemoval:t=>{ls(t)},navIntent:H?.tab==="library"?H:null,onNavIntentConsumed:I,installTargetSkill:F,onClearInstallTarget:()=>y(null),packsKnown:w,onInstallMissing:t=>b({tab:"library",openInstallWizard:!0,installTargetSkill:t}),graph:ge,packNames:S.map(t=>({id:t.id,name:t.name})),onShowSkillPacks:t=>{let i=ge.skills.get(t)?.packIds??[];b(i.length===1?{tab:"packs",focusPackId:i[0]}:{tab:"packs",focusPackIds:i})},onShowSkillBots:t=>b({tab:"bots",focusSkill:t})}),A==="bots"&&(0,s.jsx)(Dl,{bots:g,skills:f,statuses:ol,onSave:ss,onMutate:ts,busyBotIds:Ll,packs:S,packsKnown:w,focusBotIds:H?.tab==="bots"?H.focusBotIds??null:null,focusSkill:H?.tab==="bots"?H.focusSkill??null:null,onFocusConsumed:I,onOpenPack:t=>b({tab:"packs",focusPackId:t}),onOpenSkill:t=>b({tab:"library",librarySearch:t})}),A==="delivery"&&(0,s.jsx)(Tl,{trustProjectSkills:o,delivery:D,globalBusy:El,onUpdateProject:t=>{Xl(t)},onUpdateDelivery:t=>{Zl(t)},bots:g,onUpdateBotInjection:ns,botStatuses:ol,SkillSegmented:ys}),(0,s.jsx)("dialog",{className:"skills-discovery-dialog",id:"skills-discovery-dialog",ref:m,onClose:()=>Ie(!1),onClick:t=>{t.target===t.currentTarget&&Ie(!1)},children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:e("skills.discoverTitle")}),(0,s.jsx)("p",{children:e("skills.discoverHelp")}),(0,s.jsx)("button",{type:"button",className:"skills-discovery-close","data-action":"close-discovery","aria-label":e("skills.discoverClose"),title:e("skills.discoverClose"),onClick:()=>Ie(!1)})]}),(0,s.jsx)("div",{className:"skills-discovery-body",children:ve?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"skills-discovery-layout",children:[(0,s.jsx)("div",{className:"skills-discovery-tabs",role:"tablist","aria-label":e("skills.discoverTitle"),children:p.map(t=>{let i=Be(t),N=i===Xe;return(0,s.jsxs)("button",{type:"button",role:"tab","data-discovery-tab":i,className:N?"selected":"","aria-selected":N?"true":"false",onClick:()=>Ml(i),children:[(0,s.jsx)("strong",{children:t.label??t.cliId}),(0,s.jsx)("small",{children:e("skills.skillCount",{count:t.skills.length})})]},i)})}),(0,s.jsxs)("div",{className:"skills-discovery-main",children:[(0,s.jsx)("div",{className:"skills-discovery-path",children:(0,s.jsx)("code",{children:ve.rootDir})}),p.map(t=>{let i=Be(t);return(0,s.jsx)("section",{className:"skills-discovery-group","data-discovery-panel":i,hidden:!(i===Xe),children:t.skills.length===0?(0,s.jsx)("p",{className:"empty",children:e("skills.discoverGroupEmpty")}):(0,s.jsx)("div",{className:"skills-discovery-list",children:t.skills.map(R=>{let z=je.has(R.name),j=R.rootDir??R.source?.root??"";return(0,s.jsxs)("label",{className:`skills-discovery-row${z?" installed":""}`,children:[(0,s.jsx)("input",{type:"checkbox","data-discovered-skill":!0,value:j,disabled:z,checked:!z&&We.has(j),onChange:ne=>{let ie=ne.currentTarget.checked;qe(ce=>{let ae=new Set(ce);return ie?ae.add(j):ae.delete(j),ae})}}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:R.name}),R.description?(0,s.jsx)("small",{children:R.description}):null]}),z?(0,s.jsx)("em",{children:e("skills.discoverRegistered")}):null]},`${R.name}:${j}`)})})},i)})]})]})}):(0,s.jsx)("p",{className:"empty",children:e("skills.discoverEmpty")})}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button","data-action":"toggle-discovered-skills",disabled:De.length===0,onClick:()=>{qe(t=>{let i=new Set(t);return dl?De.forEach(N=>i.delete(N)):De.forEach(N=>i.add(N)),i})},children:e(dl?"skills.discoverClearSelection":"skills.discoverSelectAll")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"register-discovered-skills",disabled:xl,onClick:()=>{Ql()},children:e("skills.discoverRegister")})]})]})})]})});return(0,s.jsxs)("section",{className:"page skills-page",children:[(0,s.jsxs)("div",{className:"page-heading",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"eyebrow",children:e("nav.skills")}),(0,s.jsx)("h1",{children:e("skills.title")})]}),os]}),(0,s.jsx)("div",{id:"skills-body",children:rs})]})}function Cs(e,l){return e.size===l.length&&l.every(n=>e.has(n))}function Ps(e){let l=Z(),n=(0,c.useRef)(null),m=(0,c.useRef)(null),f=(0,c.useRef)(null),[p,g]=(0,c.useState)(!1),[S,o]=(0,c.useState)(""),[D,B]=(0,c.useState)(()=>new Set(e.names)),[v,C]=(0,c.useState)(null),w=e.names.join(`
3
+ `).toLocaleLowerCase().includes(A)):a},[w,A,e.skills,l]),H=(0,c.useMemo)(()=>{if(!w)return[];let a=new Set(e.skills.map(M=>M.name));return[...w].filter(M=>!a.has(M)).sort()},[w,e.skills]),K=hs(T)*bs,F=Math.max(1,Math.ceil($.length/K)),y=$.slice(x*K,x*K+K),b=(0,c.useMemo)(()=>new Set($.map(a=>a.name)),[$]),I=$.filter(a=>v.has(a.name)).length,d=Math.max(0,v.size-I),U=$.length>0&&I===$.length;(0,c.useEffect)(()=>{if(typeof window>"u")return;let a=()=>L(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),(0,c.useEffect)(()=>{e.externalQuery!=null&&e.externalQuery!==""&&o(e.externalQuery)},[e.externalQuery]),(0,c.useEffect)(()=>{e.externalFilterNames&&e.externalFilterNames.length>0&&h(new Set(e.externalFilterNames))},[e.externalFilterNames]),(0,c.useEffect)(()=>E(0),[A,K,w]),(0,c.useEffect)(()=>{E(a=>Math.min(Math.max(0,a),F-1))},[F]),(0,c.useEffect)(()=>{let a=new Set(e.skills.map(P=>P.name)),M=[...m.current].some(P=>!a.has(P));C(P=>{let _=new Set([...P].filter(V=>a.has(V)));return _.size===P.size?P:_}),M&&(B(!1),C(new Set)),m.current=a},[e.skills]),(0,c.useEffect)(()=>{n.current&&(n.current.indeterminate=I>0&&!U)},[U,I]),(0,c.useEffect)(()=>{if(typeof document>"u")return;let a=P=>{if(P.key!=="Escape"||!p.current)return;let _=f.current;g.current=_,P.preventDefault(),P.stopPropagation(),B(!1),C(new Set),window.setTimeout(()=>{o(V=>V||_),g.current=null},50)},M=P=>{if(P.key!=="Escape"||g.current===null)return;let _=g.current;g.current=null,P.preventDefault(),P.stopPropagation(),o(_)};return document.addEventListener("keydown",a,!0),document.addEventListener("keyup",M,!0),()=>{document.removeEventListener("keydown",a,!0),document.removeEventListener("keyup",M,!0)}},[]);function G(a){C(M=>{let P=new Set(M);return P.has(a)?P.delete(a):P.add(a),P})}function te(){C(a=>{let M=new Set(a);if(U)for(let P of b)M.delete(P);else for(let P of b)M.add(P);return M})}function r(a=!1){let M=S;B(!1),C(new Set),a&&typeof window<"u"&&window.setTimeout(()=>o(M),0)}return(0,s.jsxs)("section",{className:"skills-installed-block",children:[(0,s.jsx)(ue,{title:l("skills.installed"),count:l("skills.installedCount",{count:e.skills.length}),hint:l("skills.installedHelp"),children:(0,s.jsx)("div",{className:"skills-installed-header-actions",children:D?(0,s.jsx)("button",{type:"button","data-action":"cancel-installed-selection",onClick:()=>r(),children:l("skills.cancel")}):(0,s.jsx)("button",{type:"button","data-action":"select-installed-skills",disabled:e.skills.length===0,onClick:()=>B(!0),children:l("skills.select")})})}),(0,s.jsxs)("section",{className:"bd-card skills-installed-panel",children:[(0,s.jsxs)("div",{className:"skills-library-toolbar",children:[(0,s.jsxs)("label",{className:"skills-installed-search",children:[(0,s.jsx)("span",{className:"sr-only",children:l("skills.searchLabel")}),(0,s.jsx)("input",{type:"text",role:"searchbox",inputMode:"search","data-action":"search-installed-skills",placeholder:l("skills.searchPlaceholder"),value:S,onChange:a=>o(a.currentTarget.value),onKeyDown:a=>{a.key!=="Escape"||!D||(a.preventDefault(),a.stopPropagation(),r(!0))}}),S?(0,s.jsx)("button",{type:"button","data-action":"clear-installed-search","aria-label":l("skills.clearSearch"),onClick:()=>o(""),children:"\xD7"}):null]}),D?(0,s.jsxs)("label",{className:"skills-select-all-results",children:[(0,s.jsx)("input",{ref:n,type:"checkbox",checked:U,disabled:$.length===0||e.removingNames.size>0,onChange:te}),(0,s.jsx)("span",{children:A?l("skills.selectSearchResults",{count:$.length}):l("skills.selectAllSkills",{count:$.length})})]}):null,w?(0,s.jsxs)("button",{type:"button",className:"skills-library-filter-chip","data-action":"clear-library-filter",title:[...w].join(", "),"aria-label":l("skills.clearFilter"),onClick:()=>h(null),children:[l("skills.libraryFilterActive",{count:w.size})," \xD7"]}):null,A?(0,s.jsx)("span",{className:"skills-filter-count",children:l("skills.resultCount",{count:$.length})}):null,F>1?(0,s.jsxs)("div",{className:"skills-pager",children:[(0,s.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"-1","aria-label":l("skills.prevPage"),title:l("skills.prevPage"),disabled:x===0,onClick:()=>E(a=>Math.max(0,a-1)),children:"\u2039"}),(0,s.jsx)("span",{children:l("skills.pageStatus",{page:x+1,pages:F})}),(0,s.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"1","aria-label":l("skills.nextPage"),title:l("skills.nextPage"),disabled:x>=F-1,onClick:()=>E(a=>Math.min(F-1,a+1)),children:"\u203A"})]}):null]}),(0,s.jsx)("div",{className:"skills-installed-live",role:"status","aria-live":"polite",children:e.status?(0,s.jsx)("span",{className:tl(e.status),children:e.status.text}):null}),H.length>0&&(0,s.jsxs)("div",{className:"skills-missing-list","data-missing-skills":!0,children:[(0,s.jsx)("strong",{children:l("skills.missingFilteredTitle")}),H.map(a=>(0,s.jsxs)("div",{className:"skills-missing-row","data-missing-skill":a,children:[(0,s.jsx)("span",{className:"skills-missing-row-name",children:a}),(0,s.jsx)("small",{className:"muted",children:l("skills.dangling")}),(0,s.jsx)("button",{type:"button","data-action":"install-dangling-skill",disabled:!e.onInstallMissing,onClick:()=>e.onInstallMissing?.(a),children:l("skills.installNow")})]},a))]}),e.skills.length===0?(0,s.jsxs)("div",{className:"skills-library-empty",children:[(0,s.jsx)("strong",{children:l("skills.emptyTitle")}),(0,s.jsx)("p",{children:l("skills.emptyHelp")})]}):$.length===0&&H.length>0?null:$.length===0?(0,s.jsxs)("div",{className:"skills-library-empty","data-empty":"search",children:[(0,s.jsx)("strong",{children:l("skills.noResultsTitle",{query:S.trim()})}),(0,s.jsx)("p",{children:l("skills.noResultsHelp")}),(0,s.jsx)("button",{type:"button","data-action":"clear-installed-search-empty",onClick:()=>o(""),children:l("skills.clearSearch")})]}):(0,s.jsx)("div",{className:"skills-list",children:y.map(a=>{let M=v.has(a.name),P=e.removingNames.has(a.name);return(0,s.jsxs)("article",{className:`skills-row skills-installed-card${D?" is-selectable":""}${M?" is-selected":""}${P?" is-removing":""}`,"data-skill":a.name,"data-selection-mode":D?"true":void 0,"aria-busy":P||void 0,onClick:D?()=>G(a.name):void 0,children:[(0,s.jsxs)("div",{className:"skills-row-body",children:[(0,s.jsxs)("div",{className:"skills-row-title",children:[D?(0,s.jsx)("input",{type:"checkbox","aria-label":l("skills.selectNamed",{skill:a.displayName??a.name}),checked:M,disabled:P,onClick:_=>_.stopPropagation(),onChange:()=>G(a.name)}):null,(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:a.displayName??a.name}),a.displayName&&a.displayName!==a.name?(0,s.jsx)("small",{className:"skills-canonical-name",children:a.name}):null]})]}),a.description?(0,s.jsx)("p",{children:a.description}):null,(0,s.jsx)("small",{className:"skills-source-badge",children:ll(a,l)}),e.graph?(()=>{let _=e.graph.skills.get(a.name),V=e.packsKnown===!1,he=_?.packIds.length??0,fe=_?new Set([..._.directBotIds,..._.viaPackBotIds]).size:0,ye=V?l("skills.healthUnknown"):(_?.packIds??[]).map(le=>e.packNames?.find(se=>se.id===le)?.name??le).join(", ");return(0,s.jsxs)("span",{className:"skills-usage-chips",children:[(0,s.jsx)("button",{type:"button",className:"skills-usage-chip","data-action":"show-skill-packs",disabled:V||he===0||!e.onShowSkillPacks,title:ye||void 0,onClick:le=>{le.stopPropagation(),e.onShowSkillPacks?.(a.name)},children:V?l("skills.usedInPacksUnknown"):l("skills.usedInPacks",{count:he})}),(0,s.jsx)("button",{type:"button",className:"skills-usage-chip","data-action":"show-skill-bots",disabled:fe===0||!e.onShowSkillBots,onClick:le=>{le.stopPropagation(),e.onShowSkillBots?.(a.name)},children:l("skills.usedByBots",{count:fe})})]})})():null,P?(0,s.jsx)("span",{className:"skills-removing-label",children:l("skills.removing")}):null]}),D?null:(0,s.jsxs)("div",{className:"skills-card-actions",children:[(0,s.jsx)("button",{type:"button","data-action":"update-skill",disabled:e.busySkill===`${a.name}:update`||P,onClick:()=>e.onUpdate(a.name),children:l("skills.update")}),(0,s.jsx)("button",{type:"button","data-action":"remove-skill",disabled:P,onClick:()=>e.onRequestRemove([a.name]),children:l("skills.remove")})]})]},a.name)})})]}),D?(0,s.jsxs)("div",{className:"skills-bulk-action-bar",role:"toolbar","aria-label":l("skills.bulkActions"),children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:l("skills.selectedCount",{count:v.size})}),d>0?(0,s.jsx)("small",{children:l("skills.selectedHidden",{count:d})}):null]}),(0,s.jsx)("button",{type:"button",className:"danger","data-action":"remove-selected-skills",disabled:v.size===0||e.removingNames.size>0,onClick:()=>e.onRequestRemove([...v]),children:l("skills.removeSelected",{count:v.size})})]}):null]})}function ws(e){let l=Z(),n=(0,c.useRef)(null),m=e.names??[],f=e.references.length>0,p=m.slice(0,3),g=new Set(e.references.flatMap(o=>o.bots)).size,S=new Set(e.references.flatMap(o=>o.packs)).size;return(0,c.useEffect)(()=>{let o=n.current;if(o)if(e.names&&!o.open)try{o.showModal()}catch{}else!e.names&&o.open&&o.close()},[e.names]),(0,s.jsx)("dialog",{className:"skills-remove-dialog","data-remove-skills-dialog":!0,ref:n,onCancel:o=>{o.preventDefault(),e.busy||e.onCancel()},onClick:o=>{o.target===o.currentTarget&&!e.busy&&e.onCancel()},children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:f?m.length===1?l("skills.removeInUseOneTitle",{skill:m[0]}):l("skills.removeInUseManyTitle",{count:m.length}):m.length===1?l("skills.removeOneTitle",{skill:m[0]}):l("skills.removeManyTitle",{count:m.length})}),(0,s.jsx)("p",{children:f?m.length===1?S>0?l("skills.removeInUseOneHelpWithPacks",{botCount:g,packCount:S}):l("skills.removeInUseOneHelp",{count:g}):S>0?l("skills.removeInUseManyHelpWithPacks",{botCount:g,packCount:S}):l("skills.removeInUseManyHelp",{count:g}):m.length===1?l("skills.removeOnePermanentHelp"):l("skills.removePermanentHelp")})]}),(0,s.jsxs)("div",{className:"skills-remove-dialog-body",children:[m.length>1?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("ul",{children:p.map(o=>(0,s.jsx)("li",{children:o},o))}),m.length>p.length?(0,s.jsx)("p",{children:l("skills.removeMore",{count:m.length-p.length})}):null]}):null,e.references.length>0?(0,s.jsxs)("div",{className:"skills-remove-reference-warning",role:"alert",children:[(0,s.jsx)("strong",{children:l("skills.removeReferencesDetail")}),(0,s.jsx)("ul",{children:e.references.map(o=>(0,s.jsxs)("li",{children:[(0,s.jsx)("strong",{children:o.name}),(0,s.jsxs)("span",{children:[o.bots.join(", "),o.bots.length>0&&o.packs.length>0?" \xB7 ":"",o.packs.length>0?`${l("skills.packChips")}: ${o.packs.join(", ")}`:""]})]},o.name))})]}):null,e.error?(0,s.jsx)("p",{className:"hint-warn",role:"alert",children:e.error}):null]}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button",autoFocus:!0,disabled:e.busy,onClick:e.onCancel,children:l("skills.cancel")}),(0,s.jsx)("button",{type:"button",className:"danger",disabled:e.busy,onClick:()=>e.onConfirm(f),children:e.busy?l("skills.removing"):f?l("skills.removeAnyway"):m.length===1?l("skills.removeOneConfirm"):l("skills.removeSelected",{count:m.length})})]})]})})}function Is(){let e=Z(),l=(0,c.useRef)(!0),n=(0,c.useRef)(new Set),m=(0,c.useRef)(null),{skills:f,nativeSkillGroups:p,bots:g,packs:S,trustProjectSkills:o,delivery:D,loading:B,loadError:v,packsError:C,packsKnown:w,refresh:h,setSkills:x,setBots:E,setTrustProjectSkills:T,setDelivery:L}=Al({apiUnavailableText:e("skills.apiUnavailable")}),[A,$]=(0,c.useState)("library"),[H,K]=(0,c.useState)(null),[F,y]=(0,c.useState)(null),b=(0,c.useCallback)(t=>{K(t),y(t.installTargetSkill??null),$(t.tab)},[]),I=(0,c.useCallback)(()=>K(null),[]),[d,U]=(0,c.useState)(""),[G,te]=(0,c.useState)(""),[r,a]=(0,c.useState)(""),[M,P]=(0,c.useState)(null),[_,V]=(0,c.useState)(!1),[he,fe]=(0,c.useState)(!1),[ye,le]=(0,c.useState)(!1),[se,W]=(0,c.useState)([]),[Y,we]=(0,c.useState)(!1),[xe,Se]=(0,c.useState)(!1),[ze,Me]=(0,c.useState)(()=>new Set),[Ke,Ie]=(0,c.useState)(!1),[xl,nl]=(0,c.useState)(!1),[_e,Ml]=(0,c.useState)(null),[We,qe]=(0,c.useState)(()=>new Set),[El,Ee]=(0,c.useState)(null),[$l,al]=(0,c.useState)(null),[Ll,il]=(0,c.useState)(()=>new Set),[ol,Ne]=(0,c.useState)({}),[Je,Ce]=(0,c.useState)(null),[rl,Qe]=(0,c.useState)(null),[Hl,Pe]=(0,c.useState)(!1),[Ol,$e]=(0,c.useState)([]),[jl,Le]=(0,c.useState)(null),[He,cl]=(0,c.useState)(()=>new Set),Re=(0,c.useRef)(g),Oe=(0,c.useRef)(new Map);(0,c.useEffect)(()=>{Re.current=g},[g]);let je=(0,c.useMemo)(()=>new Set(f.map(t=>t.name)),[f]),ve=(0,c.useMemo)(()=>p.length===0?void 0:(_e?p.find(i=>Be(i)===_e):void 0)??p.find(i=>i.skills.length>0)??p[0],[_e,p]),Xe=ve?Be(ve):"",De=(0,c.useMemo)(()=>ve?ve.skills.filter(t=>!je.has(t.name)).map(t=>t.rootDir??t.source?.root??"").filter(Boolean):[],[ve,je]),dl=De.length>0&&De.every(t=>We.has(t)),ul=(0,c.useCallback)(()=>{for(let t of n.current)window.clearTimeout(t);n.current.clear()},[]),Fl=(0,c.useCallback)(t=>new Promise(i=>{let N=window.setTimeout(()=>{n.current.delete(N),i()},t);n.current.add(N)}),[]);(0,c.useEffect)(()=>(l.current=!0,()=>{l.current=!1,ul()}),[ul]),(0,c.useEffect)(()=>{qe(t=>{let i=new Set,N=new Set(f.map(R=>R.name));for(let R of p)for(let z of R.skills){let j=z.rootDir??z.source?.root??"";j&&!N.has(z.name)&&t.has(j)&&i.add(j)}return i.size===t.size?t:i})},[f,p]),(0,c.useEffect)(()=>{if(!Je||He.size>0)return;let t=window.setTimeout(()=>{l.current&&Ce(null)},6e3);return()=>window.clearTimeout(t)},[Je,He]),(0,c.useEffect)(()=>{let t=m.current;if(t)if(Ke&&!t.open)try{t.showModal()}catch{}else!Ke&&t.open&&t.close()},[Ke,Xe]);async function kl(t,i,N=!0){let R=t;for(i({text:e("skills.jobRunning"),ok:!0});;){if(!l.current)return null;if(R.status==="succeeded")return i({text:e("skills.saved"),ok:!0}),N&&await h(),R;if(R.status==="failed")throw new Error(R.error??"job_failed");if(await Fl(800),!l.current)return null;let z=await re(`/api/skills/jobs/${encodeURIComponent(R.id)}`,{method:"GET"});if(!l.current)return null;R=z.job}}function Ul(t){return g.filter(i=>ke(i.skills).includes(t)).map(i=>i.botName??i.larkAppId)}function Te(){W([]),Me(new Set),le(!1),Se(!1)}function ml(){return{source:d.trim(),path:G.trim()||void 0,ref:r.trim()||void 0,...Y?{fullDepth:!0}:{}}}function Gl(t,i=Y||xe){let N=t??[...ze];return{...ml(),skillNames:N.length>0?N:void 0,...i?{fullDepth:!0}:{}}}async function zl(){fe(!0),P({text:e("skills.scanning"),ok:!0});try{let t=await re("/api/skills/discover",{method:"POST",body:JSON.stringify(ml())});if(!l.current)return{skills:[],directInstall:!1,fullDepth:Y};let i=t.discovery?.directInstall===!0,N=Array.isArray(t.discovery?.skills)?t.discovery.skills:[],R=t.discovery?.deepScanned===!0;return Se(R),W(N),Me(sl(N,F).selected),{skills:N,directInstall:i,fullDepth:Y||R}}finally{l.current&&fe(!1)}}function me(t){let i=t||"";return i.startsWith("skill_git_command_failed")&&/authentication failed|could not read username|repository not found|unauthor|\b401\b|\b403\b/i.test(i)?e("skills.gitNeedsAuth"):i.startsWith("agentbuddy_not_found")?e("skills.agentbuddyNotFound"):i.startsWith("agentbuddy_login_required")?e("skills.agentbuddyNeedsLogin"):i.startsWith("agentbuddy_command_failed")?/login|credential|unauthor|not logged|401|403/i.test(i)?e("skills.agentbuddyNeedsLogin"):e("skills.agentbuddyCommandFailed"):i.startsWith("agentbuddy_clear_telemetry_failed")||i.startsWith("agentbuddy_telemetry_not_stripped")?e("skills.agentbuddyTelemetryFailed"):i.startsWith("agentbuddy_no_skill_produced")?e("skills.agentbuddyNoSkill"):i.startsWith("invalid_agentbuddy")?e("skills.agentbuddyInvalid"):i}async function Ze(t,i=Y||xe){V(!0);try{let N=await re("/api/skills/install",{method:"POST",body:JSON.stringify(Gl(t,i))});if(!l.current)return null;let R=await kl(N.job,P);if(!l.current||!R)return null;let z=(R.skills??(R.skill?[R.skill]:[])).map(j=>j.name).filter(Boolean);return Te(),y(null),[...new Set(z.length>0?z:t??[])]}catch(N){return l.current&&P({text:`${e("skills.failed")}: ${me(N?.message??String(N))}`,ok:!1}),null}finally{l.current&&V(!1)}}function Kl(t){Me(i=>{let N=new Set(i);return N.has(t)?N.delete(t):N.add(t),N})}function _l(t){Me(t?new Set(se.map(i=>i.name)):new Set)}async function Wl(){if(!d.trim())return P({text:e("skills.sourceRequired"),ok:!1}),null;try{le(!1);let{skills:t,directInstall:i,fullDepth:N}=await zl();if(!l.current)return null;if(i)return await Ze(void 0,N);if(t.length===0)return P({text:e("skills.scanEmpty"),ok:!1}),null;let{targetMissing:R}=sl(t,F);return t.length===1&&!R?await Ze([t[0].name],N):(P(R?{text:e("skills.installTargetNotFound",{skill:F}),ok:!1}:{text:e("skills.scanFound",{count:t.length}),ok:!0}),le(!0),null)}catch(t){return l.current&&P({text:`${e("skills.failed")}: ${me(t?.message??String(t))}`,ok:!1}),null}}async function ql(){let t=[...ze];return t.length===0?(P({text:e("skills.discoverNothingSelected"),ok:!1}),null):await Ze(t)}async function Jl(t){await re("/api/skill-packs",{method:"POST",body:JSON.stringify({id:t.id,name:t.name,include:t.skillNames.map(i=>`skill:${i}`)})}),l.current&&(await h(),l.current&&$("packs"))}async function Ql(){let t=[...We].filter(Boolean);if(t.length===0){P({text:e("skills.discoverNothingSelected"),ok:!1});return}nl(!0);try{if(P({text:e("skills.discoverRegisteringBatch",{total:t.length}),ok:!0}),await re("/api/skills/install-local-links",{method:"POST",body:JSON.stringify({sources:t})}),!l.current)return;Ie(!1),await h(),l.current&&P({text:e("skills.saved"),ok:!0})}catch(i){l.current&&P({text:`${e("skills.failed")}: ${me(i?.message??String(i))}`,ok:!1})}finally{l.current&&nl(!1)}}async function Xl(t){if(o!==t){Ee("project");try{let i=await re("/api/skills/global",{method:"PUT",body:JSON.stringify({trustProjectSkills:t})});if(!l.current)return;T(i.trustProjectSkills==="all"?"all":t)}catch(i){l.current&&window.alert(`${e("skills.failed")}: ${me(i?.message??String(i))}`)}finally{l.current&&Ee(null)}}}async function Zl(t){if(D!==t){Ee("delivery");try{let i=await re("/api/skills/global",{method:"PUT",body:JSON.stringify({delivery:t})});if(!l.current)return;L(i.delivery==="prompt"||i.delivery==="native"?i.delivery:t)}catch(i){l.current&&window.alert(`${e("skills.failed")}: ${me(i?.message??String(i))}`)}finally{l.current&&Ee(null)}}}async function Vl(t){al(`${t}:update`);try{let i=await re(`/api/skills/${encodeURIComponent(t)}/update`,{method:"POST",body:"{}"});if(!l.current)return;await kl(i.job,P)}catch(i){l.current&&window.alert(`${e("skills.failed")}: ${me(i?.message??String(i))}`)}finally{l.current&&al(null)}}function Yl(t){let i=[...new Set(t.filter(N=>je.has(N)))];i.length!==0&&(Qe(i),Pe(!0),$e([]),Le(null))}function es(){He.size>0||(Pe(!1),Qe(null),$e([]),Le(null))}async function ls(t){let i=rl??[];if(i.length!==0){cl(new Set(i)),Pe(!1),Le(null),Ce({text:e("skills.removingCount",{count:i.length}),ok:!0});try{let N=await re("/api/skills/remove",{method:"POST",body:JSON.stringify({names:i,force:t})});if(!l.current)return;let R=Array.isArray(N.removed)?N.removed.filter(j=>typeof j=="string"):i,z=new Set(R);x(j=>j.filter(ne=>!z.has(ne.name))),Ce({text:R.length===1?e("skills.removedOne",{skill:R[0]}):e("skills.removedMany",{count:R.length}),ok:!0}),Qe(null),$e([])}catch(N){if(!l.current)return;if(N?.status===409&&N?.body?.error==="skills_in_use"){let z=Array.isArray(N.body.affectedSkills)?N.body.affectedSkills.map(j=>{let ne=typeof j?.name=="string"?j.name:"",ie=Array.isArray(j?.affectedBots)?j.affectedBots.map(ae=>ae?.botName||ae?.larkAppId||"").filter(Boolean):Ul(ne),ce=Array.isArray(j?.affectedPacks)?j.affectedPacks.filter(ae=>typeof ae=="string"):[];return ne?{name:ne,bots:ie,packs:ce}:null}).filter(j=>j!==null):[];$e(z),Pe(!0),Ce(null);return}let R=e("skills.removeFailed",{detail:me(N?.message??String(N))});Le(R),Pe(!0),Ce({text:R,ok:!1})}finally{l.current&&cl(new Set)}}}function gl(t,i){let N=Oe.current.get(t)??Promise.resolve();il(z=>new Set(z).add(t));let R=N.catch(()=>{}).then(i);return Oe.current.set(t,R),R.finally(()=>{Oe.current.get(t)===R&&(Oe.current.delete(t),l.current&&il(z=>{let j=new Set(z);return j.delete(t),j}))})}async function pl(t,i,N){Ne(R=>({...R,[t]:null}));try{let R=Re.current.find(ie=>ie.larkAppId===t),z=Cl(R?.skills,i,N),j=await re(`/api/bots/${encodeURIComponent(t)}/skills`,{method:"PUT",body:JSON.stringify({action:"set",policy:z.length>0?{include:z}:null})});if(!l.current)return;let ne=ie=>ie.map(ce=>ce.larkAppId===t?{...ce,skills:j.skills??null}:ce);Re.current=ne(Re.current),E(ne),Ne(ie=>({...ie,[t]:{text:e("skills.policySaved"),ok:!0}}))}catch(R){throw l.current&&Ne(z=>({...z,[t]:{text:`${e("skills.failed")}: ${me(R?.message??String(R))}`,ok:!1}})),R}}function ss(t,i,N){return gl(t,()=>pl(t,i,N))}function ts(t,i,N){return gl(t,async()=>{let R=Re.current.find(ae=>ae.larkAppId===t),z=ke(R?.skills),j=be(R?.skills),[ne,ie]=i.split(":",2),ce=ae=>N?[...new Set([...ae,ie])]:ae.filter(cs=>cs!==ie);await pl(t,ne==="skill"?ce(z):z,ne==="pack"?ce(j):j)})}async function ns(t,i){Ne(N=>({...N,[t]:null}));try{if(await re(`/api/bots/${encodeURIComponent(t)}/skill-injection`,{method:"PUT",body:JSON.stringify({skillInjection:i})}),!l.current)return;E(N=>N.map(R=>R.larkAppId===t?{...R,skillInjection:i}:R)),Ne(N=>({...N,[t]:{text:e("skills.saved"),ok:!0}}))}catch(N){l.current&&Ne(R=>({...R,[t]:{text:`${e("skills.failed")}: ${N?.message??N}`,ok:!1}}))}}let as=g.filter(t=>Pl(t.skills)).length,is=g.reduce((t,i)=>t+(i.skills?.include?.length??0),0),ge=(0,c.useMemo)(()=>Ge(f,S,g,{packsKnown:w}),[f,S,g,w]),pe=(0,c.useMemo)(()=>Rl(ge),[ge]),Fe=(0,c.useMemo)(()=>[...ge.packs.values()].filter(t=>t.botIds.length===0).map(t=>t.id),[ge]),Ue=(0,c.useMemo)(()=>[...ge.bots.values()].filter(t=>t.health==="missing"||t.health==="pack_missing").map(t=>t.larkAppId),[ge]),os=(0,s.jsxs)("div",{className:"page-heading-actions skills-heading-actions",children:[(0,s.jsxs)("div",{className:"skills-metric-strip",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricInstalled")}),(0,s.jsx)("strong",{children:f.length})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricPacks")}),(0,s.jsx)("strong",{children:w?S.length:"\u2014"})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricBots")}),(0,s.jsxs)("strong",{children:[as,"/",g.length]})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricAttached")}),(0,s.jsx)("strong",{children:is})]})]}),(0,s.jsxs)("div",{className:"skills-issue-strip",role:"group","aria-label":e("skills.issuesLabel"),children:[pe.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-warn","data-action":"issue-dangling-skills",title:pe.join(", "),onClick:()=>b(pe.length===1?{tab:"library",librarySearch:pe[0],openInstallWizard:!0,installTargetSkill:pe[0]}:{tab:"library",libraryFilterSkills:pe}),children:e("skills.issueDangling",{count:pe.length})}),Fe.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-info","data-action":"issue-unassigned-packs",onClick:()=>b({tab:"packs",focusPackIds:Fe}),children:e("skills.issueUnassignedPacks",{count:Fe.length})}),Ue.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-warn","data-action":"issue-bots-missing",onClick:()=>b({tab:"bots",focusBotIds:Ue}),children:e("skills.issueBotsMissing",{count:Ue.length})}),!B&&w&&pe.length===0&&Fe.length===0&&Ue.length===0&&(0,s.jsx)("span",{className:"skills-issue-badge skills-issue-ok","data-skills-healthy":!0,children:e("skills.issueNone")})]}),(0,s.jsx)(bl,{id:"skills-refresh",label:e("skills.refresh"),busy:B,disabled:B,onClick:()=>{h()}})]}),rs=(0,s.jsx)("div",{className:"skills-page-stack",children:B?(0,s.jsx)(vl,{label:e("common.loading")}):v?(0,s.jsx)("p",{className:"hint-warn",children:v}):(0,s.jsxs)(s.Fragment,{children:[C&&(0,s.jsx)("p",{className:"hint-warn","data-packs-error":!0,role:"alert",children:e(w?"skills.packsLoadError":"skills.packsLoadErrorFirst",{error:C})}),(0,s.jsxs)("div",{className:"skills-tabs",role:"tablist",children:[(0,s.jsx)("button",{role:"tab","aria-selected":A==="library",className:A==="library"?"active":"",onClick:()=>$("library"),children:e("skills.tabLibrary")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="packs",className:A==="packs"?"active":"",onClick:()=>$("packs"),children:e("skills.tabPacks")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="bots",className:A==="bots"?"active":"",onClick:()=>$("bots"),children:e("skills.tabBots")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="delivery",className:A==="delivery"?"active":"",onClick:()=>$("delivery"),children:e("skills.tabDelivery")})]}),A==="packs"&&(0,s.jsx)(yl,{skills:f,packs:S,packsKnown:w,onRefresh:()=>{h()},focusPackId:H?.tab==="packs"?H.focusPackId??null:null,focusPackIds:H?.tab==="packs"?H.focusPackIds??null:null,onFocusConsumed:I,onOpenBot:t=>b({tab:"bots",focusBotIds:[t]}),onInstallMissingSkill:t=>b({tab:"library",librarySearch:t,openInstallWizard:!0,installTargetSkill:t})}),A==="library"&&(0,s.jsx)(Il,{skills:f,nativeSkillGroups:p,installSource:d,installPath:G,installRef:r,installFullDepth:Y,installStatus:M,installBusy:_,installDiscovering:he,installSelectionOpen:ye,installCandidates:se,selectedInstallSkills:ze,onInstallSourceChange:t=>{U(t),Te()},onInstallPathChange:t=>{te(t),Te()},onInstallRefChange:t=>{a(t),Te()},onInstallFullDepthChange:t=>{we(t),Te()},onToggleInstallSkill:Kl,onSelectAllInstallSkills:_l,onConfirmInstallSelection:ql,onCloseInstallSelection:()=>le(!1),onInstall:Wl,onOpenNativeDiscovery:()=>Ie(!0),onCreatePack:Jl,InstallPanel:Ss,InstalledLibrary:Ns,RemoveDialog:ws,removingNames:He,removalDialogOpen:Hl,pendingRemoval:rl,removalReferences:Ol,removalError:jl,skillBusy:$l,installedStatus:Je,onUpdateSkill:t=>{Vl(t)},onRequestRemove:Yl,onCancelRemoval:es,onConfirmRemoval:t=>{ls(t)},navIntent:H?.tab==="library"?H:null,onNavIntentConsumed:I,installTargetSkill:F,onClearInstallTarget:()=>y(null),packsKnown:w,onInstallMissing:t=>b({tab:"library",openInstallWizard:!0,installTargetSkill:t}),graph:ge,packNames:S.map(t=>({id:t.id,name:t.name})),onShowSkillPacks:t=>{let i=ge.skills.get(t)?.packIds??[];b(i.length===1?{tab:"packs",focusPackId:i[0]}:{tab:"packs",focusPackIds:i})},onShowSkillBots:t=>b({tab:"bots",focusSkill:t})}),A==="bots"&&(0,s.jsx)(Dl,{bots:g,skills:f,statuses:ol,onSave:ss,onMutate:ts,busyBotIds:Ll,packs:S,packsKnown:w,focusBotIds:H?.tab==="bots"?H.focusBotIds??null:null,focusSkill:H?.tab==="bots"?H.focusSkill??null:null,onFocusConsumed:I,onOpenPack:t=>b({tab:"packs",focusPackId:t}),onOpenSkill:t=>b({tab:"library",librarySearch:t})}),A==="delivery"&&(0,s.jsx)(Tl,{trustProjectSkills:o,delivery:D,globalBusy:El,onUpdateProject:t=>{Xl(t)},onUpdateDelivery:t=>{Zl(t)},bots:g,onUpdateBotInjection:ns,botStatuses:ol,SkillSegmented:ys}),(0,s.jsx)("dialog",{className:"skills-discovery-dialog",id:"skills-discovery-dialog",ref:m,onClose:()=>Ie(!1),onClick:t=>{t.target===t.currentTarget&&Ie(!1)},children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:e("skills.discoverTitle")}),(0,s.jsx)("p",{children:e("skills.discoverHelp")}),(0,s.jsx)("button",{type:"button",className:"skills-discovery-close","data-action":"close-discovery","aria-label":e("skills.discoverClose"),title:e("skills.discoverClose"),onClick:()=>Ie(!1)})]}),(0,s.jsx)("div",{className:"skills-discovery-body",children:ve?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"skills-discovery-layout",children:[(0,s.jsx)("div",{className:"skills-discovery-tabs",role:"tablist","aria-label":e("skills.discoverTitle"),children:p.map(t=>{let i=Be(t),N=i===Xe;return(0,s.jsxs)("button",{type:"button",role:"tab","data-discovery-tab":i,className:N?"selected":"","aria-selected":N?"true":"false",onClick:()=>Ml(i),children:[(0,s.jsx)("strong",{children:t.label??t.cliId}),(0,s.jsx)("small",{children:e("skills.skillCount",{count:t.skills.length})})]},i)})}),(0,s.jsxs)("div",{className:"skills-discovery-main",children:[(0,s.jsx)("div",{className:"skills-discovery-path",children:(0,s.jsx)("code",{children:ve.rootDir})}),p.map(t=>{let i=Be(t);return(0,s.jsx)("section",{className:"skills-discovery-group","data-discovery-panel":i,hidden:!(i===Xe),children:t.skills.length===0?(0,s.jsx)("p",{className:"empty",children:e("skills.discoverGroupEmpty")}):(0,s.jsx)("div",{className:"skills-discovery-list",children:t.skills.map(R=>{let z=je.has(R.name),j=R.rootDir??R.source?.root??"";return(0,s.jsxs)("label",{className:`skills-discovery-row${z?" installed":""}`,children:[(0,s.jsx)("input",{type:"checkbox","data-discovered-skill":!0,value:j,disabled:z,checked:!z&&We.has(j),onChange:ne=>{let ie=ne.currentTarget.checked;qe(ce=>{let ae=new Set(ce);return ie?ae.add(j):ae.delete(j),ae})}}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:R.name}),R.description?(0,s.jsx)("small",{children:R.description}):null]}),z?(0,s.jsx)("em",{children:e("skills.discoverRegistered")}):null]},`${R.name}:${j}`)})})},i)})]})]})}):(0,s.jsx)("p",{className:"empty",children:e("skills.discoverEmpty")})}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button","data-action":"toggle-discovered-skills",disabled:De.length===0,onClick:()=>{qe(t=>{let i=new Set(t);return dl?De.forEach(N=>i.delete(N)):De.forEach(N=>i.add(N)),i})},children:e(dl?"skills.discoverClearSelection":"skills.discoverSelectAll")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"register-discovered-skills",disabled:xl,onClick:()=>{Ql()},children:e("skills.discoverRegister")})]})]})})]})});return(0,s.jsxs)("section",{className:"page skills-page",children:[(0,s.jsxs)("div",{className:"page-heading",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"eyebrow",children:e("nav.skills")}),(0,s.jsx)("h1",{children:e("skills.title")})]}),os]}),(0,s.jsx)("div",{id:"skills-body",children:rs})]})}function Cs(e,l){return e.size===l.length&&l.every(n=>e.has(n))}function Ps(e){let l=Z(),n=(0,c.useRef)(null),m=(0,c.useRef)(null),f=(0,c.useRef)(null),[p,g]=(0,c.useState)(!1),[S,o]=(0,c.useState)(""),[D,B]=(0,c.useState)(()=>new Set(e.names)),[v,C]=(0,c.useState)(null),w=e.names.join(`
4
4
  `),h=S.trim().toLocaleLowerCase(),x=(0,c.useMemo)(()=>{let b=new Map(e.skills.map(I=>[I.name,I]));for(let I of e.names)b.has(I)||b.set(I,{name:I});return[...b.values()].sort((I,d)=>I.name.localeCompare(d.name))},[e.names,e.skills]),E=(0,c.useMemo)(()=>h?x.filter(b=>`${b.name} ${b.description||""}`.toLocaleLowerCase().includes(h)):x,[h,x]),T=!Cs(D,e.names),L=(0,c.useCallback)(()=>{let b=m.current;if(!b||typeof window>"u")return;let I=b.getBoundingClientRect(),d=12,U=7,G=Math.min(370,Math.max(260,window.innerWidth-d*2)),te=Math.min(Math.max(d,I.left),Math.max(d,window.innerWidth-G-d)),r=Math.max(0,I.top-U-d),a=Math.max(0,window.innerHeight-I.bottom-U-d),M=r>a,P=M?r:a,_=118+Math.min(x.length,5)*42,V=Math.max(180,Math.min(_,P));C({left:te,top:M?Math.max(d,I.top-U-V):I.bottom+U,width:G,height:V})},[x.length]);(0,c.useEffect)(()=>{p||B(new Set(e.names))},[w,p]),(0,c.useEffect)(()=>{if(!p||typeof document>"u")return;let b=I=>{n.current?.contains(I.target)||f.current?.contains(I.target)||(g(!1),o(""),B(new Set(e.names)))};return document.addEventListener("pointerdown",b),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),L(),()=>{document.removeEventListener("pointerdown",b),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[w,p,L]);function A(){B(new Set(e.names)),o(""),L(),g(!0)}function $(){B(new Set(e.names)),o(""),g(!1)}function H(b){B(I=>{let d=new Set(I);return d.has(b)?d.delete(b):d.add(b),d})}async function K(){let b=[...D].sort((I,d)=>I.localeCompare(d));try{await e.onSave(b),o(""),g(!1)}catch{}}let F=e.names.length===0?l("skills.pickerPlaceholder"):e.names.length===1?e.names[0]:l("skills.pickerSelectedCount",{count:e.names.length}),y=p?(0,s.jsxs)("div",{ref:f,className:"skills-multi-picker-popover",style:v?{left:v.left,top:v.top,width:v.width,height:v.height}:void 0,children:[(0,s.jsxs)("div",{className:"skills-multi-picker-head",children:[(0,s.jsxs)("label",{className:"skills-multi-picker-search",children:[(0,s.jsx)("span",{className:"skills-multi-picker-search-icon","aria-hidden":"true"}),(0,s.jsx)("input",{type:"search","data-action":"search-skills",autoFocus:!0,autoComplete:"off",value:S,placeholder:l("skills.pickerSearchPlaceholder"),onChange:b=>o(b.currentTarget.value),onKeyDown:b=>{b.key==="Escape"&&(b.preventDefault(),$())}})]}),(0,s.jsxs)("div",{className:"skills-multi-picker-meta",children:[(0,s.jsx)("span",{children:l("skills.pickerSelectionMeta",{selected:D.size,total:x.length})}),D.size>0?(0,s.jsx)("button",{type:"button",className:"skills-multi-picker-clear","data-action":"clear-skill-selection",onClick:()=>B(new Set),children:l("skills.pickerClear")}):null]})]}),(0,s.jsxs)("div",{className:"skills-multi-picker-options",role:"listbox","aria-label":l("skills.priority"),"aria-multiselectable":"true",children:[E.map(b=>{let I=D.has(b.name),d=!e.installedNames.has(b.name);return(0,s.jsxs)("button",{type:"button",className:`skills-multi-picker-option${I?" selected":""}${d?" dangling":""}`,role:"option","aria-selected":I,"data-skill-name":b.name,onClick:()=>H(b.name),children:[(0,s.jsx)("span",{className:"skills-multi-picker-check","aria-hidden":"true"}),(0,s.jsxs)("span",{className:"skills-multi-picker-option-copy",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("b",{children:b.name}),d?(0,s.jsx)("em",{children:l("skills.dangling")}):null]}),b.description?(0,s.jsx)("small",{children:b.description}):null]})]},b.name)}),E.length===0?(0,s.jsx)("p",{className:"skills-multi-picker-empty",children:l("skills.pickerNoResults")}):null]}),(0,s.jsxs)("footer",{className:"skills-multi-picker-actions",children:[(0,s.jsx)("button",{type:"button",className:"ghost","data-action":"cancel-skill-selection",disabled:e.busy,onClick:$,children:l("skills.cancel")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"save-skill-selection",disabled:!T||e.busy,onClick:()=>{K()},children:e.busy?l("skills.saving"):l("skills.saveSelection")})]})]}):null;return(0,s.jsxs)("div",{ref:n,className:`skills-multi-picker${p?" open":""}`,"data-skill-picker":e.botId,children:[(0,s.jsxs)("button",{ref:m,type:"button",className:"skills-multi-picker-trigger","data-action":"open-skill-picker","aria-haspopup":"listbox","aria-expanded":p,disabled:e.busy,onClick:()=>p?$():A(),children:[(0,s.jsxs)("span",{className:"skills-multi-picker-trigger-copy",children:[(0,s.jsx)("b",{children:F}),(0,s.jsx)("small",{children:l("skills.pickerTriggerHint")})]}),(0,s.jsx)("span",{className:"skills-multi-picker-chevron","aria-hidden":"true"})]}),y&&typeof document<"u"?(0,Bl.createPortal)(y,document.body):y]})}function Ys(e){let l=Z(),{bot:n,installedNames:m,skills:f,status:p,busyKey:g,onSave:S}=e,o=n.botName??n.larkAppId,D=ke(n.skills);return n.error?(0,s.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":n.larkAppId,children:[(0,s.jsxs)("header",{children:[(0,s.jsx)(Ye,{html:Ve({name:o,larkAppId:n.larkAppId,size:"sm"})}),(0,s.jsx)("strong",{children:o})]}),(0,s.jsx)("p",{className:"hint-warn-inline",children:n.error})]}):(0,s.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":n.larkAppId,children:[(0,s.jsxs)("header",{className:"skills-bot-head",children:[(0,s.jsx)(Ye,{html:Ve({name:o,larkAppId:n.larkAppId,size:"sm",dot:"ok"})}),(0,s.jsxs)("div",{className:"skills-bot-title-line",children:[(0,s.jsx)("strong",{children:o}),(0,s.jsx)("span",{className:"skills-count-pill",children:l("skills.skillCount",{count:D.length})})]})]}),(0,s.jsxs)("section",{className:"skills-policy-panel",children:[(0,s.jsx)("div",{className:"skills-priority-head",children:(0,s.jsx)("h3",{className:"skills-priority-title",children:l("skills.priority")})}),(0,s.jsx)(Ps,{botId:n.larkAppId,names:D,installedNames:m,skills:f,busy:g===`${n.larkAppId}:set`,onSave:B=>S(n.larkAppId,B)})]}),(0,s.jsx)("span",{className:tl(p),"data-bot-status":!0,children:p?.text??""})]})}function et(e){return fl(e,(0,s.jsx)(Is,{}))}export{Ys as BotPolicyCard,Ns as InstalledSkillsLibrary,ws as RemoveSkillsDialog,Ps as SkillMultiPicker,ys as SkillSegmented,Ss as SkillsInstallPanel,Is as SkillsPage,et as renderSkillsPage};
@@ -1 +1 @@
1
- import{a as E,b as J,c as S,d as V}from"./chunk-EVK77ASG.js";import{c as F}from"./chunk-2WQDS65D.js";import{a as se,d as q,g as ie,q as re}from"./chunk-5CJMHTT4.js";import"./chunk-G5XGBCM6.js";import"./chunk-Q2MT4VWH.js";import{a as K}from"./chunk-SYC6D5XU.js";import{a as z,d as oe}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var l=L(z(),1);async function W(){return E("/api/team/hosted")}async function le(){return E("/api/team/remote-roster")}async function de(t,a){return V("/api/team/local-bots/"+encodeURIComponent(t)+"/capability",{capability:a})}async function me(t){return E("/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 be(t){return J("DELETE","/api/team/hosted/"+encodeURIComponent(t))}async function fe(t,a){return V(`/api/team/hosted/${encodeURIComponent(t)}/feedback`,{feedback:a})}async function ke(t){return S("/api/team/local-invite",{teamId:t})}async function he(t,a){return S("/api/team/join-remote",{hubUrl:t,inviteCode:a})}function G(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 ve(t){return Array.from(new Set(t.flatMap(a=>a.bots.map(n=>n.cliId)).filter(Boolean))).sort()}function Te(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 Ne(t,a){return(t.memberships||[]).map(o=>{let d=o.roster?.deployments||[],r=d.find(T=>T.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:d,bots:o.roster?.bots||[]}})}function Q(t,a,n){return t.map(o=>({...o,bots:o.bots.map(d=>d.larkAppId===a?{...d,capability:n.trim()||null}:d)}))}var e=L(oe(),1),Se=L(z(),1);function we(){let t=(0,l.useRef)(!0);return(0,l.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Ce(t){let a=F(),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 X(t,a){return t.get(a)??new Set}function Le(){let t=F(),a=we(),[n,o]=(0,l.useState)([]),[d,r]=(0,l.useState)([]),[p,T]=(0,l.useState)(""),[k,y]=(0,l.useState)(t("team.unbound")),[u,R]=(0,l.useState)({query:"",cliId:"",hasCapability:!1,hasRole:!1}),[B,x]=(0,l.useState)(()=>new Map),[D,M]=(0,l.useState)(()=>new Map),[O,I]=(0,l.useState)(()=>new Set),[P,H]=(0,l.useState)(()=>new Set),[U,w]=(0,l.useState)({kind:"hidden"}),[j,c]=(0,l.useState)(()=>new Map),[g,N]=(0,l.useState)(null),b=(0,l.useMemo)(()=>[...n,...d],[n,d]),Z=(0,l.useMemo)(()=>ve(b),[b]),ee=(0,l.useMemo)(()=>[{value:"",label:t("team.allCli")},...Z.map(s=>({value:s,label:s}))],[Z,t]),A=(0,l.useCallback)(async()=>{let s=await W();if(!a.current)return;let i=s.body;if(!i?.ok){o([]);return}T(i.deployment?.deploymentId??""),y(i.deployment?.ownerName||(i.deployment?.ownerUnionId?t("team.bound"):t("team.unbound"))),o(Te(i,t))},[a,t]),te=(0,l.useCallback)(async()=>{let s=await le();a.current&&r(Ne(s.body,t))},[a,t]);(0,l.useEffect)(()=>{x(new Map),M(new Map),I(new Set),H(new Set),A(),te()},[A,te]),(0,l.useEffect)(()=>{y(s=>s==="\u672A\u7ED1\u5B9A"||s==="Unbound"?t("team.unbound"):s)},[t]),(0,l.useEffect)(()=>{let s=new Map;for(let i of b)s.set(i.key,new Set(i.bots.filter(m=>G(m,u)).map(m=>m.larkAppId)));x(i=>{let m=!1,f=new Map;for(let[h,v]of i){let C=s.get(h),_=new Set([...v].filter(Ae=>C?.has(Ae)));_.size!==v.size&&(m=!0),_.size&&f.set(h,_)}return m?f:i})},[u,b]);let ae=(0,l.useMemo)(()=>{if(!b.length)return"";let s=new Set,i=new Set;for(let h of b)h.bots.filter(C=>G(C,u)).forEach(C=>s.add(C.larkAppId)),h.bots.forEach(C=>i.add(C.larkAppId));let m=b.length>1?t("team.acrossTeams",{n:b.length}):"";return`\xB7 ${s.size===i.size?`${i.size}`:`${s.size} / ${i.size}`} ${t("team.botsWord")}${m}`},[u,b,t]);function $(s,i){c(m=>{let f=new Map(m);return f.set(s,i),f})}function xe(s,i,m){x(f=>{let h=new Map(f),v=new Set(h.get(s)??[]);return m?v.add(i):v.delete(i),v.size?h.set(s,v):h.delete(s),h})}function Me(s,i){M(m=>{let f=new Map(m);return i?f.set(s,i):f.delete(s),f})}async function Pe(s,i){await de(s,i),a.current&&(o(m=>Q(m,s,i)),r(m=>Q(m,s,i)))}async function Be(s,i){let m=await me(s);a.current&&N({app:s,name:i,content:m.body?.role||""})}async function De(s,i,m){confirm(t("team.removeMemberConfirm",{name:m}))&&(await ue(s,i),a.current&&A())}async function He(s){let i=[...X(B,s.key)];if(!i.length){$(s.key,{kind:"err",key:"team.errPickBot"});return}let m=(D.get(s.key)||"").trim()||t("team.defaultGroupName");$(s.key,{kind:"muted",key:"team.creatingGroup"});let f=s.kind==="local"?await pe(s.teamId,m,i):await ge(s.hubUrl,s.teamId,m,i);a.current&&($(s.key,{kind:"group-result",body:f.body,status:f.status}),f.body?.ok&&(x(h=>{let v=new Map(h);return v.delete(s.key),v}),M(h=>{let v=new Map(h);return v.delete(s.key),v}),s.kind==="local"&&A()))}async function ne(s){w({kind:"loading",key:s?"team.binding":"team.identifying"});let i=await ce(s);if(!a.current)return;let m=i.body;if(m?.ok&&m.owner){w({kind:"ok",name:m.owner.name||m.owner.unionId||""}),A();return}if(m?.ok&&m.needChoice&&Array.isArray(m.candidates)){w({kind:"choice",candidates:m.candidates});return}if(m?.error==="no_candidates"){w({kind:"err",key:"team.noCandidates"});return}w({kind:"bind-fail",error:String(m?.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:k}),(0,e.jsx)("button",{type:"button",id:"tf-autobind",className:"page-primary-action",onClick:()=>{ne()},children:t("team.bindBtn")}),(0,e.jsx)("span",{id:"tf-bind-out",className:"team-bind-status",hidden:U.kind==="hidden",children:(0,e.jsx)(Oe,{state:U,tr:t,onPick:s=>{ne(s)}})})]})})]}),(0,e.jsxs)("section",{className:"overview-block team-roster-section",children:[(0,e.jsx)(q,{title:t("team.myTeams"),count:ae?ae.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:s=>s.preventDefault(),children:[(0,e.jsx)("input",{id:"tf-search",type:"search",placeholder:t("team.searchPh"),value:u.query,onChange:s=>R(i=>({...i,query:s.target.value}))}),(0,e.jsx)(re,{id:"tf-cli",className:"team-cli-menu",ariaLabel:t("team.allCli"),value:u.cliId,label:se(ee,u.cliId),options:ee,onChange:s=>R(i=>({...i,cliId:s}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-fcap",checked:u.hasCapability,onChange:s=>R(i=>({...i,hasCapability:s.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:s=>R(i=>({...i,hasRole:s.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)(Ue,{teams:b,filters:u,pickedByTeam:B,gnameByTeam:D,expandedTeams:O,expandedDeps:P,groupOutputs:j,myDeploymentId:p,tr:t,onToggleTeam:s=>I(i=>Re(i,s)),onToggleDep:s=>H(i=>Re(i,s)),onPick:xe,onGroupNameChange:Me,onCapabilityChange:(s,i)=>{Pe(s,i)},onOpenRole:(s,i)=>{Be(s,i)},onRemoveMember:(s,i,m)=>{De(s,i,m)},onPullGroup:s=>{He(s)}})})]})]}),(0,e.jsx)(_e,{state:g,tr:t,onClose:()=>N(null)})]})}function Re(t,a){let n=new Set(t);return n.has(a)?n.delete(a):n.add(a),n}function Oe(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 Ue(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=>G(p,t.filters)),d=!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":!d,onClick:()=>t.onToggleTeam(n.key),children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:d?"\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})})]}),d?null:n.kind==="remote"&&!n.ok?(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:a("team.rosterFail")}):(0,e.jsx)(je,{...t,team:n,filtered:o})]},n.key)})}):(0,e.jsx)("p",{className:"muted",children:a("team.noTeams")})}function je(t){let{team:a,tr:n}=t,o=[...a.deployments].sort((r,p)=>r.local===p.local?0:r.local?-1:1),d=o.some(r=>t.filtered.some(p=>p.deployment.id===r.id));return(0,e.jsxs)(e.Fragment,{children:[o.map(r=>(0,Se.createElement)(Fe,{...t,deployment:r,key:r.id})),d?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 Fe(t){let{team:a,deployment:n,tr:o}=t,d=t.filtered.filter(u=>u.deployment.id===n.id);if(!d.length)return null;let r=n.id===t.myDeploymentId,p=r?o("team.tagLocal"):n.stale?o("team.tagRemoteStale"):o("team.tagRemote"),T=`${a.key}::${n.id}`,k=t.expandedDeps.has(T),y=d.filter(u=>X(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":T,"aria-expanded":k,role:"button",tabIndex:0,onClick:()=>t.onToggleDep(T),onKeyDown:u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),t.onToggleDep(T))},children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:k?"\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:d.length}),y?o("team.depSelected",{n:y}):""]}),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]}),k?(0,e.jsx)("div",{className:"team-roster-list",children:d.map(u=>(0,e.jsx)(Ee,{bot:u,mine:r,picked:X(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,d=()=>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=>{Ie(r.target)||d()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||Ie(r.target)||(r.preventDefault(),d())},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 Ie(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)($e,{body:a.body,status:a.status,tr:n}):null}function $e(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 d=a?.error||n,r=d==="no_local_online_bot"?o("team.errNoLocalBot"):d==="all_bots_skipped_no_owner"?o("team.errAllSkipped"):d==="no_creator_available"?o("team.errNoCreator"):d==="delegation_timeout"?o("team.errDelegationTimeout"):o("team.errGroupCreate",{error:String(d)});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 ze(){let t=F(),a=we(),[n,o]=(0,l.useState)([]),[d,r]=(0,l.useState)(""),[p,T]=(0,l.useState)(""),[k,y]=(0,l.useState)({kind:"none"}),[u,R]=(0,l.useState)(()=>new Map),[B,x]=(0,l.useState)(""),[D,M]=(0,l.useState)(""),[O,I]=(0,l.useState)({kind:"none"}),P=(0,l.useCallback)(async()=>{let c=await W();if(!a.current)return;let g=c.body;r(N=>g?.suggestedHubUrl||N),o(g?.teams||[])},[a]);(0,l.useEffect)(()=>{P()},[P]);async function H(){let c=p.trim();if(!c){y({kind:"err",key:"team.errName"});return}y({kind:"muted",key:"team.creating"});let g=await ye(c);a.current&&(g.body?.ok?(y({kind:"ok",key:"team.created"}),T(""),P()):y({kind:"create-fail",error:String(g.body?.error||g.status)}))}async function U(c){R(N=>{let b=new Map(N);return b.set(c,{kind:"muted",key:"team.generating"}),b});let g=await ke(c);a.current&&R(N=>{let b=new Map(N);return b.set(c,g.body?.code?{kind:"invite",code:g.body.code}:{kind:"err",key:"team.genFail"}),b})}async function w(c,g){confirm(t("team.delConfirm",{name:g}))&&(await be(c),a.current&&P())}async function j(){let c=B.trim(),g=D.trim();if(I({kind:"muted",key:"team.joining"}),!c||!g){I({kind:"err",key:"team.errHubCode"});return}let N=await he(c,g);a.current&&(N.body?.ok?(I({kind:"joined",name:String(N.body.teamName||"")}),M("")):I({kind:"join-fail",error:N.body?.error||N.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(),H()},children:[(0,e.jsx)("input",{id:"tm-newname",type:"text",placeholder:t("team.newTeamPh"),value:p,onChange:c=>T(c.target.value)}),(0,e.jsx)(ie,{id:"tm-create",className:"page-primary-action",onClick:()=>{H()},children:t("team.createTeamBtn")}),(0,e.jsx)("span",{className:"toolbar-status tm-cout",children:(0,e.jsx)(Y,{status:k,tr:t})})]}),(0,e.jsx)("div",{id:"tm-list",children:(0,e.jsx)(Ke,{teams:n,suggestedHubUrl:d,inviteStatuses:u,tr:t,onInvite:c=>{U(c)},onDelete:(c,g)=>{w(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:B,onChange:c=>x(c.target.value)}),(0,e.jsx)("input",{id:"tm-code",type:"text",placeholder:t("team.codePh"),value:D,onChange:c=>M(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)(Y,{status:O,tr:t})})]})]})}function Ke(t){let{teams:a,tr:n}=t;return a.length?(0,e.jsx)(e.Fragment,{children:a.map(o=>{let d=(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}),d?n("team.manageMetaRemote",{r:d}):""," \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)(Y,{status:r,tr:n,suggestedHubUrl:t.suggestedHubUrl})}),(0,e.jsx)(qe,{teamId:o.teamId,initial:o.feedback??null})]},o.teamId)})}):(0,e.jsx)("p",{className:"muted",children:n("team.noTeamsShort")})}function qe(t){let[a,n]=(0,l.useState)(JSON.stringify(t.initial??{enabled:!1},null,2)),[o,d]=(0,l.useState)(""),[r,p]=(0,l.useState)(!1);async function T(){p(!0),d("");try{let k=JSON.parse(a),y=await fe(t.teamId,k);if(y.status<200||y.status>=300||y.body.ok===!1)throw new Error(String(y.body?.error??y.status));n(JSON.stringify(y.body.feedback??null,null,2)),d("\u2713 \u5DF2\u4FDD\u5B58")}catch(k){d(`\u2717 ${k instanceof Error?k.message:String(k)}`)}finally{p(!1)}}return(0,e.jsxs)("div",{className:"team-feedback-editor",children:[(0,e.jsxs)("label",{children:[(0,e.jsx)("span",{children:"\u56E2\u961F\u53CD\u9988\u7B56\u7565"}),(0,e.jsx)("textarea",{rows:6,value:a,disabled:r,onChange:k=>n(k.target.value)})]}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",disabled:r,onClick:()=>{T()},children:"\u4FDD\u5B58\u53CD\u9988\u7B56\u7565"}),(0,e.jsx)("span",{children:o})]})]})}function Y(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,d=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:d})}function Ze(t){return K(t,(0,e.jsx)(Le,{}))}function et(t){return K(t,(0,e.jsx)(ze,{}))}export{Ze as renderTeamFederationPage,et as renderTeamManagePage};
1
+ import{a as E,b as J,c as S,d as V}from"./chunk-EVK77ASG.js";import{a as se,d as q,g as ie,q as re}from"./chunk-5CJMHTT4.js";import{d as F}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import"./chunk-F6KNPF4R.js";import{a as K}from"./chunk-SYC6D5XU.js";import{a as z,d as oe}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var l=L(z(),1);async function W(){return E("/api/team/hosted")}async function le(){return E("/api/team/remote-roster")}async function de(t,a){return V("/api/team/local-bots/"+encodeURIComponent(t)+"/capability",{capability:a})}async function me(t){return E("/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 be(t){return J("DELETE","/api/team/hosted/"+encodeURIComponent(t))}async function fe(t,a){return V(`/api/team/hosted/${encodeURIComponent(t)}/feedback`,{feedback:a})}async function ke(t){return S("/api/team/local-invite",{teamId:t})}async function he(t,a){return S("/api/team/join-remote",{hubUrl:t,inviteCode:a})}function G(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 ve(t){return Array.from(new Set(t.flatMap(a=>a.bots.map(n=>n.cliId)).filter(Boolean))).sort()}function Te(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 Ne(t,a){return(t.memberships||[]).map(o=>{let d=o.roster?.deployments||[],r=d.find(T=>T.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:d,bots:o.roster?.bots||[]}})}function Q(t,a,n){return t.map(o=>({...o,bots:o.bots.map(d=>d.larkAppId===a?{...d,capability:n.trim()||null}:d)}))}var e=L(oe(),1),Se=L(z(),1);function we(){let t=(0,l.useRef)(!0);return(0,l.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Ce(t){let a=F(),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 X(t,a){return t.get(a)??new Set}function Le(){let t=F(),a=we(),[n,o]=(0,l.useState)([]),[d,r]=(0,l.useState)([]),[p,T]=(0,l.useState)(""),[k,y]=(0,l.useState)(t("team.unbound")),[u,R]=(0,l.useState)({query:"",cliId:"",hasCapability:!1,hasRole:!1}),[B,x]=(0,l.useState)(()=>new Map),[D,M]=(0,l.useState)(()=>new Map),[O,I]=(0,l.useState)(()=>new Set),[P,H]=(0,l.useState)(()=>new Set),[U,w]=(0,l.useState)({kind:"hidden"}),[j,c]=(0,l.useState)(()=>new Map),[g,N]=(0,l.useState)(null),b=(0,l.useMemo)(()=>[...n,...d],[n,d]),Z=(0,l.useMemo)(()=>ve(b),[b]),ee=(0,l.useMemo)(()=>[{value:"",label:t("team.allCli")},...Z.map(s=>({value:s,label:s}))],[Z,t]),A=(0,l.useCallback)(async()=>{let s=await W();if(!a.current)return;let i=s.body;if(!i?.ok){o([]);return}T(i.deployment?.deploymentId??""),y(i.deployment?.ownerName||(i.deployment?.ownerUnionId?t("team.bound"):t("team.unbound"))),o(Te(i,t))},[a,t]),te=(0,l.useCallback)(async()=>{let s=await le();a.current&&r(Ne(s.body,t))},[a,t]);(0,l.useEffect)(()=>{x(new Map),M(new Map),I(new Set),H(new Set),A(),te()},[A,te]),(0,l.useEffect)(()=>{y(s=>s==="\u672A\u7ED1\u5B9A"||s==="Unbound"?t("team.unbound"):s)},[t]),(0,l.useEffect)(()=>{let s=new Map;for(let i of b)s.set(i.key,new Set(i.bots.filter(m=>G(m,u)).map(m=>m.larkAppId)));x(i=>{let m=!1,f=new Map;for(let[h,v]of i){let C=s.get(h),_=new Set([...v].filter(Ae=>C?.has(Ae)));_.size!==v.size&&(m=!0),_.size&&f.set(h,_)}return m?f:i})},[u,b]);let ae=(0,l.useMemo)(()=>{if(!b.length)return"";let s=new Set,i=new Set;for(let h of b)h.bots.filter(C=>G(C,u)).forEach(C=>s.add(C.larkAppId)),h.bots.forEach(C=>i.add(C.larkAppId));let m=b.length>1?t("team.acrossTeams",{n:b.length}):"";return`\xB7 ${s.size===i.size?`${i.size}`:`${s.size} / ${i.size}`} ${t("team.botsWord")}${m}`},[u,b,t]);function $(s,i){c(m=>{let f=new Map(m);return f.set(s,i),f})}function xe(s,i,m){x(f=>{let h=new Map(f),v=new Set(h.get(s)??[]);return m?v.add(i):v.delete(i),v.size?h.set(s,v):h.delete(s),h})}function Me(s,i){M(m=>{let f=new Map(m);return i?f.set(s,i):f.delete(s),f})}async function Pe(s,i){await de(s,i),a.current&&(o(m=>Q(m,s,i)),r(m=>Q(m,s,i)))}async function Be(s,i){let m=await me(s);a.current&&N({app:s,name:i,content:m.body?.role||""})}async function De(s,i,m){confirm(t("team.removeMemberConfirm",{name:m}))&&(await ue(s,i),a.current&&A())}async function He(s){let i=[...X(B,s.key)];if(!i.length){$(s.key,{kind:"err",key:"team.errPickBot"});return}let m=(D.get(s.key)||"").trim()||t("team.defaultGroupName");$(s.key,{kind:"muted",key:"team.creatingGroup"});let f=s.kind==="local"?await pe(s.teamId,m,i):await ge(s.hubUrl,s.teamId,m,i);a.current&&($(s.key,{kind:"group-result",body:f.body,status:f.status}),f.body?.ok&&(x(h=>{let v=new Map(h);return v.delete(s.key),v}),M(h=>{let v=new Map(h);return v.delete(s.key),v}),s.kind==="local"&&A()))}async function ne(s){w({kind:"loading",key:s?"team.binding":"team.identifying"});let i=await ce(s);if(!a.current)return;let m=i.body;if(m?.ok&&m.owner){w({kind:"ok",name:m.owner.name||m.owner.unionId||""}),A();return}if(m?.ok&&m.needChoice&&Array.isArray(m.candidates)){w({kind:"choice",candidates:m.candidates});return}if(m?.error==="no_candidates"){w({kind:"err",key:"team.noCandidates"});return}w({kind:"bind-fail",error:String(m?.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:k}),(0,e.jsx)("button",{type:"button",id:"tf-autobind",className:"page-primary-action",onClick:()=>{ne()},children:t("team.bindBtn")}),(0,e.jsx)("span",{id:"tf-bind-out",className:"team-bind-status",hidden:U.kind==="hidden",children:(0,e.jsx)(Oe,{state:U,tr:t,onPick:s=>{ne(s)}})})]})})]}),(0,e.jsxs)("section",{className:"overview-block team-roster-section",children:[(0,e.jsx)(q,{title:t("team.myTeams"),count:ae?ae.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:s=>s.preventDefault(),children:[(0,e.jsx)("input",{id:"tf-search",type:"search",placeholder:t("team.searchPh"),value:u.query,onChange:s=>R(i=>({...i,query:s.target.value}))}),(0,e.jsx)(re,{id:"tf-cli",className:"team-cli-menu",ariaLabel:t("team.allCli"),value:u.cliId,label:se(ee,u.cliId),options:ee,onChange:s=>R(i=>({...i,cliId:s}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-fcap",checked:u.hasCapability,onChange:s=>R(i=>({...i,hasCapability:s.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:s=>R(i=>({...i,hasRole:s.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)(Ue,{teams:b,filters:u,pickedByTeam:B,gnameByTeam:D,expandedTeams:O,expandedDeps:P,groupOutputs:j,myDeploymentId:p,tr:t,onToggleTeam:s=>I(i=>Re(i,s)),onToggleDep:s=>H(i=>Re(i,s)),onPick:xe,onGroupNameChange:Me,onCapabilityChange:(s,i)=>{Pe(s,i)},onOpenRole:(s,i)=>{Be(s,i)},onRemoveMember:(s,i,m)=>{De(s,i,m)},onPullGroup:s=>{He(s)}})})]})]}),(0,e.jsx)(_e,{state:g,tr:t,onClose:()=>N(null)})]})}function Re(t,a){let n=new Set(t);return n.has(a)?n.delete(a):n.add(a),n}function Oe(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 Ue(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=>G(p,t.filters)),d=!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":!d,onClick:()=>t.onToggleTeam(n.key),children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:d?"\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})})]}),d?null:n.kind==="remote"&&!n.ok?(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:a("team.rosterFail")}):(0,e.jsx)(je,{...t,team:n,filtered:o})]},n.key)})}):(0,e.jsx)("p",{className:"muted",children:a("team.noTeams")})}function je(t){let{team:a,tr:n}=t,o=[...a.deployments].sort((r,p)=>r.local===p.local?0:r.local?-1:1),d=o.some(r=>t.filtered.some(p=>p.deployment.id===r.id));return(0,e.jsxs)(e.Fragment,{children:[o.map(r=>(0,Se.createElement)(Fe,{...t,deployment:r,key:r.id})),d?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 Fe(t){let{team:a,deployment:n,tr:o}=t,d=t.filtered.filter(u=>u.deployment.id===n.id);if(!d.length)return null;let r=n.id===t.myDeploymentId,p=r?o("team.tagLocal"):n.stale?o("team.tagRemoteStale"):o("team.tagRemote"),T=`${a.key}::${n.id}`,k=t.expandedDeps.has(T),y=d.filter(u=>X(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":T,"aria-expanded":k,role:"button",tabIndex:0,onClick:()=>t.onToggleDep(T),onKeyDown:u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),t.onToggleDep(T))},children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:k?"\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:d.length}),y?o("team.depSelected",{n:y}):""]}),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]}),k?(0,e.jsx)("div",{className:"team-roster-list",children:d.map(u=>(0,e.jsx)(Ee,{bot:u,mine:r,picked:X(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,d=()=>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=>{Ie(r.target)||d()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||Ie(r.target)||(r.preventDefault(),d())},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 Ie(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)($e,{body:a.body,status:a.status,tr:n}):null}function $e(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 d=a?.error||n,r=d==="no_local_online_bot"?o("team.errNoLocalBot"):d==="all_bots_skipped_no_owner"?o("team.errAllSkipped"):d==="no_creator_available"?o("team.errNoCreator"):d==="delegation_timeout"?o("team.errDelegationTimeout"):o("team.errGroupCreate",{error:String(d)});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 ze(){let t=F(),a=we(),[n,o]=(0,l.useState)([]),[d,r]=(0,l.useState)(""),[p,T]=(0,l.useState)(""),[k,y]=(0,l.useState)({kind:"none"}),[u,R]=(0,l.useState)(()=>new Map),[B,x]=(0,l.useState)(""),[D,M]=(0,l.useState)(""),[O,I]=(0,l.useState)({kind:"none"}),P=(0,l.useCallback)(async()=>{let c=await W();if(!a.current)return;let g=c.body;r(N=>g?.suggestedHubUrl||N),o(g?.teams||[])},[a]);(0,l.useEffect)(()=>{P()},[P]);async function H(){let c=p.trim();if(!c){y({kind:"err",key:"team.errName"});return}y({kind:"muted",key:"team.creating"});let g=await ye(c);a.current&&(g.body?.ok?(y({kind:"ok",key:"team.created"}),T(""),P()):y({kind:"create-fail",error:String(g.body?.error||g.status)}))}async function U(c){R(N=>{let b=new Map(N);return b.set(c,{kind:"muted",key:"team.generating"}),b});let g=await ke(c);a.current&&R(N=>{let b=new Map(N);return b.set(c,g.body?.code?{kind:"invite",code:g.body.code}:{kind:"err",key:"team.genFail"}),b})}async function w(c,g){confirm(t("team.delConfirm",{name:g}))&&(await be(c),a.current&&P())}async function j(){let c=B.trim(),g=D.trim();if(I({kind:"muted",key:"team.joining"}),!c||!g){I({kind:"err",key:"team.errHubCode"});return}let N=await he(c,g);a.current&&(N.body?.ok?(I({kind:"joined",name:String(N.body.teamName||"")}),M("")):I({kind:"join-fail",error:N.body?.error||N.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(),H()},children:[(0,e.jsx)("input",{id:"tm-newname",type:"text",placeholder:t("team.newTeamPh"),value:p,onChange:c=>T(c.target.value)}),(0,e.jsx)(ie,{id:"tm-create",className:"page-primary-action",onClick:()=>{H()},children:t("team.createTeamBtn")}),(0,e.jsx)("span",{className:"toolbar-status tm-cout",children:(0,e.jsx)(Y,{status:k,tr:t})})]}),(0,e.jsx)("div",{id:"tm-list",children:(0,e.jsx)(Ke,{teams:n,suggestedHubUrl:d,inviteStatuses:u,tr:t,onInvite:c=>{U(c)},onDelete:(c,g)=>{w(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:B,onChange:c=>x(c.target.value)}),(0,e.jsx)("input",{id:"tm-code",type:"text",placeholder:t("team.codePh"),value:D,onChange:c=>M(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)(Y,{status:O,tr:t})})]})]})}function Ke(t){let{teams:a,tr:n}=t;return a.length?(0,e.jsx)(e.Fragment,{children:a.map(o=>{let d=(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}),d?n("team.manageMetaRemote",{r:d}):""," \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)(Y,{status:r,tr:n,suggestedHubUrl:t.suggestedHubUrl})}),(0,e.jsx)(qe,{teamId:o.teamId,initial:o.feedback??null})]},o.teamId)})}):(0,e.jsx)("p",{className:"muted",children:n("team.noTeamsShort")})}function qe(t){let[a,n]=(0,l.useState)(JSON.stringify(t.initial??{enabled:!1},null,2)),[o,d]=(0,l.useState)(""),[r,p]=(0,l.useState)(!1);async function T(){p(!0),d("");try{let k=JSON.parse(a),y=await fe(t.teamId,k);if(y.status<200||y.status>=300||y.body.ok===!1)throw new Error(String(y.body?.error??y.status));n(JSON.stringify(y.body.feedback??null,null,2)),d("\u2713 \u5DF2\u4FDD\u5B58")}catch(k){d(`\u2717 ${k instanceof Error?k.message:String(k)}`)}finally{p(!1)}}return(0,e.jsxs)("div",{className:"team-feedback-editor",children:[(0,e.jsxs)("label",{children:[(0,e.jsx)("span",{children:"\u56E2\u961F\u53CD\u9988\u7B56\u7565"}),(0,e.jsx)("textarea",{rows:6,value:a,disabled:r,onChange:k=>n(k.target.value)})]}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",disabled:r,onClick:()=>{T()},children:"\u4FDD\u5B58\u53CD\u9988\u7B56\u7565"}),(0,e.jsx)("span",{children:o})]})]})}function Y(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,d=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:d})}function Ze(t){return K(t,(0,e.jsx)(Le,{}))}function et(t){return K(t,(0,e.jsx)(ze,{}))}export{Ze as renderTeamFederationPage,et as renderTeamManagePage};