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.
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/dist/.runtime-build-id +1 -1
- package/dist/adapters/backend/destroy-result.d.ts +159 -0
- package/dist/adapters/backend/destroy-result.d.ts.map +1 -0
- package/dist/adapters/backend/destroy-result.js +223 -0
- package/dist/adapters/backend/destroy-result.js.map +1 -0
- package/dist/adapters/backend/herdr-backend.d.ts +4 -0
- package/dist/adapters/backend/herdr-backend.d.ts.map +1 -1
- package/dist/adapters/backend/herdr-backend.js +23 -1
- package/dist/adapters/backend/herdr-backend.js.map +1 -1
- package/dist/adapters/backend/mojo-backend.d.ts +577 -0
- package/dist/adapters/backend/mojo-backend.d.ts.map +1 -0
- package/dist/adapters/backend/mojo-backend.js +2471 -0
- package/dist/adapters/backend/mojo-backend.js.map +1 -0
- package/dist/adapters/backend/mojo-budgets.d.ts +21 -0
- package/dist/adapters/backend/mojo-budgets.d.ts.map +1 -0
- package/dist/adapters/backend/mojo-budgets.js +22 -0
- package/dist/adapters/backend/mojo-budgets.js.map +1 -0
- package/dist/adapters/backend/mojo-isolated-workspace.d.ts +69 -0
- package/dist/adapters/backend/mojo-isolated-workspace.d.ts.map +1 -0
- package/dist/adapters/backend/mojo-isolated-workspace.js +213 -0
- package/dist/adapters/backend/mojo-isolated-workspace.js.map +1 -0
- package/dist/adapters/backend/mojo-process-tree.d.ts +292 -0
- package/dist/adapters/backend/mojo-process-tree.d.ts.map +1 -0
- package/dist/adapters/backend/mojo-process-tree.js +486 -0
- package/dist/adapters/backend/mojo-process-tree.js.map +1 -0
- package/dist/adapters/backend/mojo-types.d.ts +542 -0
- package/dist/adapters/backend/mojo-types.d.ts.map +1 -0
- package/dist/adapters/backend/mojo-types.js +682 -0
- package/dist/adapters/backend/mojo-types.js.map +1 -0
- package/dist/adapters/backend/reproduce-command.js +3 -3
- package/dist/adapters/backend/reproduce-command.js.map +1 -1
- package/dist/adapters/backend/riff-backend.js +1 -1
- package/dist/adapters/backend/riff-backend.js.map +1 -1
- package/dist/adapters/backend/sandbox.d.ts +44 -7
- package/dist/adapters/backend/sandbox.d.ts.map +1 -1
- package/dist/adapters/backend/sandbox.js +30 -7
- package/dist/adapters/backend/sandbox.js.map +1 -1
- package/dist/adapters/backend/session-backend-selector.d.ts +14 -1
- package/dist/adapters/backend/session-backend-selector.d.ts.map +1 -1
- package/dist/adapters/backend/session-backend-selector.js +82 -10
- package/dist/adapters/backend/session-backend-selector.js.map +1 -1
- package/dist/adapters/backend/tmux-pipe-backend.d.ts +30 -0
- package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -1
- package/dist/adapters/backend/tmux-pipe-backend.js +60 -0
- package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -1
- package/dist/adapters/backend/types.d.ts +108 -6
- package/dist/adapters/backend/types.d.ts.map +1 -1
- package/dist/adapters/backend/types.js.map +1 -1
- package/dist/adapters/backend/zmx-backend.d.ts +11 -0
- package/dist/adapters/backend/zmx-backend.d.ts.map +1 -1
- package/dist/adapters/backend/zmx-backend.js +16 -1
- package/dist/adapters/backend/zmx-backend.js.map +1 -1
- package/dist/adapters/cli/codex-app.d.ts.map +1 -1
- package/dist/adapters/cli/codex-app.js +2 -2
- package/dist/adapters/cli/codex-app.js.map +1 -1
- package/dist/adapters/cli/codex.d.ts.map +1 -1
- package/dist/adapters/cli/codex.js +7 -0
- package/dist/adapters/cli/codex.js.map +1 -1
- package/dist/adapters/cli/copilot.d.ts +3 -1
- package/dist/adapters/cli/copilot.d.ts.map +1 -1
- package/dist/adapters/cli/copilot.js +23 -5
- package/dist/adapters/cli/copilot.js.map +1 -1
- package/dist/adapters/cli/cursor.d.ts.map +1 -1
- package/dist/adapters/cli/cursor.js +26 -4
- package/dist/adapters/cli/cursor.js.map +1 -1
- package/dist/adapters/cli/dsh.d.ts.map +1 -1
- package/dist/adapters/cli/dsh.js +5 -1
- package/dist/adapters/cli/dsh.js.map +1 -1
- package/dist/adapters/cli/grok.d.ts.map +1 -1
- package/dist/adapters/cli/grok.js +24 -5
- package/dist/adapters/cli/grok.js.map +1 -1
- package/dist/adapters/cli/kimi.d.ts.map +1 -1
- package/dist/adapters/cli/kimi.js +19 -1
- package/dist/adapters/cli/kimi.js.map +1 -1
- package/dist/adapters/cli/mojo.d.ts +28 -0
- package/dist/adapters/cli/mojo.d.ts.map +1 -0
- package/dist/adapters/cli/mojo.js +58 -0
- package/dist/adapters/cli/mojo.js.map +1 -0
- package/dist/adapters/cli/pi.d.ts +20 -5
- package/dist/adapters/cli/pi.d.ts.map +1 -1
- package/dist/adapters/cli/pi.js +27 -5
- package/dist/adapters/cli/pi.js.map +1 -1
- package/dist/adapters/cli/read-isolation.d.ts +251 -1
- package/dist/adapters/cli/read-isolation.d.ts.map +1 -1
- package/dist/adapters/cli/read-isolation.js +254 -1
- package/dist/adapters/cli/read-isolation.js.map +1 -1
- package/dist/adapters/cli/registry.d.ts +13 -1
- package/dist/adapters/cli/registry.d.ts.map +1 -1
- package/dist/adapters/cli/registry.js +19 -1
- package/dist/adapters/cli/registry.js.map +1 -1
- package/dist/adapters/cli/runner-input.d.ts +3 -3
- package/dist/adapters/cli/runner-input.d.ts.map +1 -1
- package/dist/adapters/cli/runner-input.js +4 -3
- package/dist/adapters/cli/runner-input.js.map +1 -1
- package/dist/adapters/cli/shared-hints.d.ts +3 -1
- package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
- package/dist/adapters/cli/shared-hints.js +51 -30
- package/dist/adapters/cli/shared-hints.js.map +1 -1
- package/dist/adapters/cli/types.d.ts +33 -4
- package/dist/adapters/cli/types.d.ts.map +1 -1
- package/dist/bot-registry.d.ts +42 -0
- package/dist/bot-registry.d.ts.map +1 -1
- package/dist/bot-registry.js +54 -4
- package/dist/bot-registry.js.map +1 -1
- package/dist/cli/arg-utils.d.ts +5 -0
- package/dist/cli/arg-utils.d.ts.map +1 -1
- package/dist/cli/arg-utils.js +7 -0
- package/dist/cli/arg-utils.js.map +1 -1
- package/dist/cli/bots-list-output.d.ts +130 -2
- package/dist/cli/bots-list-output.d.ts.map +1 -1
- package/dist/cli/bots-list-output.js +173 -27
- package/dist/cli/bots-list-output.js.map +1 -1
- package/dist/cli/daemon-lifecycle-env.d.ts +10 -3
- package/dist/cli/daemon-lifecycle-env.d.ts.map +1 -1
- package/dist/cli/daemon-lifecycle-env.js +38 -11
- package/dist/cli/daemon-lifecycle-env.js.map +1 -1
- package/dist/cli/dashboard-command.d.ts +15 -0
- package/dist/cli/dashboard-command.d.ts.map +1 -1
- package/dist/cli/dashboard-command.js +22 -0
- package/dist/cli/dashboard-command.js.map +1 -1
- package/dist/cli/log-tail.d.ts +54 -0
- package/dist/cli/log-tail.d.ts.map +1 -0
- package/dist/cli/log-tail.js +167 -0
- package/dist/cli/log-tail.js.map +1 -0
- package/dist/cli/pm2-env.d.ts +16 -0
- package/dist/cli/pm2-env.d.ts.map +1 -0
- package/dist/cli/pm2-env.js +63 -0
- package/dist/cli/pm2-env.js.map +1 -0
- package/dist/cli/pm2-fleet-lock.d.ts +26 -0
- package/dist/cli/pm2-fleet-lock.d.ts.map +1 -0
- package/dist/cli/pm2-fleet-lock.js +50 -0
- package/dist/cli/pm2-fleet-lock.js.map +1 -0
- package/dist/cli/pm2-god-retirement.d.ts +59 -0
- package/dist/cli/pm2-god-retirement.d.ts.map +1 -0
- package/dist/cli/pm2-god-retirement.js +95 -0
- package/dist/cli/pm2-god-retirement.js.map +1 -0
- package/dist/cli/session-list-wake.d.ts +41 -0
- package/dist/cli/session-list-wake.d.ts.map +1 -0
- package/dist/cli/session-list-wake.js +102 -0
- package/dist/cli/session-list-wake.js.map +1 -0
- package/dist/cli/workflow.d.ts.map +1 -1
- package/dist/cli/workflow.js +26 -0
- package/dist/cli/workflow.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +941 -118
- package/dist/cli.js.map +1 -1
- package/dist/codex-app-runner.js +261 -49
- package/dist/codex-app-runner.js.map +1 -1
- package/dist/core/cli-runtime-update.d.ts +8 -0
- package/dist/core/cli-runtime-update.d.ts.map +1 -1
- package/dist/core/cli-runtime-update.js +127 -8
- package/dist/core/cli-runtime-update.js.map +1 -1
- package/dist/core/close-residual.d.ts +64 -0
- package/dist/core/close-residual.d.ts.map +1 -0
- package/dist/core/close-residual.js +93 -0
- package/dist/core/close-residual.js.map +1 -0
- package/dist/core/closed-session-card.d.ts.map +1 -1
- package/dist/core/closed-session-card.js +11 -3
- package/dist/core/closed-session-card.js.map +1 -1
- package/dist/core/command-discovery.d.ts.map +1 -1
- package/dist/core/command-discovery.js +4 -1
- package/dist/core/command-discovery.js.map +1 -1
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +129 -27
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/cost-calculator.d.ts +3 -1
- package/dist/core/cost-calculator.d.ts.map +1 -1
- package/dist/core/cost-calculator.js +230 -1
- package/dist/core/cost-calculator.js.map +1 -1
- package/dist/core/daemon-background-close.d.ts +19 -0
- package/dist/core/daemon-background-close.d.ts.map +1 -0
- package/dist/core/daemon-background-close.js +39 -0
- package/dist/core/daemon-background-close.js.map +1 -0
- package/dist/core/dashboard-command/overview.d.ts +4 -0
- package/dist/core/dashboard-command/overview.d.ts.map +1 -1
- package/dist/core/dashboard-command/overview.js +8 -1
- package/dist/core/dashboard-command/overview.js.map +1 -1
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
- package/dist/core/dashboard-ipc-server.js +415 -42
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/core/dashboard-rows.d.ts +4 -0
- package/dist/core/dashboard-rows.d.ts.map +1 -1
- package/dist/core/dashboard-rows.js +3 -0
- package/dist/core/dashboard-rows.js.map +1 -1
- package/dist/core/dashboard-url.d.ts +37 -0
- package/dist/core/dashboard-url.d.ts.map +1 -1
- package/dist/core/dashboard-url.js +71 -0
- package/dist/core/dashboard-url.js.map +1 -1
- package/dist/core/deferred-schedule-settlement.d.ts +15 -1
- package/dist/core/deferred-schedule-settlement.d.ts.map +1 -1
- package/dist/core/deferred-schedule-settlement.js +4 -1
- package/dist/core/deferred-schedule-settlement.js.map +1 -1
- package/dist/core/device-isolation-daemon.d.ts +91 -1
- package/dist/core/device-isolation-daemon.d.ts.map +1 -1
- package/dist/core/device-isolation-daemon.js +346 -2
- package/dist/core/device-isolation-daemon.js.map +1 -1
- package/dist/core/local-terminal-opener.d.ts.map +1 -1
- package/dist/core/local-terminal-opener.js +5 -1
- package/dist/core/local-terminal-opener.js.map +1 -1
- package/dist/core/loopback-target.d.ts +14 -0
- package/dist/core/loopback-target.d.ts.map +1 -0
- package/dist/core/loopback-target.js +20 -0
- package/dist/core/loopback-target.js.map +1 -0
- package/dist/core/maintenance.d.ts.map +1 -1
- package/dist/core/maintenance.js +16 -2
- package/dist/core/maintenance.js.map +1 -1
- package/dist/core/mojo-containment-command.d.ts +20 -0
- package/dist/core/mojo-containment-command.d.ts.map +1 -0
- package/dist/core/mojo-containment-command.js +266 -0
- package/dist/core/mojo-containment-command.js.map +1 -0
- package/dist/core/mojo-containment.d.ts +575 -0
- package/dist/core/mojo-containment.d.ts.map +1 -0
- package/dist/core/mojo-containment.js +1158 -0
- package/dist/core/mojo-containment.js.map +1 -0
- package/dist/core/mojo-launcher-env-quarantine.d.ts +30 -0
- package/dist/core/mojo-launcher-env-quarantine.d.ts.map +1 -0
- package/dist/core/mojo-launcher-env-quarantine.js +175 -0
- package/dist/core/mojo-launcher-env-quarantine.js.map +1 -0
- package/dist/core/mojo-session-identity.d.ts +3 -0
- package/dist/core/mojo-session-identity.d.ts.map +1 -0
- package/dist/core/mojo-session-identity.js +126 -0
- package/dist/core/mojo-session-identity.js.map +1 -0
- package/dist/core/persistent-backend.d.ts +32 -8
- package/dist/core/persistent-backend.d.ts.map +1 -1
- package/dist/core/persistent-backend.js +55 -17
- package/dist/core/persistent-backend.js.map +1 -1
- package/dist/core/plugins/mcp/gateway.d.ts +14 -1
- package/dist/core/plugins/mcp/gateway.d.ts.map +1 -1
- package/dist/core/plugins/mcp/gateway.js +70 -3
- package/dist/core/plugins/mcp/gateway.js.map +1 -1
- package/dist/core/plugins/mcp/host.d.ts +2 -0
- package/dist/core/plugins/mcp/host.d.ts.map +1 -1
- package/dist/core/plugins/mcp/host.js +2 -0
- package/dist/core/plugins/mcp/host.js.map +1 -1
- package/dist/core/plugins/pm2.d.ts.map +1 -1
- package/dist/core/plugins/pm2.js +16 -3
- package/dist/core/plugins/pm2.js.map +1 -1
- package/dist/core/plugins/service-manager.d.ts +9 -0
- package/dist/core/plugins/service-manager.d.ts.map +1 -1
- package/dist/core/plugins/service-manager.js +33 -16
- package/dist/core/plugins/service-manager.js.map +1 -1
- package/dist/core/preview-port-owner.d.ts +109 -0
- package/dist/core/preview-port-owner.d.ts.map +1 -0
- package/dist/core/preview-port-owner.js +320 -0
- package/dist/core/preview-port-owner.js.map +1 -0
- package/dist/core/remote-cli-ids.d.ts +5 -0
- package/dist/core/remote-cli-ids.d.ts.map +1 -0
- package/dist/core/remote-cli-ids.js +24 -0
- package/dist/core/remote-cli-ids.js.map +1 -0
- package/dist/core/{riff-shutdown-detach.d.ts → remote-shutdown-detach.d.ts} +40 -39
- package/dist/core/remote-shutdown-detach.d.ts.map +1 -0
- package/dist/core/{riff-shutdown-detach.js → remote-shutdown-detach.js} +85 -83
- package/dist/core/remote-shutdown-detach.js.map +1 -0
- package/dist/core/{riff-worker-shutdown-readiness.d.ts → remote-worker-shutdown-readiness.d.ts} +5 -4
- package/dist/core/remote-worker-shutdown-readiness.d.ts.map +1 -0
- package/dist/core/{riff-worker-shutdown-readiness.js → remote-worker-shutdown-readiness.js} +4 -3
- package/dist/core/remote-worker-shutdown-readiness.js.map +1 -0
- package/dist/core/reply-target.d.ts +16 -1
- package/dist/core/reply-target.d.ts.map +1 -1
- package/dist/core/reply-target.js +61 -0
- package/dist/core/reply-target.js.map +1 -1
- package/dist/core/session-group-birth.d.ts +26 -0
- package/dist/core/session-group-birth.d.ts.map +1 -1
- package/dist/core/session-group-birth.js +81 -4
- package/dist/core/session-group-birth.js.map +1 -1
- package/dist/core/session-manager.d.ts +15 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +259 -5
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-model.d.ts +46 -0
- package/dist/core/session-model.d.ts.map +1 -0
- package/dist/core/session-model.js +42 -0
- package/dist/core/session-model.js.map +1 -0
- package/dist/core/session-owner-reminder.d.ts +63 -0
- package/dist/core/session-owner-reminder.d.ts.map +1 -0
- package/dist/core/session-owner-reminder.js +196 -0
- package/dist/core/session-owner-reminder.js.map +1 -0
- package/dist/core/session-preview-registry.d.ts +53 -0
- package/dist/core/session-preview-registry.d.ts.map +1 -0
- package/dist/core/session-preview-registry.js +82 -0
- package/dist/core/session-preview-registry.js.map +1 -0
- package/dist/core/session-preview.d.ts +114 -0
- package/dist/core/session-preview.d.ts.map +1 -0
- package/dist/core/session-preview.js +184 -0
- package/dist/core/session-preview.js.map +1 -0
- package/dist/core/session-rename.d.ts.map +1 -1
- package/dist/core/session-rename.js +5 -3
- package/dist/core/session-rename.js.map +1 -1
- package/dist/core/session-wake-deadline.d.ts +5 -0
- package/dist/core/session-wake-deadline.d.ts.map +1 -0
- package/dist/core/session-wake-deadline.js +13 -0
- package/dist/core/session-wake-deadline.js.map +1 -0
- package/dist/core/shutdown-budgets.d.ts +7 -6
- package/dist/core/shutdown-budgets.d.ts.map +1 -1
- package/dist/core/shutdown-budgets.js +11 -10
- package/dist/core/shutdown-budgets.js.map +1 -1
- package/dist/core/skills/frontmatter.d.ts.map +1 -1
- package/dist/core/skills/frontmatter.js +6 -1
- package/dist/core/skills/frontmatter.js.map +1 -1
- package/dist/core/terminal-control-grant.d.ts +74 -0
- package/dist/core/terminal-control-grant.d.ts.map +1 -0
- package/dist/core/terminal-control-grant.js +183 -0
- package/dist/core/terminal-control-grant.js.map +1 -0
- package/dist/core/terminal-proxy.d.ts.map +1 -1
- package/dist/core/terminal-proxy.js +4 -5
- package/dist/core/terminal-proxy.js.map +1 -1
- package/dist/core/terminal-write-auth.d.ts +4 -11
- package/dist/core/terminal-write-auth.d.ts.map +1 -1
- package/dist/core/terminal-write-auth.js +19 -16
- package/dist/core/terminal-write-auth.js.map +1 -1
- package/dist/core/trigger-session.d.ts.map +1 -1
- package/dist/core/trigger-session.js +36 -29
- package/dist/core/trigger-session.js.map +1 -1
- package/dist/core/types.d.ts +88 -10
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +9 -7
- package/dist/core/types.js.map +1 -1
- package/dist/core/workbench-link.d.ts +81 -0
- package/dist/core/workbench-link.d.ts.map +1 -0
- package/dist/core/workbench-link.js +109 -0
- package/dist/core/workbench-link.js.map +1 -0
- package/dist/core/worker-pool.d.ts +312 -11
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +2515 -217
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts +6 -0
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +447 -116
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/aggregator.d.ts +33 -3
- package/dist/dashboard/aggregator.d.ts.map +1 -1
- package/dist/dashboard/aggregator.js +93 -17
- package/dist/dashboard/aggregator.js.map +1 -1
- package/dist/dashboard/auth-session-connections.d.ts +59 -0
- package/dist/dashboard/auth-session-connections.d.ts.map +1 -0
- package/dist/dashboard/auth-session-connections.js +109 -0
- package/dist/dashboard/auth-session-connections.js.map +1 -0
- package/dist/dashboard/auth.d.ts +99 -1
- package/dist/dashboard/auth.d.ts.map +1 -1
- package/dist/dashboard/auth.js +176 -64
- package/dist/dashboard/auth.js.map +1 -1
- package/dist/dashboard/bot-payload.d.ts +5 -0
- package/dist/dashboard/bot-payload.d.ts.map +1 -1
- package/dist/dashboard/bot-payload.js +4 -0
- package/dist/dashboard/bot-payload.js.map +1 -1
- package/dist/dashboard/control-audit.d.ts +112 -0
- package/dist/dashboard/control-audit.d.ts.map +1 -0
- package/dist/dashboard/control-audit.js +195 -0
- package/dist/dashboard/control-audit.js.map +1 -0
- package/dist/dashboard/control-csrf.d.ts +123 -0
- package/dist/dashboard/control-csrf.d.ts.map +1 -0
- package/dist/dashboard/control-csrf.js +392 -0
- package/dist/dashboard/control-csrf.js.map +1 -0
- package/dist/dashboard/daemon-reconcile.d.ts +26 -0
- package/dist/dashboard/daemon-reconcile.d.ts.map +1 -0
- package/dist/dashboard/daemon-reconcile.js +46 -0
- package/dist/dashboard/daemon-reconcile.js.map +1 -0
- package/dist/dashboard/debug-terminal.d.ts.map +1 -1
- package/dist/dashboard/debug-terminal.js +18 -4
- package/dist/dashboard/debug-terminal.js.map +1 -1
- package/dist/dashboard/events-sse.d.ts +60 -0
- package/dist/dashboard/events-sse.d.ts.map +1 -0
- package/dist/dashboard/events-sse.js +63 -0
- package/dist/dashboard/events-sse.js.map +1 -0
- package/dist/dashboard/h5-auth.d.ts +256 -0
- package/dist/dashboard/h5-auth.d.ts.map +1 -0
- package/dist/dashboard/h5-auth.js +825 -0
- package/dist/dashboard/h5-auth.js.map +1 -0
- package/dist/dashboard/managed-spawn.d.ts +36 -0
- package/dist/dashboard/managed-spawn.d.ts.map +1 -0
- package/dist/dashboard/managed-spawn.js +169 -0
- package/dist/dashboard/managed-spawn.js.map +1 -0
- package/dist/dashboard/preview-content-capability.d.ts +41 -0
- package/dist/dashboard/preview-content-capability.d.ts.map +1 -0
- package/dist/dashboard/preview-content-capability.js +127 -0
- package/dist/dashboard/preview-content-capability.js.map +1 -0
- package/dist/dashboard/preview-contract.d.ts +85 -0
- package/dist/dashboard/preview-contract.d.ts.map +1 -0
- package/dist/dashboard/preview-contract.js +198 -0
- package/dist/dashboard/preview-contract.js.map +1 -0
- package/dist/dashboard/preview-guard-page.d.ts +52 -0
- package/dist/dashboard/preview-guard-page.d.ts.map +1 -0
- package/dist/dashboard/preview-guard-page.js +162 -0
- package/dist/dashboard/preview-guard-page.js.map +1 -0
- package/dist/dashboard/preview-interaction.d.ts +57 -0
- package/dist/dashboard/preview-interaction.d.ts.map +1 -0
- package/dist/dashboard/preview-interaction.js +198 -0
- package/dist/dashboard/preview-interaction.js.map +1 -0
- package/dist/dashboard/preview-proxy.d.ts +113 -0
- package/dist/dashboard/preview-proxy.d.ts.map +1 -0
- package/dist/dashboard/preview-proxy.js +543 -0
- package/dist/dashboard/preview-proxy.js.map +1 -0
- package/dist/dashboard/public-redact.d.ts +23 -0
- package/dist/dashboard/public-redact.d.ts.map +1 -1
- package/dist/dashboard/public-redact.js +90 -21
- package/dist/dashboard/public-redact.js.map +1 -1
- package/dist/dashboard/request-identity.d.ts +77 -0
- package/dist/dashboard/request-identity.d.ts.map +1 -0
- package/dist/dashboard/request-identity.js +72 -0
- package/dist/dashboard/request-identity.js.map +1 -0
- package/dist/dashboard/session-cleanup.d.ts +5 -0
- package/dist/dashboard/session-cleanup.d.ts.map +1 -1
- package/dist/dashboard/session-cleanup.js +4 -0
- package/dist/dashboard/session-cleanup.js.map +1 -1
- package/dist/dashboard/settings-write-applier.d.ts +5 -1
- package/dist/dashboard/settings-write-applier.d.ts.map +1 -1
- package/dist/dashboard/settings-write-applier.js +14 -0
- package/dist/dashboard/settings-write-applier.js.map +1 -1
- package/dist/dashboard/standing-link.d.ts +76 -0
- package/dist/dashboard/standing-link.d.ts.map +1 -0
- package/dist/dashboard/standing-link.js +111 -0
- package/dist/dashboard/standing-link.js.map +1 -0
- package/dist/dashboard/terminal-control.d.ts +105 -0
- package/dist/dashboard/terminal-control.d.ts.map +1 -0
- package/dist/dashboard/terminal-control.js +296 -0
- package/dist/dashboard/terminal-control.js.map +1 -0
- package/dist/dashboard/terminal-front-proxy.d.ts +55 -0
- package/dist/dashboard/terminal-front-proxy.d.ts.map +1 -0
- package/dist/dashboard/terminal-front-proxy.js +397 -0
- package/dist/dashboard/terminal-front-proxy.js.map +1 -0
- package/dist/dashboard/terminal-view-capability.d.ts +97 -0
- package/dist/dashboard/terminal-view-capability.d.ts.map +1 -0
- package/dist/dashboard/terminal-view-capability.js +145 -0
- package/dist/dashboard/terminal-view-capability.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-api.d.ts +59 -0
- package/dist/dashboard/web/agent-workbench-api.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-api.js +227 -0
- package/dist/dashboard/web/agent-workbench-api.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-appearance-menu.d.ts +59 -0
- package/dist/dashboard/web/agent-workbench-appearance-menu.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-appearance-menu.js +195 -0
- package/dist/dashboard/web/agent-workbench-appearance-menu.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-appearance.d.ts +222 -0
- package/dist/dashboard/web/agent-workbench-appearance.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-appearance.js +499 -0
- package/dist/dashboard/web/agent-workbench-appearance.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-capabilities.d.ts +13 -0
- package/dist/dashboard/web/agent-workbench-capabilities.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-capabilities.js +24 -0
- package/dist/dashboard/web/agent-workbench-capabilities.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-chat.d.ts +90 -0
- package/dist/dashboard/web/agent-workbench-chat.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-chat.js +168 -0
- package/dist/dashboard/web/agent-workbench-chat.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-dock-page.d.ts +3 -0
- package/dist/dashboard/web/agent-workbench-dock-page.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-dock-page.js +23 -0
- package/dist/dashboard/web/agent-workbench-dock-page.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-dock-view.d.ts +22 -0
- package/dist/dashboard/web/agent-workbench-dock-view.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-dock-view.js +76 -0
- package/dist/dashboard/web/agent-workbench-dock-view.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-model.d.ts +196 -0
- package/dist/dashboard/web/agent-workbench-model.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-model.js +529 -0
- package/dist/dashboard/web/agent-workbench-model.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-page.d.ts +3 -0
- package/dist/dashboard/web/agent-workbench-page.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-page.js +27 -0
- package/dist/dashboard/web/agent-workbench-page.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-panes.d.ts +49 -0
- package/dist/dashboard/web/agent-workbench-panes.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-panes.js +468 -0
- package/dist/dashboard/web/agent-workbench-panes.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-session-list.d.ts +42 -0
- package/dist/dashboard/web/agent-workbench-session-list.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-session-list.js +353 -0
- package/dist/dashboard/web/agent-workbench-session-list.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-storage.d.ts +49 -0
- package/dist/dashboard/web/agent-workbench-storage.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-storage.js +197 -0
- package/dist/dashboard/web/agent-workbench-storage.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-touch.d.ts +46 -0
- package/dist/dashboard/web/agent-workbench-touch.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-touch.js +96 -0
- package/dist/dashboard/web/agent-workbench-touch.js.map +1 -0
- package/dist/dashboard/web/agent-workbench-view.d.ts +34 -0
- package/dist/dashboard/web/agent-workbench-view.d.ts.map +1 -0
- package/dist/dashboard/web/agent-workbench-view.js +439 -0
- package/dist/dashboard/web/agent-workbench-view.js.map +1 -0
- package/dist/dashboard/web/app.d.ts.map +1 -1
- package/dist/dashboard/web/app.js +63 -2
- package/dist/dashboard/web/app.js.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.d.ts +18 -0
- package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.js +362 -36
- package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
- package/dist/dashboard/web/bot-defaults.d.ts +8 -0
- package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults.js.map +1 -1
- package/dist/dashboard/web/control-csrf.d.ts +4 -0
- package/dist/dashboard/web/control-csrf.d.ts.map +1 -0
- package/dist/dashboard/web/control-csrf.js +26 -0
- package/dist/dashboard/web/control-csrf.js.map +1 -0
- package/dist/dashboard/web/dashboard-routes.d.ts.map +1 -1
- package/dist/dashboard/web/dashboard-routes.js +2 -0
- package/dist/dashboard/web/dashboard-routes.js.map +1 -1
- package/dist/dashboard/web/groups-page.d.ts.map +1 -1
- package/dist/dashboard/web/groups-page.js +11 -2
- package/dist/dashboard/web/groups-page.js.map +1 -1
- package/dist/dashboard/web/i18n.d.ts.map +1 -1
- package/dist/dashboard/web/i18n.js +140 -6
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/overview-page.d.ts.map +1 -1
- package/dist/dashboard/web/overview-page.js +3 -2
- package/dist/dashboard/web/overview-page.js.map +1 -1
- package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
- package/dist/dashboard/web/sessions-page.js +41 -1
- package/dist/dashboard/web/sessions-page.js.map +1 -1
- package/dist/dashboard/web/sessions.d.ts.map +1 -1
- package/dist/dashboard/web/sessions.js +5 -1
- package/dist/dashboard/web/sessions.js.map +1 -1
- package/dist/dashboard/web/settings-page.d.ts +3 -0
- package/dist/dashboard/web/settings-page.d.ts.map +1 -1
- package/dist/dashboard/web/settings-page.js +56 -10
- package/dist/dashboard/web/settings-page.js.map +1 -1
- package/dist/dashboard/web/skills-page.d.ts.map +1 -1
- package/dist/dashboard/web/skills-page.js +4 -2
- package/dist/dashboard/web/skills-page.js.map +1 -1
- package/dist/dashboard/web/store.d.ts +27 -2
- package/dist/dashboard/web/store.d.ts.map +1 -1
- package/dist/dashboard/web/store.js +43 -4
- package/dist/dashboard/web/store.js.map +1 -1
- package/dist/dashboard/web/ui.d.ts +3 -0
- package/dist/dashboard/web/ui.d.ts.map +1 -1
- package/dist/dashboard/web/ui.js +11 -0
- package/dist/dashboard/web/ui.js.map +1 -1
- package/dist/dashboard/web/update-action.d.ts +12 -0
- package/dist/dashboard/web/update-action.d.ts.map +1 -1
- package/dist/dashboard/web/update-action.js +11 -0
- package/dist/dashboard/web/update-action.js.map +1 -1
- package/dist/dashboard/workbench-doctor.d.ts +114 -0
- package/dist/dashboard/workbench-doctor.d.ts.map +1 -0
- package/dist/dashboard/workbench-doctor.js +620 -0
- package/dist/dashboard/workbench-doctor.js.map +1 -0
- package/dist/dashboard/workbench-ticket.d.ts +165 -0
- package/dist/dashboard/workbench-ticket.d.ts.map +1 -0
- package/dist/dashboard/workbench-ticket.js +495 -0
- package/dist/dashboard/workbench-ticket.js.map +1 -0
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/agent-workbench-dock-page-IKAC5CFL.js +1 -0
- package/dist/dashboard-web/chunks/agent-workbench-page-M53UN5EB.js +1 -0
- package/dist/dashboard-web/chunks/bot-defaults-page-YKE5SDZF.js +10 -0
- package/dist/dashboard-web/chunks/chunk-22WIADUT.js +2 -0
- package/dist/dashboard-web/chunks/chunk-24ONYQMR.js +1 -0
- package/dist/dashboard-web/chunks/{chunk-6O7KXFD2.js → chunk-2W6SCN3M.js} +1 -1
- package/dist/dashboard-web/chunks/chunk-4XNJX6B3.js +1 -0
- package/dist/dashboard-web/chunks/{chunk-Q2MT4VWH.js → chunk-F6KNPF4R.js} +11 -9
- package/dist/dashboard-web/chunks/chunk-FXW3V4JR.js +1 -0
- package/dist/dashboard-web/chunks/chunk-G5ZS2YUS.js +1 -0
- package/dist/dashboard-web/chunks/chunk-KTQ7B6ZR.js +1 -0
- package/dist/dashboard-web/chunks/{chunk-U3ZFSO7E.js → chunk-NACP7BMR.js} +1 -1
- package/dist/dashboard-web/chunks/{connectors-page-2KZO5KSJ.js → connectors-page-VOISXXII.js} +1 -1
- package/dist/dashboard-web/chunks/{feedback-page-CLVTOLLO.js → feedback-page-RN6HRZMS.js} +1 -1
- package/dist/dashboard-web/chunks/groups-page-UQT6DCB7.js +8 -0
- package/dist/dashboard-web/chunks/{insights-page-4RPU2CRU.js → insights-page-HJFDYR5N.js} +3 -3
- package/dist/dashboard-web/chunks/{monitor-room-OTKQ2CXK.js → monitor-room-V7PCP47V.js} +1 -1
- package/dist/dashboard-web/chunks/{monitoring-page-IJPUB6JT.js → monitoring-page-NKEKVQAP.js} +1 -1
- package/dist/dashboard-web/chunks/{office-page-QSR3J44Y.js → office-page-GVJF73XW.js} +1 -1
- package/dist/dashboard-web/chunks/overview-page-KHLV6VTI.js +1 -0
- package/dist/dashboard-web/chunks/{plugin-page-VEGTCEAS.js → plugin-page-J3OF5IY4.js} +1 -1
- package/dist/dashboard-web/chunks/{roles-page-6NWJMOB5.js → roles-page-WQIRSOLZ.js} +1 -1
- package/dist/dashboard-web/chunks/{schedules-page-6I3LNXD4.js → schedules-page-J2DEY2X6.js} +1 -1
- package/dist/dashboard-web/chunks/sessions-page-7BQFEA5P.js +8 -0
- package/dist/dashboard-web/chunks/settings-page-BJEIOFJH.js +2 -0
- package/dist/dashboard-web/chunks/{skills-page-M2Q6L5CB.js → skills-page-HGIFR3IU.js} +2 -2
- package/dist/dashboard-web/chunks/{team-federation-page-7I7FDE3B.js → team-federation-page-MR5ZPL4B.js} +1 -1
- package/dist/dashboard-web/chunks/{v3-page-HQXRL65L.js → v3-page-GBR5JWPE.js} +2 -2
- package/dist/dashboard-web/chunks/{whiteboards-page-LQKC4TAZ.js → whiteboards-page-QAZM4BN3.js} +1 -1
- package/dist/dashboard-web/index.html +8 -1
- package/dist/dashboard-web/style.css +2006 -10
- package/dist/dashboard.js +1017 -264
- package/dist/dashboard.js.map +1 -1
- package/dist/dsh-runner.js +8 -1
- package/dist/dsh-runner.js.map +1 -1
- package/dist/global-config.d.ts +30 -0
- package/dist/global-config.d.ts.map +1 -1
- package/dist/global-config.js +33 -0
- package/dist/global-config.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +46 -27
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +43 -27
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/card-builder.d.ts +1 -1
- package/dist/im/lark/card-builder.d.ts.map +1 -1
- package/dist/im/lark/card-builder.js +22 -6
- package/dist/im/lark/card-builder.js.map +1 -1
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +118 -24
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/client.d.ts +15 -0
- package/dist/im/lark/client.d.ts.map +1 -1
- package/dist/im/lark/client.js +30 -0
- package/dist/im/lark/client.js.map +1 -1
- package/dist/im/lark/event-dispatcher.d.ts +48 -0
- package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
- package/dist/im/lark/event-dispatcher.js +138 -41
- package/dist/im/lark/event-dispatcher.js.map +1 -1
- package/dist/im/lark/identity-cache.d.ts +14 -6
- package/dist/im/lark/identity-cache.d.ts.map +1 -1
- package/dist/im/lark/identity-cache.js +69 -26
- package/dist/im/lark/identity-cache.js.map +1 -1
- package/dist/im/lark/lark-hosts.d.ts +13 -0
- package/dist/im/lark/lark-hosts.d.ts.map +1 -1
- package/dist/im/lark/lark-hosts.js +16 -0
- package/dist/im/lark/lark-hosts.js.map +1 -1
- package/dist/im/lark/overview-card.d.ts +22 -0
- package/dist/im/lark/overview-card.d.ts.map +1 -1
- package/dist/im/lark/overview-card.js +53 -3
- package/dist/im/lark/overview-card.js.map +1 -1
- package/dist/im/lark/sessions-card.d.ts.map +1 -1
- package/dist/im/lark/sessions-card.js +26 -3
- package/dist/im/lark/sessions-card.js.map +1 -1
- package/dist/im/lark/workflow-slash-command.d.ts +6 -0
- package/dist/im/lark/workflow-slash-command.d.ts.map +1 -1
- package/dist/im/lark/workflow-slash-command.js +7 -0
- package/dist/im/lark/workflow-slash-command.js.map +1 -1
- package/dist/index-daemon.js +27 -4
- package/dist/index-daemon.js.map +1 -1
- package/dist/index-dashboard.d.ts +3 -0
- package/dist/index-dashboard.d.ts.map +1 -0
- package/dist/index-dashboard.js +94 -0
- package/dist/index-dashboard.js.map +1 -0
- package/dist/platform/team-agents-client.d.ts +199 -0
- package/dist/platform/team-agents-client.d.ts.map +1 -0
- package/dist/platform/team-agents-client.js +263 -0
- package/dist/platform/team-agents-client.js.map +1 -0
- package/dist/platform/tunnel-client.d.ts +6 -0
- package/dist/platform/tunnel-client.d.ts.map +1 -1
- package/dist/platform/tunnel-client.js.map +1 -1
- package/dist/services/async-trigger-state.d.ts +7 -3
- package/dist/services/async-trigger-state.d.ts.map +1 -1
- package/dist/services/async-trigger-state.js +28 -0
- package/dist/services/async-trigger-state.js.map +1 -1
- package/dist/services/async-trigger-store.d.ts +13 -4
- package/dist/services/async-trigger-store.d.ts.map +1 -1
- package/dist/services/async-trigger-store.js +55 -8
- package/dist/services/async-trigger-store.js.map +1 -1
- package/dist/services/bot-config-store.d.ts +1 -11
- package/dist/services/bot-config-store.d.ts.map +1 -1
- package/dist/services/bot-config-store.js +27 -3
- package/dist/services/bot-config-store.js.map +1 -1
- package/dist/services/bot-profile-store.d.ts +17 -2
- package/dist/services/bot-profile-store.d.ts.map +1 -1
- package/dist/services/bot-profile-store.js +93 -12
- package/dist/services/bot-profile-store.js.map +1 -1
- package/dist/services/bridge-fallback-gate.d.ts +15 -7
- package/dist/services/bridge-fallback-gate.d.ts.map +1 -1
- package/dist/services/bridge-fallback-gate.js +43 -16
- package/dist/services/bridge-fallback-gate.js.map +1 -1
- package/dist/services/bridge-turn-queue.d.ts +10 -1
- package/dist/services/bridge-turn-queue.d.ts.map +1 -1
- package/dist/services/bridge-turn-queue.js +29 -9
- package/dist/services/bridge-turn-queue.js.map +1 -1
- package/dist/services/claude-transcript.d.ts +19 -0
- package/dist/services/claude-transcript.d.ts.map +1 -1
- package/dist/services/claude-transcript.js +57 -5
- package/dist/services/claude-transcript.js.map +1 -1
- package/dist/services/codex-app-threads.d.ts +2 -0
- package/dist/services/codex-app-threads.d.ts.map +1 -1
- package/dist/services/codex-app-threads.js +1 -1
- package/dist/services/codex-app-threads.js.map +1 -1
- package/dist/services/codex-reasoning-effort.d.ts +8 -0
- package/dist/services/codex-reasoning-effort.d.ts.map +1 -1
- package/dist/services/codex-reasoning-effort.js +24 -0
- package/dist/services/codex-reasoning-effort.js.map +1 -1
- package/dist/services/cursor-resume-policy.d.ts.map +1 -1
- package/dist/services/cursor-resume-policy.js +15 -3
- package/dist/services/cursor-resume-policy.js.map +1 -1
- package/dist/services/open-platform-rename.d.ts.map +1 -1
- package/dist/services/open-platform-rename.js +3 -2
- package/dist/services/open-platform-rename.js.map +1 -1
- package/dist/services/ordinary-turn-recovery.d.ts +76 -0
- package/dist/services/ordinary-turn-recovery.d.ts.map +1 -0
- package/dist/services/ordinary-turn-recovery.js +349 -0
- package/dist/services/ordinary-turn-recovery.js.map +1 -0
- package/dist/services/peer-cross-ref-store.d.ts +8 -0
- package/dist/services/peer-cross-ref-store.d.ts.map +1 -0
- package/dist/services/peer-cross-ref-store.js +95 -0
- package/dist/services/peer-cross-ref-store.js.map +1 -0
- package/dist/services/pi-transcript.d.ts.map +1 -1
- package/dist/services/pi-transcript.js +10 -6
- package/dist/services/pi-transcript.js.map +1 -1
- package/dist/services/resume-fresh-policy.d.ts +17 -0
- package/dist/services/resume-fresh-policy.d.ts.map +1 -0
- package/dist/services/resume-fresh-policy.js +24 -0
- package/dist/services/resume-fresh-policy.js.map +1 -0
- package/dist/services/session-group-title.d.ts +1 -0
- package/dist/services/session-group-title.d.ts.map +1 -1
- package/dist/services/session-group-title.js +16 -1
- package/dist/services/session-group-title.js.map +1 -1
- package/dist/services/session-groups-store.d.ts +30 -0
- package/dist/services/session-groups-store.d.ts.map +1 -1
- package/dist/services/session-groups-store.js +26 -4
- package/dist/services/session-groups-store.js.map +1 -1
- package/dist/services/session-owner-notification.d.ts +9 -0
- package/dist/services/session-owner-notification.d.ts.map +1 -0
- package/dist/services/session-owner-notification.js +10 -0
- package/dist/services/session-owner-notification.js.map +1 -0
- package/dist/services/session-owner-reminder-config-store.d.ts +9 -0
- package/dist/services/session-owner-reminder-config-store.d.ts.map +1 -0
- package/dist/services/session-owner-reminder-config-store.js +24 -0
- package/dist/services/session-owner-reminder-config-store.js.map +1 -0
- package/dist/services/session-owner-reminder-store.d.ts +5 -0
- package/dist/services/session-owner-reminder-store.d.ts.map +1 -0
- package/dist/services/session-owner-reminder-store.js +54 -0
- package/dist/services/session-owner-reminder-store.js.map +1 -0
- package/dist/services/session-store.d.ts +98 -21
- package/dist/services/session-store.d.ts.map +1 -1
- package/dist/services/session-store.js +406 -48
- package/dist/services/session-store.js.map +1 -1
- package/dist/services/structured-bridge-clis.d.ts +15 -2
- package/dist/services/structured-bridge-clis.d.ts.map +1 -1
- package/dist/services/structured-bridge-clis.js +16 -1
- package/dist/services/structured-bridge-clis.js.map +1 -1
- package/dist/services/transcript-resolver.d.ts +1 -1
- package/dist/services/transcript-resolver.d.ts.map +1 -1
- package/dist/services/transcript-resolver.js +6 -1
- package/dist/services/transcript-resolver.js.map +1 -1
- package/dist/setup/bot-config-editor.d.ts.map +1 -1
- package/dist/setup/bot-config-editor.js +7 -2
- package/dist/setup/bot-config-editor.js.map +1 -1
- package/dist/setup/ensure-herdr-integrations.d.ts +13 -0
- package/dist/setup/ensure-herdr-integrations.d.ts.map +1 -1
- package/dist/setup/ensure-herdr-integrations.js +21 -3
- package/dist/setup/ensure-herdr-integrations.js.map +1 -1
- package/dist/setup/open-platform-automation.d.ts +1 -0
- package/dist/setup/open-platform-automation.d.ts.map +1 -1
- package/dist/setup/open-platform-automation.js +107 -7
- package/dist/setup/open-platform-automation.js.map +1 -1
- package/dist/skills/definitions.d.ts +17 -0
- package/dist/skills/definitions.d.ts.map +1 -1
- package/dist/skills/definitions.js +78 -8
- package/dist/skills/definitions.js.map +1 -1
- package/dist/skills/injection-mode.d.ts +24 -3
- package/dist/skills/injection-mode.d.ts.map +1 -1
- package/dist/skills/injection-mode.js +64 -15
- package/dist/skills/injection-mode.js.map +1 -1
- package/dist/skills/installer.d.ts +18 -0
- package/dist/skills/installer.d.ts.map +1 -1
- package/dist/skills/installer.js +45 -1
- package/dist/skills/installer.js.map +1 -1
- package/dist/types.d.ts +222 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/bot-routing.d.ts +1 -1
- package/dist/utils/bot-routing.d.ts.map +1 -1
- package/dist/utils/bot-routing.js.map +1 -1
- package/dist/utils/child-env.d.ts +92 -2
- package/dist/utils/child-env.d.ts.map +1 -1
- package/dist/utils/child-env.js +195 -1
- package/dist/utils/child-env.js.map +1 -1
- package/dist/utils/cli-usage-limit.d.ts +25 -14
- package/dist/utils/cli-usage-limit.d.ts.map +1 -1
- package/dist/utils/cli-usage-limit.js +25 -15
- package/dist/utils/cli-usage-limit.js.map +1 -1
- package/dist/utils/daemon-rejection-guard.d.ts +35 -0
- package/dist/utils/daemon-rejection-guard.d.ts.map +1 -0
- package/dist/utils/daemon-rejection-guard.js +101 -0
- package/dist/utils/daemon-rejection-guard.js.map +1 -0
- package/dist/utils/dashboard-env.d.ts +53 -0
- package/dist/utils/dashboard-env.d.ts.map +1 -0
- package/dist/utils/dashboard-env.js +116 -0
- package/dist/utils/dashboard-env.js.map +1 -0
- package/dist/utils/global-install.d.ts.map +1 -1
- package/dist/utils/global-install.js +61 -5
- package/dist/utils/global-install.js.map +1 -1
- package/dist/utils/install-diagnostics.d.ts +14 -7
- package/dist/utils/install-diagnostics.d.ts.map +1 -1
- package/dist/utils/install-diagnostics.js +20 -11
- package/dist/utils/install-diagnostics.js.map +1 -1
- package/dist/utils/local-dev-update.d.ts +132 -0
- package/dist/utils/local-dev-update.d.ts.map +1 -0
- package/dist/utils/local-dev-update.js +176 -0
- package/dist/utils/local-dev-update.js.map +1 -0
- package/dist/utils/pending-input-queue.d.ts +12 -1
- package/dist/utils/pending-input-queue.d.ts.map +1 -1
- package/dist/utils/pending-input-queue.js.map +1 -1
- package/dist/worker.js +1517 -236
- package/dist/worker.js.map +1 -1
- package/dist/workflows/definition.d.ts +68 -68
- package/dist/workflows/events/payloads.d.ts +14 -14
- package/dist/workflows/events/schema.d.ts +312 -312
- package/dist/workflows/migration/v2-run-archive-schema.d.ts +40 -40
- package/dist/workflows/v3/cli-run.d.ts.map +1 -1
- package/dist/workflows/v3/cli-run.js +7 -0
- package/dist/workflows/v3/cli-run.js.map +1 -1
- package/dist/workflows/v3/goal-cli.d.ts +3 -0
- package/dist/workflows/v3/goal-cli.d.ts.map +1 -1
- package/dist/workflows/v3/goal-cli.js +11 -0
- package/dist/workflows/v3/goal-cli.js.map +1 -1
- package/dist/workflows/v3/run-envelope.d.ts +144 -144
- package/package.json +7 -2
- package/dist/cli/pm2-god-admission.d.ts +0 -8
- package/dist/cli/pm2-god-admission.d.ts.map +0 -1
- package/dist/cli/pm2-god-admission.js +0 -25
- package/dist/cli/pm2-god-admission.js.map +0 -1
- package/dist/core/riff-shutdown-detach.d.ts.map +0 -1
- package/dist/core/riff-shutdown-detach.js.map +0 -1
- package/dist/core/riff-worker-shutdown-readiness.d.ts.map +0 -1
- package/dist/core/riff-worker-shutdown-readiness.js.map +0 -1
- package/dist/dashboard-web/chunks/bot-defaults-page-4RENHE7J.js +0 -10
- package/dist/dashboard-web/chunks/chunk-2WQDS65D.js +0 -1
- package/dist/dashboard-web/chunks/chunk-G5XGBCM6.js +0 -1
- package/dist/dashboard-web/chunks/chunk-WLIVBPJC.js +0 -1
- package/dist/dashboard-web/chunks/groups-page-HLASRTSY.js +0 -8
- package/dist/dashboard-web/chunks/overview-page-6OK63V4V.js +0 -1
- package/dist/dashboard-web/chunks/sessions-page-B2TXGJDO.js +0 -8
- package/dist/dashboard-web/chunks/settings-page-6KJADSC6.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G}from"./chunk-BD3PZGH2.js";import{a as U}from"./chunk-SYC6D5XU.js";import{a as W,d as H}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var r=$(W(),1);var n=$(H(),1);async function q(){let e=await fetch("/api/plugins/dashboard");if(!e.ok)throw new Error(`HTTP ${e.status}`);let a=await e.json();return Array.isArray(a?.plugins)?a.plugins:[]}function M(e){return{plugins:Array.isArray(e?.plugins)?e.plugins:[],globalPlugins:Array.isArray(e?.globalPlugins)?e.globalPlugins:[],bots:Array.isArray(e?.bots)?e.bots:[],gatewayAdapters:Array.isArray(e?.gatewayAdapters)?e.gatewayAdapters:[]}}async function _(){let e=await fetch("/api/plugins");if(!e.ok)throw new Error(`HTTP ${e.status}`);return M(await e.json())}async function z(e,a,t){let i=t==="global"?"global":`bots/${encodeURIComponent(t)}`,g=await fetch(`/api/plugins/${encodeURIComponent(e)}/${i}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})}),l=await g.json().catch(()=>({}));if(!g.ok)throw new Error(typeof l?.error=="string"?l.error:`HTTP ${g.status}`);return M(l)}async function Q(e,a){let t=await fetch(`/api/plugins/${encodeURIComponent(e)}/pin`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({pinned:a})});if(!t.ok)throw new Error(`HTTP ${t.status}`);return M(await t.json())}async function A(e,a){let t=await fetch(`/api/plugins/${encodeURIComponent(e)}/services/${a}`,{method:"POST"});if(!t.ok)throw new Error(`HTTP ${t.status}`);return M(await t.json())}function k(e){return e.values?.length?(0,n.jsx)(n.Fragment,{children:e.values.map(a=>(0,n.jsx)("span",{className:"plugin-chip",children:a},a))}):(0,n.jsx)("span",{className:"plugin-muted",children:"-"})}function y(e){return(0,n.jsx)("code",{className:"plugin-inline-code",children:e.children})}function N(e){return e.rows.length===0?(0,n.jsx)("div",{className:"plugin-empty-state",children:"\u6682\u65E0\u5185\u5BB9"}):(0,n.jsx)("div",{className:"plugin-info-table",children:e.rows.map((a,t)=>(0,n.jsxs)("div",{className:"plugin-info-row",children:[(0,n.jsx)("span",{children:a.label}),(0,n.jsx)("div",{children:a.content})]},`${a.label}:${t}`))})}function C(e){return(0,n.jsxs)("div",{className:"plugin-tab-panel-head",children:[(0,n.jsx)("h3",{children:e.title}),(0,n.jsx)("p",{children:e.description})]})}function T(e){return(0,n.jsx)("div",{className:"plugin-empty-state",children:e.children})}function j(e){return e?e.status||e.action:"unknown"}function B(e){let a=j(e);return a==="online"||a==="started"||a==="already-running"?"\u8FD0\u884C\u4E2D":a==="stopped"||a==="not-running"?"\u5DF2\u505C\u6B62":a==="failed"?"\u5F02\u5E38":"\u672A\u77E5"}function Y(e){return e.mode==="manual"?"\u4E0D\u968F botmux start/stop/restart \u81EA\u52A8\u5F00\u5173\uFF1B\u4ECD\u53EF\u5728\u8FD9\u91CC\u624B\u52A8\u542F\u52A8\u3001\u505C\u6B62\u3001\u91CD\u542F":e.mode==="auto"?"botmux start/restart \u540E\u81EA\u52A8\u786E\u4FDD\u8FD0\u884C\uFF1B\u9ED8\u8BA4 restart \u4E0D\u5148\u505C\u6B62\uFF0C--with-plugin \u624D\u4F1A\u5148\u505C\u518D\u542F\u52A8":"\u672A\u77E5\u751F\u547D\u5468\u671F\u7B56\u7565"}function J(e){return e.mode==="manual"?"\u624B\u52A8\u5F00\u5173":e.mode==="auto"?"\u542F\u52A8\u540E\u786E\u4FDD\u8FD0\u884C":"\u672A\u77E5\u6A21\u5F0F"}function X(e){let a=j(e);return a==="online"||a==="started"||a==="already-running"?"plugin-status-ok":a==="stopped"||a==="not-running"?"plugin-status-idle":a==="failed"?"plugin-status-bad":"plugin-status-muted"}function I(e){return e.url?(0,n.jsx)("a",{className:`plugin-link${e.health?"":" plugin-service-url"}`,href:e.url,target:"_blank",rel:"noreferrer",children:e.health?"\u5065\u5EB7\u68C0\u67E5":e.url}):(0,n.jsx)("span",{className:"plugin-muted",children:e.health?"\u65E0\u5065\u5EB7\u68C0\u67E5":"\u6682\u65E0\u8BBF\u95EE\u5730\u5740"})}function Z(e){let{plugin:a}=e;if(!a.service)return(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u9700\u8981\u5355\u72EC\u542F\u52A8\u7684\u540E\u53F0\u8FDB\u7A0B\u3002"});let t=a.serviceReport,i=[{label:"\u72B6\u6001",content:(0,n.jsx)("span",{className:`plugin-status ${X(t)}`,children:B(t)})},{label:"\u6A21\u5F0F",content:(0,n.jsx)(k,{values:[J(a.service)]})},{label:"\u751F\u547D\u5468\u671F",content:(0,n.jsx)("span",{children:Y(a.service)})},{label:"\u7AEF\u53E3",content:t?.port?(0,n.jsx)(y,{children:t.port}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u4E0A\u62A5"})},{label:"PID",content:t?.pid?(0,n.jsx)(y,{children:t.pid}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u4E0A\u62A5"})},{label:"\u8BBF\u95EE\u5730\u5740",content:(0,n.jsx)(I,{url:t?.openUrl})},{label:"\u5065\u5EB7\u68C0\u67E5",content:(0,n.jsx)(I,{url:t?.healthUrl,health:!0})}];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(N,{rows:i}),t?.warning?(0,n.jsx)("div",{className:"plugin-warning",children:t.warning}):null]})}function nn(e){let{plugin:a}=e;if(!a.service)return null;let t=a.serviceReport;return(0,n.jsxs)("section",{className:"plugin-action-group",children:[(0,n.jsxs)("div",{className:"plugin-action-head",children:[(0,n.jsx)("span",{children:"Service"}),(0,n.jsx)("strong",{children:J(a.service)}),(0,n.jsx)("span",{className:`plugin-status ${X(t)}`,children:B(t)})]}),(0,n.jsxs)("div",{className:"plugin-action-meta",children:[t?.port?(0,n.jsxs)("span",{children:["\u7AEF\u53E3 ",t.port]}):null,t?.pid?(0,n.jsxs)("span",{children:["PID ",t.pid]}):null,(0,n.jsx)(I,{url:t?.openUrl})]}),(0,n.jsx)("div",{className:"plugin-service-actions",children:["start","stop","restart"].map(i=>(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-service":a.id,"data-action":i,disabled:e.busy,onClick:()=>e.onAction(i),children:i==="start"?"\u542F\u52A8":i==="stop"?"\u505C\u6B62":"\u91CD\u542F"},i))})]})}function en(e){let a=e.plugin.dashboard??[];return a.length===0?null:(0,n.jsxs)("section",{className:"plugin-action-group",children:[(0,n.jsxs)("div",{className:"plugin-action-head",children:[(0,n.jsx)("span",{children:"Dashboard"}),(0,n.jsxs)("strong",{children:[a.length," \u4E2A\u9875\u9762"]})]}),(0,n.jsx)("div",{className:"plugin-action-links",children:a.map(t=>(0,n.jsxs)("a",{className:"btn-link primary",href:t.route,children:["\u6253\u5F00 ",t.id]},t.id))})]})}function an(e){let a=!!e.plugin.service,t=(e.plugin.dashboard?.length??0)>0;return!a&&!t?null:(0,n.jsxs)("div",{className:"plugin-action-area","aria-label":`${e.plugin.id} \u63D2\u4EF6\u64CD\u4F5C`,children:[(0,n.jsxs)("div",{className:"plugin-action-title",children:[(0,n.jsx)("span",{children:"\u64CD\u4F5C"}),(0,n.jsx)("small",{children:"\u56FA\u5B9A\u64CD\u4F5C\u533A\uFF0C\u4E0B\u9762\u7684 tab \u53EA\u5C55\u793A\u4FE1\u606F"})]}),(0,n.jsxs)("div",{className:"plugin-action-grid",children:[(0,n.jsx)(nn,{plugin:e.plugin,busy:e.busy,onAction:e.onServiceAction}),(0,n.jsx)(en,{plugin:e.plugin})]})]})}function R(e){return(0,n.jsx)("section",{className:`plugin-tab-panel${e.active?" is-active":""}`,role:"tabpanel","data-plugin-panel":e.id,children:e.children})}function tn(e){let t=(e.plugin.contributions?.skills??[]).map(i=>({label:i.name||i.path||"skill",content:i.path?(0,n.jsx)(y,{children:i.path}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u58F0\u660E\u8DEF\u5F84"})}));return(0,n.jsxs)(R,{id:"skills",active:e.active,children:[(0,n.jsx)(C,{title:"Skills",description:"\u6BCF\u6B21\u771F\u6B63\u542F\u52A8\u6216\u91CD\u542F CLI \u8FDB\u7A0B\u65F6\uFF0C\u90FD\u4F1A\u6309\u5F53\u524D Bot \u7684\u6709\u6548\u63D2\u4EF6\u96C6\u5237\u65B0\u8FD9\u4E9B\u6280\u80FD\uFF1B\u8FD0\u884C\u4E2D\u7684 CLI \u4E0D\u70ED\u66F4\u65B0\u3002"}),t.length>0?(0,n.jsx)(N,{rows:t}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B Skills\u3002"})]})}function ln(e){let a=e.plugin,t=a.contributions?.mcp,i=t?[{label:t.name||"mcp",content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u4F20\u8F93"}),(0,n.jsx)(k,{values:[t.transport||"stdio"]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u8FD0\u884C\u914D\u7F6E"}),(0,n.jsx)(k,{values:["\u53D7\u4FDD\u62A4\uFF0C\u7531 Gateway \u6309\u4F1A\u8BDD\u52A0\u8F7D"]})]})]})}]:[],g=(a.gatewayAdapters??[]).map(s=>({label:s.cliId,content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"Gateway"}),(0,n.jsx)(k,{values:[s.state==="configured"||s.state==="unchanged"||s.state==="installed"?"\u5DF2\u63A5\u5165":s.state==="adapter-required"?"\u5F85\u9002\u914D":"\u672A\u5199\u5165"]})]}),s.configPath?(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u914D\u7F6E\u76EE\u6807"}),(0,n.jsx)(y,{children:s.configPath})]}):null,s.warning?(0,n.jsx)("div",{className:"plugin-warning",children:s.warning}):null]})})),l=(a.mcpDiagnostics??[]).map(s=>({label:s.serverName,content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u6700\u8FD1\u8FDE\u63A5"}),(0,n.jsx)(k,{values:[s.status==="connected"?"\u6B63\u5E38":"\u5931\u8D25",s.transport]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u80FD\u529B\u6570\u91CF"}),(0,n.jsx)(k,{values:[`Tools ${s.tools??0}`,`Prompts ${s.prompts??0}`,`Resources ${s.resources??0}`]})]}),s.sessionId?(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u4F1A\u8BDD"}),(0,n.jsx)(y,{children:s.sessionId})]}):null,s.error?(0,n.jsx)("div",{className:"plugin-warning",children:s.error}):null]})}));return(0,n.jsxs)(R,{id:"mcp",active:e.active,children:[(0,n.jsx)(C,{title:"MCP",description:"CLI \u53EA\u8FDE\u63A5\u4E00\u4E2A Botmux Gateway\uFF1B\u6BCF\u4E00\u4EE3 CLI \u8FDB\u7A0B\u6309\u542F\u52A8\u65F6\u6E05\u5355\u8FDE\u63A5\u8FD9\u4E9B\u4E0B\u6E38 MCP\u3002"}),g.length>0?(0,n.jsx)(N,{rows:g}):null,l.length>0?(0,n.jsx)(N,{rows:l}):null,i.length>0?(0,n.jsx)(N,{rows:i}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B MCP server\u3002"})]})}function sn(e){let a=e.plugin.contributions?.cli,t=[...a?.entry?[{label:"\u5165\u53E3\u6587\u4EF6",content:(0,n.jsx)(y,{children:a.entry})}]:[],...(a?.commands??[]).map(i=>({label:i.name,content:i.description?(0,n.jsx)("span",{children:i.description}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u65E0\u63CF\u8FF0"})}))];return(0,n.jsxs)(R,{id:"cli",active:e.active,children:[(0,n.jsx)(C,{title:"CLI \u547D\u4EE4",description:"\u542F\u7528\u63D2\u4EF6\u540E\uFF0C\u8FD9\u4E9B\u547D\u4EE4\u4F1A\u8FDB\u5165 botmux \u7684\u547D\u4EE4\u8DEF\u7531\u3002"}),t.length>0?(0,n.jsx)(N,{rows:t}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B CLI \u547D\u4EE4\u3002"})]})}function on(e){let a=(e.plugin.dashboard??[]).map(t=>({label:t.id,content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u8DEF\u7531"}),(0,n.jsx)(y,{children:t.route})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u5165\u53E3"}),(0,n.jsx)(y,{children:t.entry})]})]})}));return(0,n.jsxs)(R,{id:"dashboard",active:e.active,children:[(0,n.jsx)(C,{title:"Dashboard",description:"\u63D2\u4EF6\u81EA\u5DF1\u7684\u53EF\u89C6\u5316\u9875\u9762\u4F1A\u5728\u8FD9\u91CC\u66B4\u9732\u5165\u53E3\u3002"}),a.length>0?(0,n.jsx)(N,{rows:a}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B Dashboard \u9875\u9762\u3002"})]})}function rn(e){return(0,n.jsxs)(R,{id:"service",active:e.active,children:[(0,n.jsx)(C,{title:"Service",description:"\u63D2\u4EF6\u540E\u53F0\u670D\u52A1\u7684\u58F0\u660E\u3001\u5F53\u524D\u72B6\u6001\u548C\u8BBF\u95EE\u5730\u5740\u3002\u542F\u52A8\u3001\u505C\u6B62\u3001\u91CD\u542F\u5728\u4E0A\u65B9\u64CD\u4F5C\u533A\u5904\u7406\u3002"}),(0,n.jsx)(Z,{plugin:e.plugin})]})}function cn(e){let a=e.plugin.contributions?.cli?.commands??[],t=(0,r.useMemo)(()=>[{id:"skills",label:"Skills",count:e.plugin.skillsCount??0,hint:"\u4F1A\u8BDD\u52A0\u8F7D"},{id:"mcp",label:"MCP",count:e.plugin.mcpCount??0,hint:"Gateway \u805A\u5408"},{id:"cli",label:"CLI \u547D\u4EE4",count:a.length,hint:"\u547D\u4EE4\u8DEF\u7531"},{id:"dashboard",label:"Dashboard",count:e.plugin.dashboard?.length??0,hint:"\u9875\u9762\u5165\u53E3"},{id:"service",label:"Service",count:e.plugin.service?1:0,hint:e.plugin.service?J(e.plugin.service):"\u65E0\u540E\u53F0\u8FDB\u7A0B"}],[a.length,e.plugin.dashboard?.length,e.plugin.mcpCount,e.plugin.service,e.plugin.skillsCount]),[i,g]=(0,r.useState)(()=>t.find(l=>l.count>0)?.id??"skills");return(0,n.jsxs)("div",{className:"plugin-tabs",children:[(0,n.jsx)("div",{className:"plugin-tab-list",role:"tablist","aria-label":`${e.plugin.id} \u63D2\u4EF6\u80FD\u529B`,children:t.map(l=>(0,n.jsxs)("button",{type:"button",className:`plugin-tab-button${i===l.id?" is-active":""}`,role:"tab","aria-selected":i===l.id,"data-plugin-tab":l.id,onClick:()=>g(l.id),children:[(0,n.jsx)("strong",{children:l.count}),(0,n.jsx)("span",{children:l.label}),(0,n.jsx)("small",{children:l.hint})]},l.id))}),(0,n.jsxs)("div",{className:"plugin-tab-panels",children:[(0,n.jsx)(tn,{plugin:e.plugin,active:i==="skills"}),(0,n.jsx)(ln,{plugin:e.plugin,active:i==="mcp"}),(0,n.jsx)(sn,{plugin:e.plugin,active:i==="cli"}),(0,n.jsx)(on,{plugin:e.plugin,active:i==="dashboard"}),(0,n.jsx)(rn,{plugin:e.plugin,active:i==="service"})]})]})}function x(e,a){return`${e}:${a}`}function w(e,a,t){let i=t.get(x(e.id,a));return i!==void 0?i:a==="global"?e.enabledGlobal===!0:e.enabledByBot?.[a]===!0}function gn(e){return(0,n.jsxs)("label",{className:"toggle-row plugin-enable-row",children:[(0,n.jsxs)("span",{className:"plugin-enable-copy",children:[(0,n.jsx)("strong",{children:e.label}),(0,n.jsx)("small",{children:e.hint})]}),(0,n.jsx)("input",{type:"checkbox","data-plugin-toggle":e.scope,"data-plugin-id":e.plugin.id,checked:e.checked,disabled:e.busy,onChange:a=>e.onToggle(e.scope,a.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"})]})}function un(e){let a=w(e.plugin,"global",e.pendingToggles);return(0,n.jsxs)("label",{className:"toggle-row plugin-global-setting",children:[(0,n.jsxs)("span",{className:"plugin-global-setting-copy",children:[(0,n.jsx)("strong",{children:"\u5168\u5C40\u542F\u7528"}),(0,n.jsx)("small",{children:a?`\u5DF2\u5BF9\u5168\u90E8 ${e.bots.length} \u4E2A Bot \u542F\u7528`:"\u5173\u95ED\u65F6\u53EF\u5C55\u5F00\u5361\u7247\uFF0C\u6309 Bot \u5355\u72EC\u542F\u7528"})]}),(0,n.jsx)("input",{type:"checkbox","data-plugin-toggle":"global","data-plugin-id":e.plugin.id,checked:a,disabled:e.busy,onChange:t=>e.onToggle("global",t.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"})]})}function dn(e){let{plugin:a,bots:t,pendingToggles:i}=e,g=t.filter(l=>w(a,l.id,i)).length;return(0,n.jsxs)("section",{className:"plugin-enable-panel","aria-label":`${a.displayName||a.id} \u6309 Bot \u542F\u7528`,children:[(0,n.jsxs)("div",{className:"plugin-enable-panel-head",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"\u6309 Bot \u542F\u7528"}),(0,n.jsx)("small",{children:"\u5168\u5C40\u5173\u95ED\u65F6\uFF0C\u53EF\u4E3A\u9700\u8981\u6B64\u63D2\u4EF6\u7684 Bot \u5355\u72EC\u5F00\u542F\uFF1B\u65B0\u542F\u52A8\u7684 CLI \u4F1A\u8BDD\u751F\u6548\u3002"})]}),(0,n.jsxs)("span",{children:[g,"/",t.length," \u4E2A Bot \u5DF2\u542F\u7528"]})]}),(0,n.jsxs)("div",{className:"plugin-enable-list",children:[t.map(l=>{let s=w(a,l.id,i),p=s?"\u5DF2\u542F\u7528":"\u672A\u542F\u7528";return(0,n.jsx)(gn,{plugin:a,scope:l.id,label:l.name,hint:`\u5F53\u524D${p}`,checked:s,busy:e.busy,onToggle:e.onToggle},l.id)}),t.length===0?(0,n.jsx)("div",{className:"plugin-enable-empty",children:"\u6682\u65E0\u5DF2\u914D\u7F6E Bot"}):null]})]})}function pn(e){let a=e.plugin.contributions?.cli?.commands??[],t=[{label:"Skills",count:e.plugin.skillsCount??0},{label:"MCP",count:e.plugin.mcpCount??0},{label:"\u547D\u4EE4",count:a.length},{label:"Dashboard",count:e.plugin.dashboard?.length??0}].filter(i=>i.count>0);return(0,n.jsxs)("div",{className:"plugin-card-summary",children:[(0,n.jsxs)("div",{className:"plugin-capability-summary","aria-label":"\u63D2\u4EF6\u80FD\u529B\u6458\u8981",children:[t.map(i=>(0,n.jsxs)("span",{className:"plugin-capability-chip",children:[(0,n.jsx)("strong",{children:i.count}),i.label]},i.label)),e.plugin.service?(0,n.jsxs)("span",{className:`plugin-capability-chip ${X(e.plugin.serviceReport)}`,children:["Service ",B(e.plugin.serviceReport)]}):null,t.length===0&&!e.plugin.service?(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u58F0\u660E\u6269\u5C55\u80FD\u529B"}):null]}),(0,n.jsx)("span",{className:"plugin-scope-summary",children:e.globalEnabled?`\u5168\u90E8 ${e.botCount} \u4E2A Bot`:`${e.enabledBotCount}/${e.botCount} \u4E2A Bot \u5355\u72EC\u542F\u7528`})]})}function bn(e){let a=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let t=a.current;if(t)if(e.feedback&&!t.open)try{t.showModal()}catch{t.setAttribute("open","")}else!e.feedback&&t.open&&t.close()},[e.feedback]),(0,n.jsx)("dialog",{className:"plugin-feedback-dialog","data-plugin-feedback-dialog":!0,ref:a,onClose:e.onClose,onClick:t=>{t.target===t.currentTarget&&e.onClose()},children:(0,n.jsxs)("article",{children:[(0,n.jsxs)("header",{children:[(0,n.jsx)("span",{className:"plugin-feedback-mark","aria-hidden":"true",children:"!"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{children:"\u63D2\u4EF6\u8BBE\u7F6E\u672A\u4FDD\u5B58"}),(0,n.jsx)("h2",{"data-plugin-feedback-title":!0,children:e.feedback?.title??"\u64CD\u4F5C\u5931\u8D25"})]})]}),(0,n.jsx)("p",{className:"plugin-feedback-message","data-plugin-feedback-message":!0,children:e.feedback?.message}),(0,n.jsx)("footer",{children:(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-feedback-close":!0,onClick:e.onClose,children:"\u77E5\u9053\u4E86"})})]})})}function mn(e){let{plugin:a}=e,[t,i]=(0,r.useState)(!1),g=a.displayName||a.id,l=a.dependencies??[],s=w(a,"global",e.pendingToggles),p=e.bots.filter(d=>w(a,d.id,e.pendingToggles)).length,S=s||p>0,b=e.pendingToggles.has(x(a.id,"global")),f=(a.dashboard?.length??0)>0,m=e.pendingPin??a.pinnedToSidebar===!0,P=`plugin-details-${a.id}`;return(0,n.jsxs)("article",{className:`bd-card plugin-card${t?" is-expanded":" is-collapsed"}`,"data-plugin-card":a.id,children:[(0,n.jsxs)("header",{className:"plugin-card-head",children:[(0,n.jsxs)("div",{className:"plugin-title-block",children:[(0,n.jsxs)("div",{className:"plugin-title-row",children:[(0,n.jsx)("h2",{children:g}),(0,n.jsx)("span",{className:`plugin-status ${S?"plugin-status-ok":"plugin-status-idle"}`,children:s?"\u5168\u5C40\u5DF2\u542F\u7528":p>0?`${p} \u4E2A Bot \u5DF2\u542F\u7528`:"\u672A\u542F\u7528"})]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("code",{children:a.id}),(0,n.jsxs)("span",{children:[a.packageName,"@",a.version]}),l.length>0?(0,n.jsxs)("span",{children:["\u4F9D\u8D56 ",l.join(", ")]}):null]})]}),(0,n.jsx)("button",{type:"button",className:"btn-link plugin-expand-button","data-plugin-expand":a.id,"aria-expanded":t,"aria-controls":P,onClick:()=>i(d=>!d),children:t?"\u6536\u8D77\u8BE6\u60C5":"\u5C55\u5F00\u8BE6\u60C5"})]}),(0,n.jsx)(un,{plugin:a,bots:e.bots,pendingToggles:e.pendingToggles,busy:e.busy,onToggle:e.onToggle}),(0,n.jsx)(pn,{plugin:a,globalEnabled:s,enabledBotCount:p,botCount:e.bots.length}),t?(0,n.jsxs)("div",{className:"plugin-card-expanded",id:P,children:[!s&&!b?(0,n.jsx)(dn,{plugin:a,bots:e.bots,pendingToggles:e.pendingToggles,busy:e.busy,onToggle:e.onToggle}):null,b?(0,n.jsx)("div",{className:"plugin-settings-pending",children:"\u6B63\u5728\u66F4\u65B0\u5168\u5C40\u8BBE\u7F6E..."}):null,f?(0,n.jsx)("div",{className:"plugin-card-controls",children:(0,n.jsxs)("label",{className:"toggle-row plugin-pin-toggle",children:[(0,n.jsx)("input",{type:"checkbox","data-plugin-pin":a.id,checked:m,disabled:e.busy,onChange:d=>e.onPin(d.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch"}),(0,n.jsxs)("span",{className:"toggle-tx",children:[(0,n.jsx)("strong",{children:"Pin \u5230\u4FA7\u680F"}),(0,n.jsx)("small",{children:m?"\u5DF2\u56FA\u5B9A\uFF0C\u53EF\u4ECE\u4E3B\u83DC\u5355\u5FEB\u901F\u6253\u5F00":"\u56FA\u5B9A\u540E\u53EF\u4ECE\u4E3B\u83DC\u5355\u5FEB\u901F\u6253\u5F00"})]})]})}):null,(0,n.jsx)(an,{plugin:a,busy:e.busy,onServiceAction:e.onServiceAction}),(0,n.jsx)("div",{className:"plugin-card-body",children:(0,n.jsx)(cn,{plugin:a})})]}):null]})}function E(e,a,t){let i=new Map(e);return t===void 0?i.delete(a):i.set(a,t),i}function vn(e,a,t){let i=new Set(e);return t?i.add(a):i.delete(a),i}function hn(){let[e,a]=(0,r.useState)(null),[t,i]=(0,r.useState)(null),[g,l]=(0,r.useState)(!1),[s,p]=(0,r.useState)(()=>new Set),[S,b]=(0,r.useState)(()=>new Map),[f,m]=(0,r.useState)(()=>new Map),[P,d]=(0,r.useState)(null),D=(0,r.useCallback)(async()=>{l(!0),i(null);try{a(await _())}catch(o){i(o instanceof Error?o.message:String(o))}finally{l(!1)}},[]);(0,r.useEffect)(()=>{D()},[D]);let v=(0,r.useCallback)((o,u)=>{p(c=>vn(c,o,u))},[]),F=(0,r.useCallback)(async(o,u,c)=>{let L=x(o,u);b(h=>E(h,L,c)),v(o,!0);try{let h=await z(o,c,u);a(h)}catch(h){d({title:c?"\u65E0\u6CD5\u542F\u7528\u63D2\u4EF6":"\u65E0\u6CD5\u7981\u7528\u63D2\u4EF6",message:h instanceof Error?h.message:String(h)})}finally{b(h=>E(h,L,void 0)),v(o,!1)}},[v]),K=(0,r.useCallback)(async(o,u)=>{m(c=>E(c,o,u)),v(o,!0);try{let c=await Q(o,u);a(c),window.dispatchEvent(new Event(G))}catch(c){d({title:"\u65E0\u6CD5\u66F4\u65B0\u4FA7\u680F\u56FA\u5B9A",message:c instanceof Error?c.message:String(c)})}finally{m(c=>E(c,o,void 0)),v(o,!1)}},[v]),V=(0,r.useCallback)(async(o,u)=>{v(o,!0);try{let c=await A(o,u);a(c)}catch(c){d({title:"Service \u64CD\u4F5C\u5931\u8D25",message:c instanceof Error?c.message:String(c)})}finally{v(o,!1)}},[v]);if(!e&&!t)return(0,n.jsx)("section",{className:"page",children:(0,n.jsx)("div",{className:"empty",children:"Loading plugins..."})});if(!e)return(0,n.jsx)("section",{className:"page",children:(0,n.jsxs)("div",{className:"bd-card empty",children:["\u63D2\u4EF6\u5217\u8868\u52A0\u8F7D\u5931\u8D25\uFF1A",t]})});let O=e.plugins.filter(o=>w(o,"global",S)).length;return(0,n.jsxs)("section",{className:"page plugin-management-page",children:[(0,n.jsxs)("div",{className:"page-heading",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{children:"\u63D2\u4EF6"}),(0,n.jsx)("p",{children:"\u5361\u7247\u9ED8\u8BA4\u5C55\u793A\u542F\u7528\u8303\u56F4\u4E0E\u80FD\u529B\u6458\u8981\uFF1B\u5C55\u5F00\u540E\u53EF\u7BA1\u7406\u5355\u4E2A Bot\u3001Service \u548C\u8BE6\u7EC6\u80FD\u529B\u3002\u5168\u5C40\u542F\u7528\u5BF9\u6240\u6709 Bot \u751F\u6548\uFF0C\u6539\u52A8\u5728\u65B0\u542F\u52A8\u7684 CLI \u4F1A\u8BDD\u4E2D\u751F\u6548\u3002"})]}),(0,n.jsx)("div",{className:"plugin-heading-actions",children:(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-refresh":!0,disabled:g,onClick:()=>{D()},children:g?"\u5237\u65B0\u4E2D...":"\u5237\u65B0"})})]}),(0,n.jsxs)("div",{className:"plugin-summary-grid",children:[(0,n.jsxs)("div",{className:"bd-card plugin-summary-card",children:[(0,n.jsx)("span",{children:"\u5DF2\u5B89\u88C5"}),(0,n.jsx)("strong",{children:e.plugins.length})]}),(0,n.jsxs)("div",{className:"bd-card plugin-summary-card",children:[(0,n.jsx)("span",{children:"\u5168\u5C40\u542F\u7528"}),(0,n.jsx)("strong",{"data-plugin-summary-enabled":!0,children:O})]})]}),e.plugins.length===0?(0,n.jsxs)("div",{className:"bd-card empty",children:["\u6682\u65E0\u5DF2\u5B89\u88C5\u63D2\u4EF6\u3002\u7528 ",(0,n.jsx)("code",{children:"botmux plugin install"})," \u5B89\u88C5\u540E\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002"]}):(0,n.jsx)("div",{className:"plugin-card-list",children:e.plugins.map(o=>(0,n.jsx)(mn,{plugin:o,bots:e.bots,pendingToggles:S,pendingPin:f.get(o.id),busy:s.has(o.id),onToggle:(u,c)=>{F(o.id,u,c)},onPin:u=>{K(o.id,u)},onServiceAction:u=>{V(o.id,u)}},o.id))}),(0,n.jsx)(bn,{feedback:P,onClose:()=>d(null)})]})}function fn(e){return{async getServiceStatus(){return(await _()).plugins.find(t=>t.id===e)?.serviceReport},async startService(){return A(e,"start")},async stopService(){return A(e,"stop")},async restartService(){return A(e,"restart")}}}function yn(e){let[a,t]=(0,r.useState)(null),[i,g]=(0,r.useState)(null),[l,s]=(0,r.useState)(null);(0,r.useEffect)(()=>{let b=!1;return t(null),g(null),s(null),(async()=>{try{let m=(await q()).find(d=>e.hash===d.route||e.hash.startsWith(`${d.route}/`)||e.hash.startsWith(`${d.route}?`));if(!m)throw new Error(`Plugin page not found: ${e.hash}`);let P=await import(m.url);if(typeof P.default!="function")throw new Error("plugin_dashboard_default_export_not_function");if(b)return;t(m),g(()=>P.default)}catch(f){b||s(f instanceof Error?f.message:String(f))}})(),()=>{b=!0}},[e.hash]);let p=(0,r.useMemo)(()=>a?fn(a.pluginId):null,[a]);if(l)return(0,n.jsx)("section",{className:"page",children:(0,n.jsxs)("div",{className:"bd-card empty",children:["\u63D2\u4EF6 Dashboard \u52A0\u8F7D\u5931\u8D25\uFF1A",l]})});if(!a||!i||!p)return(0,n.jsx)("section",{className:"page",children:(0,n.jsx)("div",{className:"empty",children:"Loading plugin..."})});let S=a.displayName||a.pluginId;return(0,n.jsx)("section",{className:"page plugin-page",children:(0,n.jsxs)("div",{className:"plugin-dashboard-shell",children:[(0,n.jsx)("div",{className:"plugin-dashboard-toolbar",children:(0,n.jsx)("a",{className:"btn-link plugin-dashboard-back",href:"#/plugins",children:"\u8FD4\u56DE\u63D2\u4EF6\u5217\u8868"})}),(0,n.jsx)("div",{className:"page-heading plugin-dashboard-heading",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"plugin-dashboard-kicker",children:"Plugin Dashboard"}),(0,n.jsx)("h1",{children:S}),(0,n.jsxs)("p",{children:[(0,n.jsx)("code",{children:a.pluginId}),(0,n.jsx)("span",{children:"/"}),(0,n.jsx)("code",{children:a.id})]})]})}),(0,n.jsx)("div",{className:"plugin-dashboard-content","data-plugin-dashboard-root":!0,children:(0,n.jsx)(i,{pluginId:a.pluginId,api:p})})]})})}function Pn(){let e=location.hash||"#/plugins";return e==="#/plugins"||e.startsWith("#/plugins?")?(0,n.jsx)(hn,{}):(0,n.jsx)(yn,{hash:e})}function kn(e){return U(e,(0,n.jsx)(Pn,{}))}export{kn as renderPluginPage};
|
|
1
|
+
import{a as H}from"./chunk-BD3PZGH2.js";import{a as G}from"./chunk-SYC6D5XU.js";import{a as W,d as U}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var r=$(W(),1);var n=$(U(),1);async function q(){let e=await fetch("/api/plugins/dashboard");if(!e.ok)throw new Error(`HTTP ${e.status}`);let a=await e.json();return Array.isArray(a?.plugins)?a.plugins:[]}function M(e){return{plugins:Array.isArray(e?.plugins)?e.plugins:[],globalPlugins:Array.isArray(e?.globalPlugins)?e.globalPlugins:[],bots:Array.isArray(e?.bots)?e.bots:[],gatewayAdapters:Array.isArray(e?.gatewayAdapters)?e.gatewayAdapters:[]}}async function _(){let e=await fetch("/api/plugins");if(!e.ok)throw new Error(`HTTP ${e.status}`);return M(await e.json())}async function z(e,a,t){let i=t==="global"?"global":`bots/${encodeURIComponent(t)}`,g=await fetch(`/api/plugins/${encodeURIComponent(e)}/${i}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})}),l=await g.json().catch(()=>({}));if(!g.ok)throw new Error(typeof l?.error=="string"?l.error:`HTTP ${g.status}`);return M(l)}async function Q(e,a){let t=await fetch(`/api/plugins/${encodeURIComponent(e)}/pin`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({pinned:a})});if(!t.ok)throw new Error(`HTTP ${t.status}`);return M(await t.json())}async function A(e,a){let t=await fetch(`/api/plugins/${encodeURIComponent(e)}/services/${a}`,{method:"POST"});if(!t.ok)throw new Error(`HTTP ${t.status}`);return M(await t.json())}function k(e){return e.values?.length?(0,n.jsx)(n.Fragment,{children:e.values.map(a=>(0,n.jsx)("span",{className:"plugin-chip",children:a},a))}):(0,n.jsx)("span",{className:"plugin-muted",children:"-"})}function y(e){return(0,n.jsx)("code",{className:"plugin-inline-code",children:e.children})}function N(e){return e.rows.length===0?(0,n.jsx)("div",{className:"plugin-empty-state",children:"\u6682\u65E0\u5185\u5BB9"}):(0,n.jsx)("div",{className:"plugin-info-table",children:e.rows.map((a,t)=>(0,n.jsxs)("div",{className:"plugin-info-row",children:[(0,n.jsx)("span",{children:a.label}),(0,n.jsx)("div",{children:a.content})]},`${a.label}:${t}`))})}function C(e){return(0,n.jsxs)("div",{className:"plugin-tab-panel-head",children:[(0,n.jsx)("h3",{children:e.title}),(0,n.jsx)("p",{children:e.description})]})}function T(e){return(0,n.jsx)("div",{className:"plugin-empty-state",children:e.children})}function j(e){return e?e.status||e.action:"unknown"}function B(e){let a=j(e);return a==="online"||a==="started"||a==="already-running"?"\u8FD0\u884C\u4E2D":a==="stopped"||a==="not-running"?"\u5DF2\u505C\u6B62":a==="failed"?"\u5F02\u5E38":"\u672A\u77E5"}function Y(e){return e.mode==="manual"?"\u4E0D\u968F botmux start/stop/restart \u81EA\u52A8\u5F00\u5173\uFF1B\u4ECD\u53EF\u5728\u8FD9\u91CC\u624B\u52A8\u542F\u52A8\u3001\u505C\u6B62\u3001\u91CD\u542F":e.mode==="auto"?"botmux start/restart \u540E\u81EA\u52A8\u786E\u4FDD\u8FD0\u884C\uFF1B\u9ED8\u8BA4 restart \u4E0D\u5148\u505C\u6B62\uFF0C--with-plugin \u624D\u4F1A\u5148\u505C\u518D\u542F\u52A8":"\u672A\u77E5\u751F\u547D\u5468\u671F\u7B56\u7565"}function J(e){return e.mode==="manual"?"\u624B\u52A8\u5F00\u5173":e.mode==="auto"?"\u542F\u52A8\u540E\u786E\u4FDD\u8FD0\u884C":"\u672A\u77E5\u6A21\u5F0F"}function X(e){let a=j(e);return a==="online"||a==="started"||a==="already-running"?"plugin-status-ok":a==="stopped"||a==="not-running"?"plugin-status-idle":a==="failed"?"plugin-status-bad":"plugin-status-muted"}function I(e){return e.url?(0,n.jsx)("a",{className:`plugin-link${e.health?"":" plugin-service-url"}`,href:e.url,target:"_blank",rel:"noreferrer",children:e.health?"\u5065\u5EB7\u68C0\u67E5":e.url}):(0,n.jsx)("span",{className:"plugin-muted",children:e.health?"\u65E0\u5065\u5EB7\u68C0\u67E5":"\u6682\u65E0\u8BBF\u95EE\u5730\u5740"})}function Z(e){let{plugin:a}=e;if(!a.service)return(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u9700\u8981\u5355\u72EC\u542F\u52A8\u7684\u540E\u53F0\u8FDB\u7A0B\u3002"});let t=a.serviceReport,i=[{label:"\u72B6\u6001",content:(0,n.jsx)("span",{className:`plugin-status ${X(t)}`,children:B(t)})},{label:"\u6A21\u5F0F",content:(0,n.jsx)(k,{values:[J(a.service)]})},{label:"\u751F\u547D\u5468\u671F",content:(0,n.jsx)("span",{children:Y(a.service)})},{label:"\u7AEF\u53E3",content:t?.port?(0,n.jsx)(y,{children:t.port}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u4E0A\u62A5"})},{label:"PID",content:t?.pid?(0,n.jsx)(y,{children:t.pid}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u4E0A\u62A5"})},{label:"\u8BBF\u95EE\u5730\u5740",content:(0,n.jsx)(I,{url:t?.openUrl})},{label:"\u5065\u5EB7\u68C0\u67E5",content:(0,n.jsx)(I,{url:t?.healthUrl,health:!0})}];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(N,{rows:i}),t?.warning?(0,n.jsx)("div",{className:"plugin-warning",children:t.warning}):null]})}function nn(e){let{plugin:a}=e;if(!a.service)return null;let t=a.serviceReport;return(0,n.jsxs)("section",{className:"plugin-action-group",children:[(0,n.jsxs)("div",{className:"plugin-action-head",children:[(0,n.jsx)("span",{children:"Service"}),(0,n.jsx)("strong",{children:J(a.service)}),(0,n.jsx)("span",{className:`plugin-status ${X(t)}`,children:B(t)})]}),(0,n.jsxs)("div",{className:"plugin-action-meta",children:[t?.port?(0,n.jsxs)("span",{children:["\u7AEF\u53E3 ",t.port]}):null,t?.pid?(0,n.jsxs)("span",{children:["PID ",t.pid]}):null,(0,n.jsx)(I,{url:t?.openUrl})]}),(0,n.jsx)("div",{className:"plugin-service-actions",children:["start","stop","restart"].map(i=>(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-service":a.id,"data-action":i,disabled:e.busy,onClick:()=>e.onAction(i),children:i==="start"?"\u542F\u52A8":i==="stop"?"\u505C\u6B62":"\u91CD\u542F"},i))})]})}function en(e){let a=e.plugin.dashboard??[];return a.length===0?null:(0,n.jsxs)("section",{className:"plugin-action-group",children:[(0,n.jsxs)("div",{className:"plugin-action-head",children:[(0,n.jsx)("span",{children:"Dashboard"}),(0,n.jsxs)("strong",{children:[a.length," \u4E2A\u9875\u9762"]})]}),(0,n.jsx)("div",{className:"plugin-action-links",children:a.map(t=>(0,n.jsxs)("a",{className:"btn-link primary",href:t.route,children:["\u6253\u5F00 ",t.id]},t.id))})]})}function an(e){let a=!!e.plugin.service,t=(e.plugin.dashboard?.length??0)>0;return!a&&!t?null:(0,n.jsxs)("div",{className:"plugin-action-area","aria-label":`${e.plugin.id} \u63D2\u4EF6\u64CD\u4F5C`,children:[(0,n.jsxs)("div",{className:"plugin-action-title",children:[(0,n.jsx)("span",{children:"\u64CD\u4F5C"}),(0,n.jsx)("small",{children:"\u56FA\u5B9A\u64CD\u4F5C\u533A\uFF0C\u4E0B\u9762\u7684 tab \u53EA\u5C55\u793A\u4FE1\u606F"})]}),(0,n.jsxs)("div",{className:"plugin-action-grid",children:[(0,n.jsx)(nn,{plugin:e.plugin,busy:e.busy,onAction:e.onServiceAction}),(0,n.jsx)(en,{plugin:e.plugin})]})]})}function R(e){return(0,n.jsx)("section",{className:`plugin-tab-panel${e.active?" is-active":""}`,role:"tabpanel","data-plugin-panel":e.id,children:e.children})}function tn(e){let t=(e.plugin.contributions?.skills??[]).map(i=>({label:i.name||i.path||"skill",content:i.path?(0,n.jsx)(y,{children:i.path}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u58F0\u660E\u8DEF\u5F84"})}));return(0,n.jsxs)(R,{id:"skills",active:e.active,children:[(0,n.jsx)(C,{title:"Skills",description:"\u6BCF\u6B21\u771F\u6B63\u542F\u52A8\u6216\u91CD\u542F CLI \u8FDB\u7A0B\u65F6\uFF0C\u90FD\u4F1A\u6309\u5F53\u524D Bot \u7684\u6709\u6548\u63D2\u4EF6\u96C6\u5237\u65B0\u8FD9\u4E9B\u6280\u80FD\uFF1B\u8FD0\u884C\u4E2D\u7684 CLI \u4E0D\u70ED\u66F4\u65B0\u3002"}),t.length>0?(0,n.jsx)(N,{rows:t}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B Skills\u3002"})]})}function ln(e){let a=e.plugin,t=a.contributions?.mcp,i=t?[{label:t.name||"mcp",content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u4F20\u8F93"}),(0,n.jsx)(k,{values:[t.transport||"stdio"]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u8FD0\u884C\u914D\u7F6E"}),(0,n.jsx)(k,{values:["\u53D7\u4FDD\u62A4\uFF0C\u7531 Gateway \u6309\u4F1A\u8BDD\u52A0\u8F7D"]})]})]})}]:[],g=(a.gatewayAdapters??[]).map(s=>({label:s.cliId,content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"Gateway"}),(0,n.jsx)(k,{values:[s.state==="configured"||s.state==="unchanged"||s.state==="installed"?"\u5DF2\u63A5\u5165":s.state==="adapter-required"?"\u5F85\u9002\u914D":"\u672A\u5199\u5165"]})]}),s.configPath?(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u914D\u7F6E\u76EE\u6807"}),(0,n.jsx)(y,{children:s.configPath})]}):null,s.warning?(0,n.jsx)("div",{className:"plugin-warning",children:s.warning}):null]})})),l=(a.mcpDiagnostics??[]).map(s=>({label:s.serverName,content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u6700\u8FD1\u8FDE\u63A5"}),(0,n.jsx)(k,{values:[s.status==="connected"?"\u6B63\u5E38":"\u5931\u8D25",s.transport]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u80FD\u529B\u6570\u91CF"}),(0,n.jsx)(k,{values:[`Tools ${s.tools??0}`,`Prompts ${s.prompts??0}`,`Resources ${s.resources??0}`]})]}),s.sessionId?(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u4F1A\u8BDD"}),(0,n.jsx)(y,{children:s.sessionId})]}):null,s.error?(0,n.jsx)("div",{className:"plugin-warning",children:s.error}):null]})}));return(0,n.jsxs)(R,{id:"mcp",active:e.active,children:[(0,n.jsx)(C,{title:"MCP",description:"CLI \u53EA\u8FDE\u63A5\u4E00\u4E2A Botmux Gateway\uFF1B\u6BCF\u4E00\u4EE3 CLI \u8FDB\u7A0B\u6309\u542F\u52A8\u65F6\u6E05\u5355\u8FDE\u63A5\u8FD9\u4E9B\u4E0B\u6E38 MCP\u3002"}),g.length>0?(0,n.jsx)(N,{rows:g}):null,l.length>0?(0,n.jsx)(N,{rows:l}):null,i.length>0?(0,n.jsx)(N,{rows:i}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B MCP server\u3002"})]})}function sn(e){let a=e.plugin.contributions?.cli,t=[...a?.entry?[{label:"\u5165\u53E3\u6587\u4EF6",content:(0,n.jsx)(y,{children:a.entry})}]:[],...(a?.commands??[]).map(i=>({label:i.name,content:i.description?(0,n.jsx)("span",{children:i.description}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u65E0\u63CF\u8FF0"})}))];return(0,n.jsxs)(R,{id:"cli",active:e.active,children:[(0,n.jsx)(C,{title:"CLI \u547D\u4EE4",description:"\u542F\u7528\u63D2\u4EF6\u540E\uFF0C\u8FD9\u4E9B\u547D\u4EE4\u4F1A\u8FDB\u5165 botmux \u7684\u547D\u4EE4\u8DEF\u7531\u3002"}),t.length>0?(0,n.jsx)(N,{rows:t}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B CLI \u547D\u4EE4\u3002"})]})}function on(e){let a=(e.plugin.dashboard??[]).map(t=>({label:t.id,content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u8DEF\u7531"}),(0,n.jsx)(y,{children:t.route})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u5165\u53E3"}),(0,n.jsx)(y,{children:t.entry})]})]})}));return(0,n.jsxs)(R,{id:"dashboard",active:e.active,children:[(0,n.jsx)(C,{title:"Dashboard",description:"\u63D2\u4EF6\u81EA\u5DF1\u7684\u53EF\u89C6\u5316\u9875\u9762\u4F1A\u5728\u8FD9\u91CC\u66B4\u9732\u5165\u53E3\u3002"}),a.length>0?(0,n.jsx)(N,{rows:a}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B Dashboard \u9875\u9762\u3002"})]})}function rn(e){return(0,n.jsxs)(R,{id:"service",active:e.active,children:[(0,n.jsx)(C,{title:"Service",description:"\u63D2\u4EF6\u540E\u53F0\u670D\u52A1\u7684\u58F0\u660E\u3001\u5F53\u524D\u72B6\u6001\u548C\u8BBF\u95EE\u5730\u5740\u3002\u542F\u52A8\u3001\u505C\u6B62\u3001\u91CD\u542F\u5728\u4E0A\u65B9\u64CD\u4F5C\u533A\u5904\u7406\u3002"}),(0,n.jsx)(Z,{plugin:e.plugin})]})}function cn(e){let a=e.plugin.contributions?.cli?.commands??[],t=(0,r.useMemo)(()=>[{id:"skills",label:"Skills",count:e.plugin.skillsCount??0,hint:"\u4F1A\u8BDD\u52A0\u8F7D"},{id:"mcp",label:"MCP",count:e.plugin.mcpCount??0,hint:"Gateway \u805A\u5408"},{id:"cli",label:"CLI \u547D\u4EE4",count:a.length,hint:"\u547D\u4EE4\u8DEF\u7531"},{id:"dashboard",label:"Dashboard",count:e.plugin.dashboard?.length??0,hint:"\u9875\u9762\u5165\u53E3"},{id:"service",label:"Service",count:e.plugin.service?1:0,hint:e.plugin.service?J(e.plugin.service):"\u65E0\u540E\u53F0\u8FDB\u7A0B"}],[a.length,e.plugin.dashboard?.length,e.plugin.mcpCount,e.plugin.service,e.plugin.skillsCount]),[i,g]=(0,r.useState)(()=>t.find(l=>l.count>0)?.id??"skills");return(0,n.jsxs)("div",{className:"plugin-tabs",children:[(0,n.jsx)("div",{className:"plugin-tab-list",role:"tablist","aria-label":`${e.plugin.id} \u63D2\u4EF6\u80FD\u529B`,children:t.map(l=>(0,n.jsxs)("button",{type:"button",className:`plugin-tab-button${i===l.id?" is-active":""}`,role:"tab","aria-selected":i===l.id,"data-plugin-tab":l.id,onClick:()=>g(l.id),children:[(0,n.jsx)("strong",{children:l.count}),(0,n.jsx)("span",{children:l.label}),(0,n.jsx)("small",{children:l.hint})]},l.id))}),(0,n.jsxs)("div",{className:"plugin-tab-panels",children:[(0,n.jsx)(tn,{plugin:e.plugin,active:i==="skills"}),(0,n.jsx)(ln,{plugin:e.plugin,active:i==="mcp"}),(0,n.jsx)(sn,{plugin:e.plugin,active:i==="cli"}),(0,n.jsx)(on,{plugin:e.plugin,active:i==="dashboard"}),(0,n.jsx)(rn,{plugin:e.plugin,active:i==="service"})]})]})}function x(e,a){return`${e}:${a}`}function w(e,a,t){let i=t.get(x(e.id,a));return i!==void 0?i:a==="global"?e.enabledGlobal===!0:e.enabledByBot?.[a]===!0}function gn(e){return(0,n.jsxs)("label",{className:"toggle-row plugin-enable-row",children:[(0,n.jsxs)("span",{className:"plugin-enable-copy",children:[(0,n.jsx)("strong",{children:e.label}),(0,n.jsx)("small",{children:e.hint})]}),(0,n.jsx)("input",{type:"checkbox","data-plugin-toggle":e.scope,"data-plugin-id":e.plugin.id,checked:e.checked,disabled:e.busy,onChange:a=>e.onToggle(e.scope,a.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"})]})}function un(e){let a=w(e.plugin,"global",e.pendingToggles);return(0,n.jsxs)("label",{className:"toggle-row plugin-global-setting",children:[(0,n.jsxs)("span",{className:"plugin-global-setting-copy",children:[(0,n.jsx)("strong",{children:"\u5168\u5C40\u542F\u7528"}),(0,n.jsx)("small",{children:a?`\u5DF2\u5BF9\u5168\u90E8 ${e.bots.length} \u4E2A Bot \u542F\u7528`:"\u5173\u95ED\u65F6\u53EF\u5C55\u5F00\u5361\u7247\uFF0C\u6309 Bot \u5355\u72EC\u542F\u7528"})]}),(0,n.jsx)("input",{type:"checkbox","data-plugin-toggle":"global","data-plugin-id":e.plugin.id,checked:a,disabled:e.busy,onChange:t=>e.onToggle("global",t.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"})]})}function dn(e){let{plugin:a,bots:t,pendingToggles:i}=e,g=t.filter(l=>w(a,l.id,i)).length;return(0,n.jsxs)("section",{className:"plugin-enable-panel","aria-label":`${a.displayName||a.id} \u6309 Bot \u542F\u7528`,children:[(0,n.jsxs)("div",{className:"plugin-enable-panel-head",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"\u6309 Bot \u542F\u7528"}),(0,n.jsx)("small",{children:"\u5168\u5C40\u5173\u95ED\u65F6\uFF0C\u53EF\u4E3A\u9700\u8981\u6B64\u63D2\u4EF6\u7684 Bot \u5355\u72EC\u5F00\u542F\uFF1B\u65B0\u542F\u52A8\u7684 CLI \u4F1A\u8BDD\u751F\u6548\u3002"})]}),(0,n.jsxs)("span",{children:[g,"/",t.length," \u4E2A Bot \u5DF2\u542F\u7528"]})]}),(0,n.jsxs)("div",{className:"plugin-enable-list",children:[t.map(l=>{let s=w(a,l.id,i),p=s?"\u5DF2\u542F\u7528":"\u672A\u542F\u7528";return(0,n.jsx)(gn,{plugin:a,scope:l.id,label:l.name,hint:`\u5F53\u524D${p}`,checked:s,busy:e.busy,onToggle:e.onToggle},l.id)}),t.length===0?(0,n.jsx)("div",{className:"plugin-enable-empty",children:"\u6682\u65E0\u5DF2\u914D\u7F6E Bot"}):null]})]})}function pn(e){let a=e.plugin.contributions?.cli?.commands??[],t=[{label:"Skills",count:e.plugin.skillsCount??0},{label:"MCP",count:e.plugin.mcpCount??0},{label:"\u547D\u4EE4",count:a.length},{label:"Dashboard",count:e.plugin.dashboard?.length??0}].filter(i=>i.count>0);return(0,n.jsxs)("div",{className:"plugin-card-summary",children:[(0,n.jsxs)("div",{className:"plugin-capability-summary","aria-label":"\u63D2\u4EF6\u80FD\u529B\u6458\u8981",children:[t.map(i=>(0,n.jsxs)("span",{className:"plugin-capability-chip",children:[(0,n.jsx)("strong",{children:i.count}),i.label]},i.label)),e.plugin.service?(0,n.jsxs)("span",{className:`plugin-capability-chip ${X(e.plugin.serviceReport)}`,children:["Service ",B(e.plugin.serviceReport)]}):null,t.length===0&&!e.plugin.service?(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u58F0\u660E\u6269\u5C55\u80FD\u529B"}):null]}),(0,n.jsx)("span",{className:"plugin-scope-summary",children:e.globalEnabled?`\u5168\u90E8 ${e.botCount} \u4E2A Bot`:`${e.enabledBotCount}/${e.botCount} \u4E2A Bot \u5355\u72EC\u542F\u7528`})]})}function bn(e){let a=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let t=a.current;if(t)if(e.feedback&&!t.open)try{t.showModal()}catch{t.setAttribute("open","")}else!e.feedback&&t.open&&t.close()},[e.feedback]),(0,n.jsx)("dialog",{className:"plugin-feedback-dialog","data-plugin-feedback-dialog":!0,ref:a,onClose:e.onClose,onClick:t=>{t.target===t.currentTarget&&e.onClose()},children:(0,n.jsxs)("article",{children:[(0,n.jsxs)("header",{children:[(0,n.jsx)("span",{className:"plugin-feedback-mark","aria-hidden":"true",children:"!"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{children:"\u63D2\u4EF6\u8BBE\u7F6E\u672A\u4FDD\u5B58"}),(0,n.jsx)("h2",{"data-plugin-feedback-title":!0,children:e.feedback?.title??"\u64CD\u4F5C\u5931\u8D25"})]})]}),(0,n.jsx)("p",{className:"plugin-feedback-message","data-plugin-feedback-message":!0,children:e.feedback?.message}),(0,n.jsx)("footer",{children:(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-feedback-close":!0,onClick:e.onClose,children:"\u77E5\u9053\u4E86"})})]})})}function mn(e){let{plugin:a}=e,[t,i]=(0,r.useState)(!1),g=a.displayName||a.id,l=a.dependencies??[],s=w(a,"global",e.pendingToggles),p=e.bots.filter(d=>w(a,d.id,e.pendingToggles)).length,S=s||p>0,b=e.pendingToggles.has(x(a.id,"global")),f=(a.dashboard?.length??0)>0,m=e.pendingPin??a.pinnedToSidebar===!0,P=`plugin-details-${a.id}`;return(0,n.jsxs)("article",{className:`bd-card plugin-card${t?" is-expanded":" is-collapsed"}`,"data-plugin-card":a.id,children:[(0,n.jsxs)("header",{className:"plugin-card-head",children:[(0,n.jsxs)("div",{className:"plugin-title-block",children:[(0,n.jsxs)("div",{className:"plugin-title-row",children:[(0,n.jsx)("h2",{children:g}),(0,n.jsx)("span",{className:`plugin-status ${S?"plugin-status-ok":"plugin-status-idle"}`,children:s?"\u5168\u5C40\u5DF2\u542F\u7528":p>0?`${p} \u4E2A Bot \u5DF2\u542F\u7528`:"\u672A\u542F\u7528"})]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("code",{children:a.id}),(0,n.jsxs)("span",{children:[a.packageName,"@",a.version]}),l.length>0?(0,n.jsxs)("span",{children:["\u4F9D\u8D56 ",l.join(", ")]}):null]})]}),(0,n.jsx)("button",{type:"button",className:"btn-link plugin-expand-button","data-plugin-expand":a.id,"aria-expanded":t,"aria-controls":P,onClick:()=>i(d=>!d),children:t?"\u6536\u8D77\u8BE6\u60C5":"\u5C55\u5F00\u8BE6\u60C5"})]}),(0,n.jsx)(un,{plugin:a,bots:e.bots,pendingToggles:e.pendingToggles,busy:e.busy,onToggle:e.onToggle}),(0,n.jsx)(pn,{plugin:a,globalEnabled:s,enabledBotCount:p,botCount:e.bots.length}),t?(0,n.jsxs)("div",{className:"plugin-card-expanded",id:P,children:[!s&&!b?(0,n.jsx)(dn,{plugin:a,bots:e.bots,pendingToggles:e.pendingToggles,busy:e.busy,onToggle:e.onToggle}):null,b?(0,n.jsx)("div",{className:"plugin-settings-pending",children:"\u6B63\u5728\u66F4\u65B0\u5168\u5C40\u8BBE\u7F6E..."}):null,f?(0,n.jsx)("div",{className:"plugin-card-controls",children:(0,n.jsxs)("label",{className:"toggle-row plugin-pin-toggle",children:[(0,n.jsx)("input",{type:"checkbox","data-plugin-pin":a.id,checked:m,disabled:e.busy,onChange:d=>e.onPin(d.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch"}),(0,n.jsxs)("span",{className:"toggle-tx",children:[(0,n.jsx)("strong",{children:"Pin \u5230\u4FA7\u680F"}),(0,n.jsx)("small",{children:m?"\u5DF2\u56FA\u5B9A\uFF0C\u53EF\u4ECE\u4E3B\u83DC\u5355\u5FEB\u901F\u6253\u5F00":"\u56FA\u5B9A\u540E\u53EF\u4ECE\u4E3B\u83DC\u5355\u5FEB\u901F\u6253\u5F00"})]})]})}):null,(0,n.jsx)(an,{plugin:a,busy:e.busy,onServiceAction:e.onServiceAction}),(0,n.jsx)("div",{className:"plugin-card-body",children:(0,n.jsx)(cn,{plugin:a})})]}):null]})}function E(e,a,t){let i=new Map(e);return t===void 0?i.delete(a):i.set(a,t),i}function vn(e,a,t){let i=new Set(e);return t?i.add(a):i.delete(a),i}function hn(){let[e,a]=(0,r.useState)(null),[t,i]=(0,r.useState)(null),[g,l]=(0,r.useState)(!1),[s,p]=(0,r.useState)(()=>new Set),[S,b]=(0,r.useState)(()=>new Map),[f,m]=(0,r.useState)(()=>new Map),[P,d]=(0,r.useState)(null),D=(0,r.useCallback)(async()=>{l(!0),i(null);try{a(await _())}catch(o){i(o instanceof Error?o.message:String(o))}finally{l(!1)}},[]);(0,r.useEffect)(()=>{D()},[D]);let v=(0,r.useCallback)((o,u)=>{p(c=>vn(c,o,u))},[]),F=(0,r.useCallback)(async(o,u,c)=>{let L=x(o,u);b(h=>E(h,L,c)),v(o,!0);try{let h=await z(o,c,u);a(h)}catch(h){d({title:c?"\u65E0\u6CD5\u542F\u7528\u63D2\u4EF6":"\u65E0\u6CD5\u7981\u7528\u63D2\u4EF6",message:h instanceof Error?h.message:String(h)})}finally{b(h=>E(h,L,void 0)),v(o,!1)}},[v]),K=(0,r.useCallback)(async(o,u)=>{m(c=>E(c,o,u)),v(o,!0);try{let c=await Q(o,u);a(c),window.dispatchEvent(new Event(H))}catch(c){d({title:"\u65E0\u6CD5\u66F4\u65B0\u4FA7\u680F\u56FA\u5B9A",message:c instanceof Error?c.message:String(c)})}finally{m(c=>E(c,o,void 0)),v(o,!1)}},[v]),V=(0,r.useCallback)(async(o,u)=>{v(o,!0);try{let c=await A(o,u);a(c)}catch(c){d({title:"Service \u64CD\u4F5C\u5931\u8D25",message:c instanceof Error?c.message:String(c)})}finally{v(o,!1)}},[v]);if(!e&&!t)return(0,n.jsx)("section",{className:"page",children:(0,n.jsx)("div",{className:"empty",children:"Loading plugins..."})});if(!e)return(0,n.jsx)("section",{className:"page",children:(0,n.jsxs)("div",{className:"bd-card empty",children:["\u63D2\u4EF6\u5217\u8868\u52A0\u8F7D\u5931\u8D25\uFF1A",t]})});let O=e.plugins.filter(o=>w(o,"global",S)).length;return(0,n.jsxs)("section",{className:"page plugin-management-page",children:[(0,n.jsxs)("div",{className:"page-heading",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{children:"\u63D2\u4EF6"}),(0,n.jsx)("p",{children:"\u5361\u7247\u9ED8\u8BA4\u5C55\u793A\u542F\u7528\u8303\u56F4\u4E0E\u80FD\u529B\u6458\u8981\uFF1B\u5C55\u5F00\u540E\u53EF\u7BA1\u7406\u5355\u4E2A Bot\u3001Service \u548C\u8BE6\u7EC6\u80FD\u529B\u3002\u5168\u5C40\u542F\u7528\u5BF9\u6240\u6709 Bot \u751F\u6548\uFF0C\u6539\u52A8\u5728\u65B0\u542F\u52A8\u7684 CLI \u4F1A\u8BDD\u4E2D\u751F\u6548\u3002"})]}),(0,n.jsx)("div",{className:"plugin-heading-actions",children:(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-refresh":!0,disabled:g,onClick:()=>{D()},children:g?"\u5237\u65B0\u4E2D...":"\u5237\u65B0"})})]}),(0,n.jsxs)("div",{className:"plugin-summary-grid",children:[(0,n.jsxs)("div",{className:"bd-card plugin-summary-card",children:[(0,n.jsx)("span",{children:"\u5DF2\u5B89\u88C5"}),(0,n.jsx)("strong",{children:e.plugins.length})]}),(0,n.jsxs)("div",{className:"bd-card plugin-summary-card",children:[(0,n.jsx)("span",{children:"\u5168\u5C40\u542F\u7528"}),(0,n.jsx)("strong",{"data-plugin-summary-enabled":!0,children:O})]})]}),e.plugins.length===0?(0,n.jsxs)("div",{className:"bd-card empty",children:["\u6682\u65E0\u5DF2\u5B89\u88C5\u63D2\u4EF6\u3002\u7528 ",(0,n.jsx)("code",{children:"botmux plugin install"})," \u5B89\u88C5\u540E\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002"]}):(0,n.jsx)("div",{className:"plugin-card-list",children:e.plugins.map(o=>(0,n.jsx)(mn,{plugin:o,bots:e.bots,pendingToggles:S,pendingPin:f.get(o.id),busy:s.has(o.id),onToggle:(u,c)=>{F(o.id,u,c)},onPin:u=>{K(o.id,u)},onServiceAction:u=>{V(o.id,u)}},o.id))}),(0,n.jsx)(bn,{feedback:P,onClose:()=>d(null)})]})}function fn(e){return{async getServiceStatus(){return(await _()).plugins.find(t=>t.id===e)?.serviceReport},async startService(){return A(e,"start")},async stopService(){return A(e,"stop")},async restartService(){return A(e,"restart")}}}function yn(e){let[a,t]=(0,r.useState)(null),[i,g]=(0,r.useState)(null),[l,s]=(0,r.useState)(null);(0,r.useEffect)(()=>{let b=!1;return t(null),g(null),s(null),(async()=>{try{let m=(await q()).find(d=>e.hash===d.route||e.hash.startsWith(`${d.route}/`)||e.hash.startsWith(`${d.route}?`));if(!m)throw new Error(`Plugin page not found: ${e.hash}`);let P=await import(m.url);if(typeof P.default!="function")throw new Error("plugin_dashboard_default_export_not_function");if(b)return;t(m),g(()=>P.default)}catch(f){b||s(f instanceof Error?f.message:String(f))}})(),()=>{b=!0}},[e.hash]);let p=(0,r.useMemo)(()=>a?fn(a.pluginId):null,[a]);if(l)return(0,n.jsx)("section",{className:"page",children:(0,n.jsxs)("div",{className:"bd-card empty",children:["\u63D2\u4EF6 Dashboard \u52A0\u8F7D\u5931\u8D25\uFF1A",l]})});if(!a||!i||!p)return(0,n.jsx)("section",{className:"page",children:(0,n.jsx)("div",{className:"empty",children:"Loading plugin..."})});let S=a.displayName||a.pluginId;return(0,n.jsx)("section",{className:"page plugin-page",children:(0,n.jsxs)("div",{className:"plugin-dashboard-shell",children:[(0,n.jsx)("div",{className:"plugin-dashboard-toolbar",children:(0,n.jsx)("a",{className:"btn-link plugin-dashboard-back",href:"#/plugins",children:"\u8FD4\u56DE\u63D2\u4EF6\u5217\u8868"})}),(0,n.jsx)("div",{className:"page-heading plugin-dashboard-heading",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"plugin-dashboard-kicker",children:"Plugin Dashboard"}),(0,n.jsx)("h1",{children:S}),(0,n.jsxs)("p",{children:[(0,n.jsx)("code",{children:a.pluginId}),(0,n.jsx)("span",{children:"/"}),(0,n.jsx)("code",{children:a.id})]})]})}),(0,n.jsx)("div",{className:"plugin-dashboard-content","data-plugin-dashboard-root":!0,children:(0,n.jsx)(i,{pluginId:a.pluginId,api:p})})]})})}function Pn(){let e=location.hash||"#/plugins";return e==="#/plugins"||e.startsWith("#/plugins?")?(0,n.jsx)(hn,{}):(0,n.jsx)(yn,{hash:e})}function kn(e){return G(e,(0,n.jsx)(Pn,{}))}export{kn as renderPluginPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Gt,b as Ft,c as $t,d as Ot}from"./chunk-R3FXBFQH.js";import{c as Dt}from"./chunk-2WQDS65D.js";import{b as Bt,c as ce,h as $e,q as Oe}from"./chunk-5CJMHTT4.js";import"./chunk-G5XGBCM6.js";import{B as At,x as Et}from"./chunk-Q2MT4VWH.js";import{a as Fe}from"./chunk-SYC6D5XU.js";import{a as bn,d as _t}from"./chunk-5THX4DI2.js";import{c as Ge}from"./chunk-7SZRL6FY.js";var a=Ge(bn(),1);function jt(t,n){let r=n.trim().toLowerCase();return r?t.filter(o=>o.openId.toLowerCase().includes(r)||o.name.toLowerCase().includes(r)||o.memberType.toLowerCase().includes(r)):t}function Ut(t){return[...new Set([...t].filter(Boolean))]}function Ht(t){let n=new Set(t.targetIds.filter(Boolean));if(t.mode==="all_except_excluded"){let o=new Set(t.exclude);for(let c of n)o.delete(c),t.listening||o.add(c);return{include:[],exclude:Ut(o)}}let r=new Set(t.include);for(let o of n)r.delete(o),t.listening&&r.add(o);return{include:Ut(r),exclude:[]}}function Ue(t){let n=t.targetIds.filter(Boolean);if(n.length===0)return t.mode==="all_except_excluded"?"listen":"ignore";let r=new Set;if(t.mode==="all_except_excluded"){let o=new Set(t.exclude);for(let c of n)r.add(o.has(c)?"ignore":"listen")}else{let o=new Set(t.include);for(let c of n)r.add(o.has(c)?"listen":"ignore")}return r.size===1?[...r][0]:"mixed"}function Vt(t,n,r){let o={};for(let c of t){if(!c)continue;let m=n(c),f=m==="user"||m==="bot"?m:r?.[c];(f==="user"||f==="bot")&&(o[c]=f)}return o}var O=32768,qt=Math.floor(O*.95),pe=32768,Kt=Math.floor(pe*.95),je=5,He=20,hn=/^[A-Za-z0-9._-]{1,64}$/;function Ve(t){return hn.test(t)&&t!=="."&&t!==".."}function Wt(t=location.hash){let[,n=""]=t.split("?");return new URLSearchParams(n).get("chatId")?.trim()||null}function qe(t,n){return $t(t,n)}function we(t){return new TextEncoder().encode(t).length}function Yt(t){return t.memberBots.filter(n=>n.inChat&&n.hasRole).length}function zt(t){return t.memberBots.filter(n=>n.inChat).length}function me(t,n){return n?t.find(r=>r.larkAppId===n):void 0}function Jt(t,n){let r=n.toLowerCase();return r?t.filter(o=>{let c=o.chatId.toLowerCase().includes(r)||(o.name??"").toLowerCase().includes(r),m=o.memberBots.some(f=>f.larkAppId.toLowerCase().includes(r)||(f.botName??"").toLowerCase().includes(r));return c||m}):t}function Xt(t,n){let r=n.toLowerCase();return t.filter(o=>!r||o.profileId.toLowerCase().includes(r))}async function x(t){return t.json().catch(()=>({}))}async function Qt(){let t=await fetch("/api/groups"),n=await x(t);return{bots:(n.bots??[]).map(r=>({larkAppId:r.larkAppId,botName:r.botName??r.larkAppId,botAvatarUrl:r.botAvatarUrl})),groups:(n.chats??[]).map(r=>({chatId:r.chatId,name:r.name??r.chatId,memberBots:(r.memberBots??[]).map(o=>({larkAppId:o.larkAppId,botName:o.botName??o.larkAppId,inChat:o.inChat??!1,hasRole:o.hasRole??!1,hasMessageListener:o.hasMessageListener??!1,oncallChat:o.oncallChat??null}))}))}}async function Zt(){let t=await fetch("/api/role-profiles");return(await x(t)).profiles??[]}async function q(t){let n=await fetch(`/api/role-profiles/${encodeURIComponent(t)}`);return(await x(n)).entries??[]}async function Ke(t,n){let r=await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return x(r)}async function er(t,n,r,o,c){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:r,injectMode:o,dispatchCompletionEnabled:c})})).ok}async function tr(t,n,r){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({injectMode:r})})).ok}async function rr(t,n,r){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({dispatchCompletionEnabled:r})})).ok}async function nr(t,n){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}async function We(t,n){let r=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return(await x(r)).listener??{enabled:!1,prompt:"",messagePolicy:{scope:"top_level"}}}async function sr(t,n,r){return(await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(r)})).ok}async function or(t,n){return(await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}function Se(t){return Number.isFinite(t)?Math.min(He,Math.max(1,Math.floor(t))):je}function ue(t){return String(t).padStart(2,"0")}function lr(t){if(!t)return"";let n=Number(t);if(!Number.isFinite(n)||n<=0)return"";let r=n<1e12?n*1e3:n,o=new Date(r);return Number.isFinite(o.getTime())?[o.getFullYear(),"-",ue(o.getMonth()+1),"-",ue(o.getDate())," ",ue(o.getHours()),":",ue(o.getMinutes()),":",ue(o.getSeconds())].join(""):""}async function ir(t,n,r,o){let c=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({listener:r,limit:Se(o)})}),m=await x(c);return{ok:c.ok&&m.ok!==!1,requestedLimit:m.requestedLimit??Se(o),matches:m.matches??[],error:m.error}}async function ar(t,n,r,o){let c=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/run-preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({listener:r,limit:Se(o)})}),m=await x(c);return{ok:c.ok&&m.ok!==!1,requestedLimit:m.requestedLimit??Se(o),matches:m.matches??[],results:m.results,error:m.error}}async function dr(t,n,r){let o=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/run-preview/${encodeURIComponent(r)}`),c=await x(o);return{ok:o.ok&&c.ok!==!1,runId:c.runId,results:c.results,error:c.error}}async function cr(t,n){let r=await fetch(`/api/groups/${encodeURIComponent(t)}/${encodeURIComponent(n)}/members-display`);return(await x(r)).members??[]}async function ur(t,n){let r=await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return x(r)}async function pr(t,n,r){return(await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:r,allowEmpty:!0})})).ok}async function mr(t,n){return(await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}async function fr(t,n){let r=await Promise.all(n.map(async f=>{try{let p=await fetch(`/api/role-profiles/${encodeURIComponent(f.profileId)}`),v=await x(p);return[f.profileId,Array.isArray(v.entries)?v.entries:[]]}catch{return[f.profileId,[]]}})),o=new Set,c=[];for(let f of t)for(let p of f.memberBots){if(!p.inChat||!p.hasRole)continue;let v=qe(p.larkAppId,f.chatId);o.has(v)||(o.add(v),c.push({larkAppId:p.larkAppId,chatId:f.chatId}))}let m=await Ot(c);return{entriesByProfile:new Map(r),effectiveRolesByBot:m}}async function gr(t){let n=await fetch(`/api/role-profiles/${encodeURIComponent(t.profileId)}/apply`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({chatId:t.chatId,larkAppId:t.larkAppId,force:t.force,preview:t.preview})}),r=await x(n);return{larkAppId:t.larkAppId,ok:n.ok&&r.ok!==!1,status:n.status,error:r.error,wouldRefuse:r.wouldRefuse}}var e=Ge(_t(),1),hr=["text","post","image","interactive"],K={enabled:!1,prompt:"",senderPolicy:{mode:"include_only",includeSenderTypes:["user"],excludeSelf:!0},messagePolicy:{includeMsgTypes:[...hr],scope:"top_level"}};function ze(t){let n=t?.senderPolicy?.mode==="include_only"?"include_only":"all_except_excluded";return{enabled:t?.enabled===!0,name:t?.name??"",replyCardTitle:t?.replyCardTitle??"",workingDir:t?.workingDir??"",prompt:t?.prompt??"",senderPolicy:{mode:n,includeSenderOpenIds:[...t?.senderPolicy?.includeSenderOpenIds??[]],excludeSenderOpenIds:[...t?.senderPolicy?.excludeSenderOpenIds??[]],...t?.senderPolicy?.excludeSenderKinds?{excludeSenderKinds:{...t.senderPolicy.excludeSenderKinds}}:{},includeSenderTypes:[...t?.senderPolicy?.includeSenderTypes??K.senderPolicy?.includeSenderTypes??[]],excludeSenderTypes:[...t?.senderPolicy?.excludeSenderTypes??[]],excludeSelf:t?.senderPolicy?.excludeSelf!==!1},messagePolicy:{includeMsgTypes:[...t?.messagePolicy?.includeMsgTypes??K.messagePolicy?.includeMsgTypes??[]],scope:"top_level"}}}function yr(t){return!!t&&t.prompt.trim().length>0}function Pn(t){return t.memberBots.some(n=>n.inChat&&(n.hasRole||n.hasMessageListener))}function Ye(t,n){return t?.name||n}function In(t,n){let r=new Map;for(let o of t??[])r.set(o.messageId,o);for(let o of n)r.set(o.messageId,{...r.get(o.messageId),...o});return[...r.values()]}function Sn(t,n){return!n||t==="failed"?"error":t==="replied"?"ok":t==="running"?"running":"triggered"}function wn(t,n=[]){return ze(t??K)}function xn(){let t=(0,a.useRef)(!0);return(0,a.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Rn(){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>()=>{for(let n of t.current)window.clearTimeout(n);t.current.clear()},[]),(0,a.useCallback)((n,r)=>{let o=window.setTimeout(()=>{t.current.delete(o),n()},r);return t.current.add(o),o},[])}function Pr(t){return(0,e.jsx)(Bt,{html:Et({name:t.bot.botName,larkAppId:t.bot.larkAppId,avatarUrl:t.bot.botAvatarUrl,size:"sm"})})}function Ir(t){let n=Dt(),r=xn(),o=Rn(),[c,m]=(0,a.useState)([]),[f,p]=(0,a.useState)([]),[v,T]=(0,a.useState)([]),[xe,R]=(0,a.useState)({entriesByProfile:new Map,effectiveRolesByBot:new Map}),[W,A]=(0,a.useState)(!1),[Re,Y]=(0,a.useState)(!0),[ke,_]=(0,a.useState)(!0),[F,k]=(0,a.useState)(""),[z,ge]=(0,a.useState)(""),[U,B]=(0,a.useState)(()=>new Set),[g,ye]=(0,a.useState)(null),[y,J]=(0,a.useState)(null),[d,b]=(0,a.useState)(null),[I,M]=(0,a.useState)(""),[X,Q]=(0,a.useState)("every"),[ve,Z]=(0,a.useState)(!1),[Je,Xe]=(0,a.useState)(!1),[Qe,Ze]=(0,a.useState)(!1),[Sr,et]=(0,a.useState)(!1),[wr,tt]=(0,a.useState)(!1),[xr,Ne]=(0,a.useState)(null),[Rr,rt]=(0,a.useState)(null),[kr,nt]=(0,a.useState)(null),[j,st]=(0,a.useState)("role"),[Nr,Lr]=(0,a.useState)(null),[P,D]=(0,a.useState)(()=>ze(K)),[Le,ot]=(0,a.useState)([]),[Tr,lt]=(0,a.useState)(!1),[Mr,it]=(0,a.useState)(!1),[at,dt]=(0,a.useState)(!1),[Te,ct]=(0,a.useState)(!1),[Cr,G]=(0,a.useState)(null),[Me,Er]=(0,a.useState)(je),[Ar,be]=(0,a.useState)({kind:"idle"}),ee=(0,a.useRef)(null),ut=(0,a.useRef)(0),[S,_r]=(0,a.useState)(null),[C,pt]=(0,a.useState)(null),[te,re]=(0,a.useState)([]),[ne,he]=(0,a.useState)(""),[$,se]=(0,a.useState)(null),[mt,Br]=(0,a.useState)(!1),[ft,gt]=(0,a.useState)(()=>new Set),[yt,vt]=(0,a.useState)(!1),[bt,ht]=(0,a.useState)(!1),[Dr,Ce]=(0,a.useState)(null),[Gr,oe]=(0,a.useState)({kind:"idle"}),H=(0,a.useRef)(0),le=(0,a.useRef)(0),Pt=(0,a.useRef)(null),Ee=g?c.find(s=>s.chatId===g):void 0,Fr=Ee&&y?Ee.memberBots.find(s=>s.larkAppId===y):void 0,Ae=C?f.find(s=>s.larkAppId===C):void 0,$r=me(te,C),_e=$?c.find(s=>s.chatId===$):void 0,Pe=_e?.memberBots.filter(s=>s.inChat)??[],Or=Pe.map(s=>s.larkAppId).join("\0"),Ur=te.map(s=>s.larkAppId).sort().join("\0"),jr=(0,a.useMemo)(()=>Jt(c,F),[c,F]),Hr=(0,a.useMemo)(()=>Xt(v,z),[v,z]),Be=we(I),De=we(ne),It=we(P.prompt),St=(0,a.useMemo)(()=>{let s=new Map;for(let l of Le)s.set(l.openId,l);return s},[Le]),N=(0,a.useCallback)((s,l,i=!1)=>{let u=Date.now()+Math.random();s({text:l,isError:i,id:u}),o(()=>{s(h=>h?.id===u?null:h)},i?3e3:2e3)},[o]),L=(0,a.useCallback)(async(s,l)=>{try{let i=await fr(s,l);if(!r.current)return;R(i),A(!0)}catch{if(!r.current)return;R({entriesByProfile:new Map,effectiveRolesByBot:new Map}),A(!0)}},[r]),E=(0,a.useCallback)(async()=>{let s=await Qt();return r.current&&(m(s.groups),p(s.bots)),s},[r]),ie=(0,a.useCallback)(async()=>{let s=await Zt();return r.current&&T(s),s},[r]),ae=(0,a.useCallback)((s,l=[])=>{let i=wn(s??K,l);Lr(s),D(i)},[]),wt=(0,a.useCallback)(async(s,l,i)=>{lt(!0),it(!0),ot([]);try{let[u,h]=await Promise.all([We(s,l).catch(()=>ze(K)),cr(s,l).catch(()=>[])]);if(!r.current||i!==H.current)return;ae(yr(u)?u:null,h),ot(h),G(null)}finally{r.current&&i===H.current&&(lt(!1),it(!1))}},[r,ae]),xt=(0,a.useCallback)(async()=>{Y(!0),_(!0),A(!1);try{let s=await E();if(!r.current)return;let l=await ie();if(!r.current||(await At(),!r.current))return;if(B(new Set(s.groups.filter(Pn).map(i=>i.chatId))),t.tab==="profiles"){let i=Wt();se(u=>u||(i&&s.groups.some(h=>h.chatId===i)?i:s.groups[0]?.chatId??null))}else se(i=>i??s.groups[0]?.chatId??null);Y(!1),_(!1),L(s.groups,l)}catch{if(!r.current)return;Y(!1),_(!1),A(!0)}},[r,t.tab,E,ie,L]);(0,a.useEffect)(()=>{xt()},[xt]),(0,a.useEffect)(()=>()=>{ut.current+=1,ee.current=null},[]),(0,a.useEffect)(()=>{$||c.length===0||se(c[0].chatId)},[c,$]),(0,a.useEffect)(()=>{let s=new Set(Pe.filter(l=>!!me(te,l.larkAppId)).map(l=>l.larkAppId));gt(s),oe({kind:"idle"})},[Ur,Or]);async function Vr(s,l){let i=++H.current;ye(s),J(l),Ne(null),rt(null),nt(null),G(null),ae(null);let u=await Ke(l,s);!r.current||i!==H.current||(b(u),M(u.content??""),Q(u.injectMode==="once"?"once":"every"),Z(u.dispatchCompletionEnabled===!0),await wt(l,s,i))}async function qr(){let s=await E();if(r.current&&(L(s.groups,v),g&&y)){let l=++H.current,i=await Ke(y,g);if(!r.current||l!==H.current)return;b(i),M(i.content??""),Q(i.injectMode==="once"?"once":"every"),Z(i.dispatchCompletionEnabled===!0),await wt(y,g,l)}}async function Kr(){if(!(!g||!y)){Xe(!0);try{let s=await er(y,g,I,X,ve);if(!r.current)return;if(s){let l=await E();if(!r.current)return;b(i=>i&&{...i,content:I,hasRole:!0,injectMode:X,dispatchCompletionEnabled:ve}),L(l.groups,v),N(Ne,n("roles.saved"))}else N(Ne,I.trim().length===0?n("roles.emptyError"):n("roles.saveFailed"),!0)}finally{r.current&&Xe(!1)}}}async function Wr(){if(!(!g||!y)&&confirm(n("roles.confirmDelete"))){Ze(!0);try{let s=await nr(y,g);if(!r.current)return;if(s){let l=await E();if(!r.current)return;ye(null),J(null),b(null),M(""),Q("every"),Z(!1),L(l.groups,v)}}finally{r.current&&Ze(!1)}}}async function Yr(s){if(!g||!y)return;let l=X;Q(s),et(!0);try{let i=await tr(y,g,s);if(!r.current)return;i||Q(l),N(rt,n(i?"roles.saved":"roles.saveFailed"),!i)}finally{r.current&&et(!1)}}async function zr(s){if(!g||!y)return;let l=ve;Z(s),tt(!0);try{let i=await rr(y,g,s);if(!r.current)return;i||Z(l),N(nt,n(i?"roles.saved":"roles.saveFailed"),!i)}finally{r.current&&tt(!1)}}function Jr(s){D(l=>({...l,...s}))}function Xr(s){D(l=>({...l,senderPolicy:{...l.senderPolicy??{},...s}}))}function Qr(s){D(l=>({...l,messagePolicy:{...l.messagePolicy??{scope:"top_level"},...s,scope:"top_level"}}))}function Zr(s,l){D(i=>{let u=new Set(i.senderPolicy?.includeSenderTypes??[]);if(l)u.add(s);else{if(u.size<=1&&u.has(s))return i;u.delete(s)}return{...i,senderPolicy:{...i.senderPolicy??{},includeSenderTypes:[...u]}}})}function en(s,l){D(i=>{let u=new Set(i.messagePolicy?.includeMsgTypes??[]);if(l)u.add(s);else{if(u.size<=1&&u.has(s))return i;u.delete(s)}return{...i,messagePolicy:{...i.messagePolicy??{scope:"top_level"},includeMsgTypes:[...u],scope:"top_level"}}})}function Rt(s,l){D(i=>{let u=i.senderPolicy?.mode==="all_except_excluded"?"all_except_excluded":"include_only",h=Ht({mode:u,include:i.senderPolicy?.includeSenderOpenIds??[],exclude:i.senderPolicy?.excludeSenderOpenIds??[],targetIds:s,listening:l});return{...i,senderPolicy:{...i.senderPolicy??{},mode:u,includeSenderOpenIds:h.include,excludeSenderOpenIds:h.exclude}}})}function tn(s,l){Rt([s],l)}function rn(s,l){Rt(s,l)}function nn(s){D(l=>({...l,senderPolicy:{...l.senderPolicy??{},mode:s,includeSenderOpenIds:[...l.senderPolicy?.includeSenderOpenIds??[]],excludeSenderOpenIds:[...l.senderPolicy?.excludeSenderOpenIds??[]]}}))}function kt(){let s=P.senderPolicy??{},l=P.messagePolicy??{},i=s.mode==="all_except_excluded"?"all_except_excluded":"include_only",u=[...new Set(s.includeSenderOpenIds??[])].filter(Boolean),h=[...new Set(s.excludeSenderOpenIds??[])].filter(Boolean),de=Vt(h,Ie=>St.get(Ie)?.memberType,s.excludeSenderKinds),w=[...new Set(s.includeSenderTypes??[])].filter(Ie=>Ie==="user"||Ie==="bot"),Ct=[...new Set(l.includeMsgTypes??[])].filter(Boolean);return{enabled:P.enabled,...P.name?.trim()?{name:P.name.trim()}:{},...P.replyCardTitle?.trim()?{replyCardTitle:P.replyCardTitle.trim()}:{},...P.workingDir?.trim()?{workingDir:P.workingDir.trim()}:{},prompt:P.prompt.trim(),senderPolicy:{mode:i,...i==="include_only"&&u.length>0?{includeSenderOpenIds:u}:{},...i==="all_except_excluded"&&h.length>0?{excludeSenderOpenIds:h}:{},...i==="all_except_excluded"&&Object.keys(de).length>0?{excludeSenderKinds:de}:{},...w.length>0?{includeSenderTypes:w}:{},excludeSelf:s.excludeSelf!==!1},messagePolicy:{...Ct.length>0?{includeMsgTypes:Ct}:{},scope:"top_level"}}}function sn(){return P.prompt.trim()?P.senderPolicy?.mode!=="all_except_excluded"&&(P.senderPolicy?.includeSenderOpenIds?.length??0)===0?(N(G,n("roles.listenerSenderRequired"),!0),null):{...kt(),enabled:!0}:(N(G,n("roles.listenerPromptRequired"),!0),null)}async function Nt(s){if(!g||!y)return;let l=sn();if(!l)return;let i=s?"run":"preview";be({kind:"loading",mode:i});try{let u=s?await ar(y,g,l,Me):await ir(y,g,l,Me);if(!r.current)return;be(u.ok?{kind:"result",response:u,mode:i}:{kind:"error",text:u.error||n("roles.listenerPreviewFailed")}),u.ok&&s&&u.runId&&on(u.runId)}catch(u){if(!r.current)return;be({kind:"error",text:u instanceof Error?u.message:n("roles.listenerPreviewFailed")})}}function on(s){if(!g||!y)return;let l=++ut.current;ee.current={runId:s,token:l};let i=async()=>{if(!r.current)return;let u=ee.current;if(!(!u||u.runId!==s||u.token!==l||!g||!y))try{let h=await dr(y,g,s);if(!r.current)return;if(h.ok&&h.results){let de=h.results;be(w=>w.kind!=="result"||w.mode!=="run"||w.response.runId!==s?w:{...w,response:{...w.response,results:In(w.response.results,de)}}),de.some(w=>w.state==="triggered"||w.state==="running")?o(i,1500):ee.current?.runId===s&&(ee.current=null)}}catch{o(i,2500)}};o(i,1500)}async function ln(){if(!(!g||!y)){if(!P.enabled&&!P.prompt.trim()){await Lt(!1);return}if(P.enabled){if(!P.prompt.trim()){N(G,n("roles.listenerPromptRequired"),!0);return}if(P.senderPolicy?.mode!=="all_except_excluded"&&(P.senderPolicy?.includeSenderOpenIds?.length??0)===0){N(G,n("roles.listenerSenderRequired"),!0);return}}dt(!0);try{let s=await sr(y,g,kt());if(!r.current)return;if(s){let l=await E();if(!r.current)return;let i=await We(y,g);if(!r.current)return;ae(yr(i)?i:null),L(l.groups,v)}N(G,n(s?"roles.saved":"roles.saveFailed"),!s)}finally{r.current&&dt(!1)}}}async function Lt(s=!0){if(!(!g||!y)&&!(s&&!confirm(n("roles.listenerConfirmDelete")))){ct(!0);try{let l=await or(y,g);if(!r.current)return;if(l){let i=await E();if(!r.current)return;ae(null),L(i.groups,v)}N(G,n(l?"roles.saved":"roles.saveFailed"),!l)}finally{r.current&&ct(!1)}}}async function Tt(s){let l=s.trim();if(!Ve(l))return;let i=++le.current;_r(l),pt(null),he(""),oe({kind:"idle"}),se(h=>h??c[0]?.chatId??null);let u=await q(l);!r.current||i!==le.current||(re(u),Ce(null))}async function an(s){if(!S)return;let l=++le.current;pt(s);let i=await ur(S,s);if(!r.current||l!==le.current)return;he(i.content??"");let u=await q(S);!r.current||l!==le.current||(re(u),Ce(null))}async function dn(){let s=await E();if(!r.current)return;let l=await ie();if(r.current){if(S){let i=await q(S);if(!r.current)return;re(i)}L(s.groups,l)}}async function cn(){let s=Pt.current,l=s?.value.trim()??"";if(l){if(!Ve(l)){s?.setCustomValidity(n("roles.profileIdInvalid")),s?.reportValidity();return}s?.setCustomValidity(""),await Tt(l),r.current&&(location.hash.startsWith("#/roles/profile")||(location.hash="#/roles/profile"))}}async function un(){if(!(!S||!C)){vt(!0);try{let s=await pr(S,C,ne);if(!r.current)return;let l=await ie();if(!r.current)return;let i=await q(S);if(!r.current)return;re(i),L(c,l),N(Ce,n(s?"roles.saved":"roles.saveFailed"),!s)}finally{r.current&&vt(!1)}}}async function pn(){if(!(!S||!C)&&confirm(n("roles.confirmDeleteProfileEntry"))){ht(!0);try{if(await mr(S,C),!r.current)return;he("");let s=await ie();if(!r.current)return;let l=await q(S);if(!r.current)return;re(l),L(c,s)}finally{r.current&&ht(!1)}}}function mn(s,l){gt(i=>{let u=new Set(i);return l?u.add(s):u.delete(s),u})}async function Mt(s){if(!S)return;let l=$??c[0]?.chatId;if(!l)return;let i=[...ft];if(i.length===0){oe({kind:"text",text:n("roles.applyPickBots")});return}oe({kind:"text",text:"..."});let u=await Promise.all(i.map(h=>gr({profileId:S,chatId:l,larkAppId:h,force:mt,preview:s})));if(r.current&&(oe({kind:"results",preview:s,results:u}),!s)){let h=await E();if(!r.current)return;L(h.groups,v)}}let fn=Je||Be>O||I.trim().length===0,gn=at||Te||It>pe||P.enabled&&P.prompt.trim().length===0,yn=yt||De>O||ne.trim().length===0,V=t.tab==="profiles",vn=(0,e.jsxs)("nav",{className:"roles-subnav insight-tabs",role:"tablist","aria-label":n("roles.title"),children:[(0,e.jsx)("a",{href:"#/roles",className:`itab${V?"":" on"}`,role:"tab","aria-selected":!V,children:n("roles.tabGroups")}),(0,e.jsx)("a",{href:"#/roles/profile",className:`itab${V?" on":""}`,role:"tab","aria-selected":V,children:n("roles.tabProfiles")})]});return(0,e.jsxs)("section",{className:"page roles-page",children:[(0,e.jsxs)("div",{className:"page-heading roles-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:n("nav.roles")}),(0,e.jsx)("h1",{children:n("roles.title")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:vn})]}),(0,e.jsxs)("div",{id:"roles-by-group-view",className:"roles-layout",hidden:V,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-search",placeholder:n("roles.search"),value:F,onChange:s=>k(s.target.value)}),(0,e.jsx)($e,{id:"roles-refresh",label:n("roles.refresh"),onClick:()=>{qr()}})]}),(0,e.jsx)("div",{id:"roles-tree",className:"roles-tree",children:Re?(0,e.jsx)(ce,{label:n("common.loading")}):(0,e.jsx)(Ln,{groups:jr,profiles:v,context:xe,contextLoaded:W,expandedGroups:U,selectedGroupId:g,selectedBotId:y,tr:n,onToggleGroup:s=>B(l=>kn(l,s)),onSelectBot:(s,l)=>{Vr(s,l)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:!g||!y?(0,e.jsx)("div",{id:"roles-editor-empty",className:"roles-editor-empty",children:n("roles.selectHint")}):(0,e.jsxs)("div",{id:"roles-editor-form",className:"roles-editor-form",children:[(0,e.jsxs)("div",{className:"roles-editor-head",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{id:"roles-editor-group-name",children:Ee?.name??g}),(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{id:"roles-editor-bot-name",children:Fr?.botName??y})]}),(0,e.jsx)("div",{className:"roles-editor-meta",children:(0,e.jsxs)("span",{id:"roles-editor-chat-id",className:"roles-editor-meta-line",children:[g," \xB7 ",y]})})]}),(0,e.jsx)("div",{className:"roles-editor-actions roles-editor-head-actions",children:j==="role"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",id:"roles-delete",className:"danger",style:{display:d?.hasRole?"":"none"},disabled:Qe,onClick:()=>{Wr()},children:Qe?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-save",className:"primary",disabled:fn,onClick:()=>{Kr()},children:Je?"...":n("roles.save")})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",id:"roles-listener-delete",className:"danger",style:{display:Nr?"":"none"},disabled:Te,onClick:()=>{Lt()},children:Te?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-listener-save",className:"primary",disabled:gn,onClick:()=>{ln()},children:at?"...":n("roles.save")})]})})]}),(0,e.jsxs)("div",{className:"roles-editor-switch segmented",role:"tablist","aria-label":n("roles.editorTabs"),children:[(0,e.jsx)("button",{type:"button",className:j==="role"?"active":"","aria-pressed":j==="role",onClick:()=>st("role"),children:n("roles.roleTab")}),(0,e.jsx)("button",{type:"button",className:j==="listener"?"active":"","aria-pressed":j==="listener",onClick:()=>st("listener"),children:n("roles.listenerTab")})]}),j==="role"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:n("roles.injectModeLabel")}),(0,e.jsx)(Oe,{id:"roles-editor-inject-mode",className:"roles-inline-menu",ariaLabel:n("roles.injectModeLabel"),disabled:Sr,label:n(X==="once"?"roles.injectModeOnce":"roles.injectModeEvery"),value:X,options:[{value:"every",label:n("roles.injectModeEvery")},{value:"once",label:n("roles.injectModeOnce")}],onChange:s=>{Yr(s==="once"?"once":"every")}}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:n("roles.injectModeHint")}),(0,e.jsx)(fe,{flash:Rr})]}),(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:n("roles.dispatchCompletionLabel")}),(0,e.jsxs)("label",{className:"filter-toggle roles-listener-enabled",children:[(0,e.jsx)("input",{id:"roles-editor-dispatch-completion-enabled",type:"checkbox",checked:ve,disabled:wr,onChange:s=>{zr(s.currentTarget.checked)}}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:n("roles.dispatchCompletionEnabled")})]}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:n("roles.dispatchCompletionHint")}),(0,e.jsx)(fe,{flash:kr})]}),(0,e.jsx)("textarea",{id:"roles-editor-textarea",placeholder:n("roles.editorPlaceholder"),rows:14,value:I,onChange:s=>M(s.target.value)}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-editor-bytecount",className:vr(Be),children:[Be," / ",O," bytes"]}),(0,e.jsx)(fe,{flash:xr})]}),(0,e.jsx)(br,{content:I,tr:n,id:"roles-preview"})]}):(0,e.jsx)(Mn,{listener:P,members:Le,memberById:St,promptByteLen:It,loading:Tr,membersLoading:Mr,flash:Cr,tr:n,onPatch:Jr,onSenderPolicyPatch:Xr,onMessagePolicyPatch:Qr,onToggleSenderType:Zr,onToggleMsgType:en,onSetTargetPolicy:tn,onSetTargetsPolicy:rn,onSetSenderMode:nn,previewLimit:Me,previewStatus:Ar,onPreviewLimitChange:Er,onPreview:()=>{Nt(!1)},onRunPreview:()=>{Nt(!0)}})]})})]}),(0,e.jsxs)("div",{id:"roles-profiles-view",className:"roles-layout roles-profiles-layout",hidden:!V,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header roles-profile-create dashboard-toolbar",children:[(0,e.jsx)("input",{type:"text",id:"roles-profile-id",placeholder:n("roles.profileIdPlaceholder"),maxLength:64,ref:Pt,onChange:s=>s.currentTarget.setCustomValidity("")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-select",onClick:()=>{cn()},children:n("roles.openProfile")})]}),(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-profile-search",placeholder:n("roles.profileSearch"),value:z,onChange:s=>ge(s.target.value)}),(0,e.jsx)($e,{id:"roles-profile-refresh",label:n("roles.refresh"),onClick:()=>{dn()}})]}),(0,e.jsx)("div",{id:"roles-profile-list",className:"roles-tree",children:ke?(0,e.jsx)(ce,{label:n("common.loading")}):(0,e.jsx)(An,{profiles:Hr,selectedProfileId:S,tr:n,onSelect:s=>{Tt(s)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:S?(0,e.jsxs)("div",{id:"roles-profile-detail",className:"roles-editor-form roles-profile-detail",children:[(0,e.jsx)("div",{className:"roles-profile-title",children:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{children:S}),Ae?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{children:Ae.botName??Ae.larkAppId})]}):null]}),(0,e.jsx)("div",{className:"roles-editor-meta-line",children:n("roles.profileRuntimeHint")})]})}),(0,e.jsxs)("div",{className:"roles-profile-grid",children:[(0,e.jsxs)("div",{className:"roles-profile-bots",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:n("roles.profileBots")}),(0,e.jsx)("div",{className:"roles-profile-bot-list",children:f.map(s=>{let l=!!me(te,s.larkAppId),i=C===s.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row roles-profile-bot-row ${i?"selected":""}`,"data-profile-bot-id":s.larkAppId,onClick:()=>{an(s.larkAppId)},children:[(0,e.jsx)(Pr,{bot:s}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:s.botName??s.larkAppId}),(0,e.jsx)("div",{className:"roles-bot-id",children:s.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${l?"has-role":"no-role"}`,children:n(l?"roles.configured":"roles.unconfigured")})]},s.larkAppId)})})]}),(0,e.jsx)("div",{className:"roles-profile-editor",children:C?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"roles-profile-editor-head",children:[(0,e.jsxs)("span",{id:"roles-profile-bytecount",className:vr(De),children:[De," / ",O," bytes"]}),(0,e.jsxs)("div",{className:"roles-editor-actions roles-editor-head-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-delete",className:"danger",style:{display:$r?"":"none"},disabled:bt,onClick:()=>{pn()},children:bt?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-save",className:"primary",disabled:yn,onClick:()=>{un()},children:yt?"...":n("roles.saveEntry")})]})]}),(0,e.jsx)("textarea",{id:"roles-profile-textarea",placeholder:n("roles.profileEditorPlaceholder"),rows:12,value:ne,onChange:s=>he(s.target.value)}),(0,e.jsx)("div",{className:"roles-editor-footer",children:(0,e.jsx)(fe,{flash:Dr})}),(0,e.jsx)(br,{content:ne,tr:n,id:"roles-profile-preview"})]}):(0,e.jsx)("div",{className:"roles-editor-empty roles-profile-inline-empty",children:n("roles.profileBotSelectHint")})})]}),(0,e.jsxs)("div",{className:"roles-profile-apply",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:n("roles.applyToGroup")}),(0,e.jsxs)("div",{className:"roles-profile-apply-controls",children:[(0,e.jsx)(Oe,{id:"roles-profile-apply-group",className:"roles-apply-group-menu",ariaLabel:n("roles.applyToGroup"),disabled:c.length===0,label:_e?.name??$??n("roles.noChats"),value:$??"",options:c.map(s=>({value:s.chatId,label:s.name??s.chatId})),onChange:s=>se(s)}),(0,e.jsxs)("label",{className:"roles-profile-force",children:[(0,e.jsx)("input",{type:"checkbox",id:"roles-profile-apply-force",checked:mt,onChange:s=>Br(s.target.checked)})," ",n("roles.applyForce")]})]}),(0,e.jsx)("div",{id:"roles-profile-apply-bots",children:!_e||Pe.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.noChats")}):Pe.map(s=>{let l=!!me(te,s.larkAppId);return(0,e.jsxs)("label",{className:"checkbox-row roles-profile-apply-bot",children:[(0,e.jsx)("input",{type:"checkbox",name:"profile-apply-bot",value:s.larkAppId,checked:ft.has(s.larkAppId),onChange:i=>mn(s.larkAppId,i.target.checked)}),(0,e.jsx)("span",{children:s.botName??s.larkAppId}),(0,e.jsx)("small",{children:n(l?"roles.configured":"roles.profileMissing")})]},s.larkAppId)})}),(0,e.jsxs)("div",{className:"roles-editor-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-preview-apply",onClick:()=>{Mt(!0)},children:n("roles.previewApply")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-apply",className:"primary",onClick:()=>{Mt(!1)},children:n("roles.applyProfile")})]}),(0,e.jsx)("div",{id:"roles-profile-apply-status",className:"roles-profile-status",children:(0,e.jsx)(_n,{status:Gr,bots:f,tr:n})})]})]}):(0,e.jsx)("div",{id:"roles-profile-empty",className:"roles-editor-empty",children:n("roles.profileSelectHint")})})]})]})}function kn(t,n){let r=new Set(t);return r.has(n)?r.delete(n):r.add(n),r}function vr(t){return`roles-bytecount ${t>qt?"warn":""} ${t>O?"over":""}`}function Nn(t){return`roles-bytecount ${t>Kt?"warn":""} ${t>pe?"over":""}`}function fe(t){return t.flash?(0,e.jsxs)("span",{className:`roles-saved-flash ${t.flash.isError?"roles-save-error":""}`,children:[" ",t.flash.text]}):null}function Ln(t){let{tr:n}=t;return t.groups.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.noChats")}):(0,e.jsx)(e.Fragment,{children:t.groups.map(r=>{let o=t.expandedGroups.has(r.chatId),c=r.memberBots.filter(p=>p.inChat),m=Yt(r),f=zt(r);return(0,e.jsxs)("div",{className:"roles-group-section",children:[(0,e.jsxs)("div",{className:`roles-group-row ${o?"expanded":""} ${t.selectedGroupId===r.chatId&&!t.selectedBotId?"selected":""}`,"data-group-id":r.chatId,onClick:()=>t.onToggleGroup(r.chatId),children:[(0,e.jsx)("span",{className:"roles-group-arrow",children:o?"\u25BE":"\u25B8"}),(0,e.jsx)("span",{className:"roles-group-icon","aria-hidden":"true",children:(0,e.jsxs)("svg",{viewBox:"0 0 16 16",children:[(0,e.jsx)("circle",{cx:"5.6",cy:"5.8",r:"2.4"}),(0,e.jsx)("path",{d:"M1.8 13.2c.5-2.4 2-3.6 3.8-3.6s3.3 1.2 3.8 3.6"}),(0,e.jsx)("circle",{cx:"11",cy:"6.8",r:"1.9"}),(0,e.jsx)("path",{d:"M9.8 12.6c.4-1.7 1.5-2.6 2.8-2.6 1 0 1.9.5 2.4 1.6"})]})}),(0,e.jsxs)("div",{className:"roles-group-info",children:[(0,e.jsx)("div",{className:"roles-group-name",children:r.name??r.chatId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[m,"/",f," ",n("roles.botsWithRoles")]}),(0,e.jsx)(Tn,{group:r,profiles:t.profiles,context:t.context,loaded:t.contextLoaded,tr:n})]}),(0,e.jsx)("span",{className:"roles-group-chevron"})]}),(0,e.jsx)("div",{className:"roles-bot-list",children:o?c.map(p=>{let v=t.selectedGroupId===r.chatId&&t.selectedBotId===p.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row ${v?"selected":""}`,"data-group-id":r.chatId,"data-bot-id":p.larkAppId,onClick:T=>{T.stopPropagation(),t.onSelectBot(r.chatId,p.larkAppId)},children:[(0,e.jsx)("span",{className:"roles-bot-indent"}),(0,e.jsx)(Pr,{bot:p}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:p.botName}),(0,e.jsx)("div",{className:"roles-bot-id",children:p.larkAppId})]}),(0,e.jsxs)("div",{className:"roles-bot-badges",children:[(0,e.jsx)("span",{className:`roles-badge ${p.hasRole?"has-role":"no-role"}`,children:p.hasRole?n("roles.configured"):n("roles.unconfigured")}),p.hasMessageListener?(0,e.jsx)("span",{className:"roles-badge has-listener",children:n("roles.listenerBadge")}):null]})]},p.larkAppId)}):null})]},r.chatId)})})}function Tn(t){let{group:n,profiles:r,context:o,loaded:c,tr:m}=t;if(!r.length||!c)return null;let f=new Map;for(let T of n.memberBots)T.inChat&&f.set(T.larkAppId,o.effectiveRolesByBot.get(qe(T.larkAppId,n.chatId))??null);if(!Gt(f))return null;let p=Ft(n.memberBots,r,o.entriesByProfile,f)[0];if(!p)return(0,e.jsx)("div",{className:"roles-profile-match muted",children:m("groups.profileStatusUnmatched")});let v=p.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`roles-profile-match ${p.kind}`,children:m(v,{name:p.profileId,matched:p.matched,total:p.total,chat:p.chatMatched})})}function Mn(t){let{listener:n,tr:r}=t,[o,c]=(0,a.useState)("members"),[m,f]=(0,a.useState)(""),[p,v]=(0,a.useState)(()=>new Set),T=new Set(n.senderPolicy?.includeSenderTypes??[]),xe=new Set(n.messagePolicy?.includeMsgTypes??[]),R=n.senderPolicy?.mode==="all_except_excluded"?"all_except_excluded":"include_only",W=new Set(n.senderPolicy?.includeSenderOpenIds??[]),A=new Set(n.senderPolicy?.excludeSenderOpenIds??[]),Re=[...[...R==="all_except_excluded"?A:W].filter(d=>!t.memberById.has(d))],Y=[...t.members.filter(d=>d.memberType!=="bot"),...Re.map(d=>({openId:d,name:d,memberType:"unknown"}))],ke=t.members.filter(d=>d.memberType==="bot"),_=o==="bots"?ke:Y,F=jt(_,m),k=F.map(d=>d.openId),z=k.filter(d=>p.has(d)),ge=k.length>0&&z.length===k.length,U=[...p].filter(d=>_.some(b=>b.openId===d)),B=U.length>0?U:k,g=Ue({mode:R,include:[...W],exclude:[...A],targetIds:B});(0,a.useEffect)(()=>{f(""),v(new Set)},[o]),(0,a.useEffect)(()=>{let d=new Set(_.map(b=>b.openId));v(b=>{let I=new Set([...b].filter(M=>d.has(M)));return I.size===b.size?b:I})},[_]);let ye=(d,b)=>{v(I=>{let M=new Set(I);return b?M.add(d):M.delete(d),M})},y=()=>{v(d=>{let b=new Set(d);if(ge)for(let I of k)b.delete(I);else for(let I of k)b.add(I);return b})},J=d=>{B.length!==0&&t.onSetTargetsPolicy(B,d)};return(0,e.jsxs)("div",{className:"roles-listener-editor",children:[t.loading?(0,e.jsx)(ce,{label:r("common.loading")}):null,(0,e.jsxs)("label",{className:"filter-toggle roles-listener-enabled",children:[(0,e.jsx)("input",{type:"checkbox",checked:n.enabled,onChange:d=>t.onPatch({enabled:d.currentTarget.checked})}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:r("roles.listenerEnabled")})]}),(0,e.jsx)("p",{className:"roles-listener-scope-help",children:r("roles.listenerScopeHelp")}),(0,e.jsxs)("div",{className:"roles-listener-grid",children:[(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerName")}),(0,e.jsx)("input",{type:"text",value:n.name??"",placeholder:r("roles.listenerNamePlaceholder"),onChange:d=>t.onPatch({name:d.currentTarget.value})})]}),(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerReplyCardTitle")}),(0,e.jsx)("input",{type:"text",value:n.replyCardTitle??"",placeholder:r("roles.listenerReplyCardTitlePlaceholder"),onChange:d=>t.onPatch({replyCardTitle:d.currentTarget.value})})]}),(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerWorkingDir")}),(0,e.jsx)("input",{type:"text",value:n.workingDir??"",placeholder:r("roles.listenerWorkingDirPlaceholder"),onChange:d=>t.onPatch({workingDir:d.currentTarget.value})})]})]}),(0,e.jsxs)("div",{className:"roles-listener-policy-row",children:[(0,e.jsxs)("div",{className:"roles-listener-policy",children:[(0,e.jsx)("div",{className:"roles-field-label",children:r("roles.listenerSenderTypes")}),(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:T.has("user"),onChange:d=>t.onToggleSenderType("user",d.currentTarget.checked)}),(0,e.jsx)("span",{children:r("roles.listenerSenderUser")})]}),(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:T.has("bot"),onChange:d=>t.onToggleSenderType("bot",d.currentTarget.checked)}),(0,e.jsx)("span",{children:r("roles.listenerSenderBot")})]})]}),(0,e.jsxs)("div",{className:"roles-listener-policy",children:[(0,e.jsx)("div",{className:"roles-field-label",children:r("roles.listenerMessageTypes")}),hr.map(d=>(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:xe.has(d),onChange:b=>t.onToggleMsgType(d,b.currentTarget.checked)}),(0,e.jsx)("span",{children:d})]},d))]}),(0,e.jsxs)("label",{className:"roles-listener-checkbox",children:[(0,e.jsx)("input",{type:"checkbox",checked:n.senderPolicy?.excludeSelf!==!1,onChange:d=>t.onSenderPolicyPatch({excludeSelf:d.currentTarget.checked})}),(0,e.jsx)("span",{children:r("roles.listenerExcludeSelf")})]})]}),(0,e.jsx)("div",{className:"roles-listener-policy-row",children:(0,e.jsxs)("div",{className:"roles-listener-policy",children:[(0,e.jsx)("div",{className:"roles-field-label",children:r("roles.listenerSenderMode")}),(0,e.jsxs)("div",{className:"roles-listener-target-tabs segmented",role:"tablist","aria-label":r("roles.listenerSenderMode"),children:[(0,e.jsx)("button",{type:"button",className:R==="include_only"?"active":"","aria-pressed":R==="include_only",onClick:()=>t.onSetSenderMode("include_only"),children:r("roles.listenerSenderModeInclude")}),(0,e.jsx)("button",{type:"button",className:R==="all_except_excluded"?"active":"","aria-pressed":R==="all_except_excluded",onClick:()=>t.onSetSenderMode("all_except_excluded"),children:r("roles.listenerSenderModeAllExcept")})]}),(0,e.jsx)("small",{className:"roles-listener-scope-help",children:r(R==="all_except_excluded"?"roles.listenerSenderModeAllExceptHelp":"roles.listenerSenderModeIncludeHelp")})]})}),(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerPrompt")}),(0,e.jsx)("textarea",{id:"roles-listener-prompt",placeholder:r("roles.listenerPromptPlaceholder"),rows:9,value:n.prompt,onChange:d=>t.onPatch({prompt:d.currentTarget.value})})]}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-listener-bytecount",className:Nn(t.promptByteLen),children:[t.promptByteLen," / ",pe," bytes"]}),(0,e.jsx)(fe,{flash:t.flash})]}),(0,e.jsxs)("div",{className:"roles-listener-preview-panel",children:[(0,e.jsxs)("div",{className:"roles-listener-preview-head",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:r("roles.listenerPreviewTitle")}),(0,e.jsx)("small",{children:r("roles.listenerPreviewHint")})]}),(0,e.jsxs)("div",{className:"roles-listener-preview-actions",children:[(0,e.jsxs)("label",{children:[(0,e.jsx)("span",{children:r("roles.listenerPreviewCount")}),(0,e.jsx)("select",{value:t.previewLimit,onChange:d=>t.onPreviewLimitChange(Number(d.currentTarget.value)),children:Array.from({length:He},(d,b)=>b+1).map(d=>(0,e.jsx)("option",{value:d,children:d},d))})]}),(0,e.jsx)("button",{type:"button",onClick:t.onPreview,disabled:t.previewStatus.kind==="loading",children:t.previewStatus.kind==="loading"&&t.previewStatus.mode==="preview"?"...":r("roles.listenerPreviewButton")}),(0,e.jsx)("button",{type:"button",className:"primary",onClick:t.onRunPreview,disabled:t.previewStatus.kind==="loading",children:t.previewStatus.kind==="loading"&&t.previewStatus.mode==="run"?"...":r("roles.listenerRunPreviewButton")})]})]}),(0,e.jsx)(Cn,{status:t.previewStatus,tr:r})]}),(0,e.jsxs)("div",{className:"roles-listener-members",children:[(0,e.jsxs)("div",{className:"roles-listener-members-head",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:r("roles.listenerFilters")}),(0,e.jsx)("small",{children:t.membersLoading?r("common.loading"):r("roles.listenerMembersHint")})]}),(0,e.jsxs)("div",{className:"roles-listener-target-tabs segmented",role:"tablist","aria-label":r("roles.listenerFilters"),children:[(0,e.jsx)("button",{type:"button",className:o==="members"?"active":"","aria-pressed":o==="members",onClick:()=>c("members"),children:r("roles.listenerMembers")}),(0,e.jsx)("button",{type:"button",className:o==="bots"?"active":"","aria-pressed":o==="bots",onClick:()=>c("bots"),children:r("roles.listenerBots")})]}),(0,e.jsxs)("div",{className:"roles-listener-filter-toolbar",children:[(0,e.jsx)("input",{type:"search",value:m,placeholder:r("roles.listenerSearchPlaceholder"),onChange:d=>f(d.currentTarget.value)}),m?(0,e.jsx)("button",{type:"button",className:"roles-listener-clear-search",onClick:()=>f(""),"aria-label":r("roles.listenerClearSearch"),children:"\xD7"}):null,(0,e.jsx)("button",{type:"button",className:"roles-listener-select-all",disabled:k.length===0,onClick:y,children:r(ge?"roles.listenerClearVisible":"roles.listenerSelectVisible",{count:k.length})})]}),(0,e.jsxs)("div",{className:"roles-listener-bulkbar",children:[(0,e.jsxs)("span",{children:[U.length>0?r("roles.listenerSelectedCount",{count:U.length}):r("roles.listenerFilteredCount",{count:k.length}),g==="mixed"?` \xB7 ${r("roles.listenerMixedMode")}`:""]}),(0,e.jsxs)("div",{className:"roles-listener-member-actions",role:"group","aria-label":r("roles.listenerBulkActions"),children:[(0,e.jsx)("button",{type:"button",className:g==="listen"?"active":"","aria-pressed":g==="listen",disabled:B.length===0,onClick:()=>J(!0),children:r("roles.listenerTargetListen")}),(0,e.jsx)("button",{type:"button",className:g==="ignore"?"active":"","aria-pressed":g==="ignore",disabled:B.length===0,onClick:()=>J(!1),children:r("roles.listenerTargetIgnore")})]})]}),(0,e.jsx)("div",{className:"roles-listener-member-list",children:F.length===0?(0,e.jsx)("div",{className:"roles-empty",children:r(o==="bots"?"roles.listenerBotsEmpty":"roles.listenerMembersEmpty")}):F.map(d=>{let b=Ue({mode:R,include:[...W],exclude:[...A],targetIds:[d.openId]});return(0,e.jsxs)("div",{className:"roles-listener-member",children:[(0,e.jsx)("label",{className:"roles-listener-member-select","aria-label":Ye(d,d.openId),children:(0,e.jsx)("input",{type:"checkbox",checked:p.has(d.openId),onChange:I=>ye(d.openId,I.currentTarget.checked)})}),(0,e.jsxs)("div",{className:"roles-listener-member-main",children:[(0,e.jsx)("strong",{children:Ye(d,d.openId)}),(0,e.jsx)("span",{children:d.openId})]}),(0,e.jsxs)("div",{className:"roles-listener-member-actions",role:"group","aria-label":Ye(d,d.openId),children:[(0,e.jsx)("button",{type:"button",className:b==="listen"?"active":"","aria-pressed":b==="listen",onClick:()=>t.onSetTargetPolicy(d.openId,!0),children:r("roles.listenerTargetListen")}),(0,e.jsx)("button",{type:"button",className:b==="ignore"?"active":"","aria-pressed":b==="ignore",onClick:()=>t.onSetTargetPolicy(d.openId,!1),children:r("roles.listenerTargetIgnore")})]})]},d.openId)})})]})]})}function br(t){return(0,e.jsx)("div",{id:t.id,className:"roles-preview",children:t.content.trim()?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("strong",{children:t.tr("roles.preview")}),(0,e.jsx)("pre",{children:t.content})]}):(0,e.jsx)("small",{children:t.tr("roles.previewEmpty")})})}function Cn(t){let{status:n,tr:r}=t;if(n.kind==="idle")return(0,e.jsx)("div",{className:"roles-listener-preview-empty",children:r("roles.listenerPreviewEmpty")});if(n.kind==="loading")return(0,e.jsx)(ce,{label:r("common.loading")});if(n.kind==="error")return(0,e.jsx)("div",{className:"roles-listener-preview-error",children:n.text});let o=n.response.matches??[],m=(n.response.results??[]).reduce((f,p)=>{let v=p.ok?p.state??"triggered":"failed";return f[v]=(f[v]??0)+1,f},{});return(0,e.jsxs)("div",{className:"roles-listener-preview-results",children:[(0,e.jsx)("div",{className:"roles-listener-preview-summary",children:n.mode==="run"?r("roles.listenerRunPreviewSummary",{count:o.length,triggered:m.triggered??0,running:m.running??0,replied:m.replied??0,failed:m.failed??0}):r("roles.listenerPreviewSummary",{count:o.length})}),o.length===0?(0,e.jsx)("div",{className:"roles-listener-preview-empty",children:r("roles.listenerPreviewNoMatches")}):(0,e.jsx)("div",{className:"roles-listener-preview-list",children:o.map(f=>(0,e.jsx)(En,{item:f,result:n.response.results?.find(p=>p.messageId===f.messageId),tr:r},f.messageId))})]})}function En(t){let n=t.item.messageText.length>300?`${t.item.messageText.slice(0,300)}...`:t.item.messageText,r=t.item.senderName||t.item.senderOpenId||t.item.senderType,o=lr(t.item.createTime);return(0,e.jsxs)("div",{className:"roles-listener-preview-item",children:[(0,e.jsxs)("div",{className:"roles-listener-preview-meta",children:[(0,e.jsx)("span",{children:t.item.msgType}),(0,e.jsx)("span",{children:t.item.senderType}),t.item.senderOpenId?(0,e.jsx)("span",{children:t.item.senderOpenId}):null,(0,e.jsx)("span",{children:t.item.messageId}),t.result?(0,e.jsx)("span",{className:Sn(t.result.state,t.result.ok),children:t.tr(`roles.listenerRunPreviewState.${t.result.ok?t.result.state??"triggered":"failed"}`)}):null]}),t.result?.sessionId||t.result?.replyMessageId||t.result?.error?(0,e.jsxs)("div",{className:"roles-listener-preview-run-detail",children:[t.result.sessionId?(0,e.jsx)("span",{children:t.result.sessionId}):null,t.result.replyMessageId?(0,e.jsx)("span",{children:t.result.replyMessageId}):null,t.result.error?(0,e.jsx)("strong",{children:t.result.error}):null]}):null,(0,e.jsxs)("div",{className:"roles-listener-preview-sender",children:[(0,e.jsx)("span",{children:t.tr("roles.listenerPreviewSender")}),(0,e.jsx)("strong",{children:r})]}),o?(0,e.jsxs)("div",{className:"roles-listener-preview-time",children:[(0,e.jsx)("span",{children:t.tr("roles.listenerPreviewTime")}),(0,e.jsx)("strong",{children:o})]}):null,t.item.messageTitle?(0,e.jsxs)("div",{className:"roles-listener-preview-title",children:[(0,e.jsx)("span",{children:t.tr("roles.listenerPreviewMessageTitle")}),(0,e.jsx)("strong",{children:t.item.messageTitle})]}):null,(0,e.jsx)("div",{className:"roles-listener-preview-content-label",children:t.tr("roles.listenerPreviewContent")}),(0,e.jsx)("pre",{children:n})]})}function An(t){let{tr:n}=t;return t.profiles.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.profileEmpty")}):(0,e.jsx)(e.Fragment,{children:t.profiles.map(r=>{let o=t.selectedProfileId===r.profileId,c=(r.botEntries??[]).some(m=>m.hasEntry);return(0,e.jsxs)("div",{className:`roles-profile-row ${o?"selected":""}`,"data-profile-id":r.profileId,onClick:()=>t.onSelect(r.profileId),children:[(0,e.jsxs)("div",{className:"roles-profile-row-main",children:[(0,e.jsx)("div",{className:"roles-profile-name",children:r.profileId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[r.entryCount," ",n("roles.profileEntries")]})]}),(0,e.jsx)("span",{className:`roles-badge ${c?"has-role":"no-role"}`,children:n(c?"roles.configured":"roles.profileMissing")})]},r.profileId)})})}function _n(t){let{status:n,bots:r,tr:o}=t;return n.kind==="idle"?null:n.kind==="text"?(0,e.jsx)(e.Fragment,{children:n.text}):(0,e.jsx)(e.Fragment,{children:n.results.map(c=>{let f=r.find(v=>v.larkAppId===c.larkAppId)?.botName??c.larkAppId,p=c.ok?n.preview?c.wouldRefuse?o("roles.applyWouldRefuse"):o("roles.applyPreviewOk"):o("roles.applyOk"):`${o("roles.applyFailed")}: ${String(c.error??`HTTP ${c.status}`)}`;return(0,e.jsxs)("div",{children:[f,": ",p]},c.larkAppId)})})}function qn(t){return Fe(t,(0,e.jsx)(Ir,{tab:"groups"}))}function Kn(t){return Fe(t,(0,e.jsx)(Ir,{tab:"profiles"}))}export{Kn as renderRoleProfilesPage,qn as renderRolesPage};
|
|
1
|
+
import{a as Gt,b as Ft,c as $t,d as Ot}from"./chunk-R3FXBFQH.js";import{b as Dt,c as ce,h as $e,q as Oe}from"./chunk-5CJMHTT4.js";import{d as _t}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import{C as Et,G as At}from"./chunk-F6KNPF4R.js";import{a as Fe}from"./chunk-SYC6D5XU.js";import{a as bn,d as Bt}from"./chunk-5THX4DI2.js";import{c as Ge}from"./chunk-7SZRL6FY.js";var a=Ge(bn(),1);function jt(t,n){let r=n.trim().toLowerCase();return r?t.filter(o=>o.openId.toLowerCase().includes(r)||o.name.toLowerCase().includes(r)||o.memberType.toLowerCase().includes(r)):t}function Ut(t){return[...new Set([...t].filter(Boolean))]}function Ht(t){let n=new Set(t.targetIds.filter(Boolean));if(t.mode==="all_except_excluded"){let o=new Set(t.exclude);for(let c of n)o.delete(c),t.listening||o.add(c);return{include:[],exclude:Ut(o)}}let r=new Set(t.include);for(let o of n)r.delete(o),t.listening&&r.add(o);return{include:Ut(r),exclude:[]}}function Ue(t){let n=t.targetIds.filter(Boolean);if(n.length===0)return t.mode==="all_except_excluded"?"listen":"ignore";let r=new Set;if(t.mode==="all_except_excluded"){let o=new Set(t.exclude);for(let c of n)r.add(o.has(c)?"ignore":"listen")}else{let o=new Set(t.include);for(let c of n)r.add(o.has(c)?"listen":"ignore")}return r.size===1?[...r][0]:"mixed"}function Vt(t,n,r){let o={};for(let c of t){if(!c)continue;let m=n(c),f=m==="user"||m==="bot"?m:r?.[c];(f==="user"||f==="bot")&&(o[c]=f)}return o}var O=32768,qt=Math.floor(O*.95),pe=32768,Kt=Math.floor(pe*.95),je=5,He=20,hn=/^[A-Za-z0-9._-]{1,64}$/;function Ve(t){return hn.test(t)&&t!=="."&&t!==".."}function Wt(t=location.hash){let[,n=""]=t.split("?");return new URLSearchParams(n).get("chatId")?.trim()||null}function qe(t,n){return $t(t,n)}function we(t){return new TextEncoder().encode(t).length}function Yt(t){return t.memberBots.filter(n=>n.inChat&&n.hasRole).length}function zt(t){return t.memberBots.filter(n=>n.inChat).length}function me(t,n){return n?t.find(r=>r.larkAppId===n):void 0}function Jt(t,n){let r=n.toLowerCase();return r?t.filter(o=>{let c=o.chatId.toLowerCase().includes(r)||(o.name??"").toLowerCase().includes(r),m=o.memberBots.some(f=>f.larkAppId.toLowerCase().includes(r)||(f.botName??"").toLowerCase().includes(r));return c||m}):t}function Xt(t,n){let r=n.toLowerCase();return t.filter(o=>!r||o.profileId.toLowerCase().includes(r))}async function x(t){return t.json().catch(()=>({}))}async function Qt(){let t=await fetch("/api/groups"),n=await x(t);return{bots:(n.bots??[]).map(r=>({larkAppId:r.larkAppId,botName:r.botName??r.larkAppId,botAvatarUrl:r.botAvatarUrl})),groups:(n.chats??[]).map(r=>({chatId:r.chatId,name:r.name??r.chatId,memberBots:(r.memberBots??[]).map(o=>({larkAppId:o.larkAppId,botName:o.botName??o.larkAppId,inChat:o.inChat??!1,hasRole:o.hasRole??!1,hasMessageListener:o.hasMessageListener??!1,oncallChat:o.oncallChat??null}))}))}}async function Zt(){let t=await fetch("/api/role-profiles");return(await x(t)).profiles??[]}async function q(t){let n=await fetch(`/api/role-profiles/${encodeURIComponent(t)}`);return(await x(n)).entries??[]}async function Ke(t,n){let r=await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return x(r)}async function er(t,n,r,o,c){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:r,injectMode:o,dispatchCompletionEnabled:c})})).ok}async function tr(t,n,r){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({injectMode:r})})).ok}async function rr(t,n,r){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({dispatchCompletionEnabled:r})})).ok}async function nr(t,n){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}async function We(t,n){let r=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return(await x(r)).listener??{enabled:!1,prompt:"",messagePolicy:{scope:"top_level"}}}async function sr(t,n,r){return(await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(r)})).ok}async function or(t,n){return(await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}function Se(t){return Number.isFinite(t)?Math.min(He,Math.max(1,Math.floor(t))):je}function ue(t){return String(t).padStart(2,"0")}function lr(t){if(!t)return"";let n=Number(t);if(!Number.isFinite(n)||n<=0)return"";let r=n<1e12?n*1e3:n,o=new Date(r);return Number.isFinite(o.getTime())?[o.getFullYear(),"-",ue(o.getMonth()+1),"-",ue(o.getDate())," ",ue(o.getHours()),":",ue(o.getMinutes()),":",ue(o.getSeconds())].join(""):""}async function ir(t,n,r,o){let c=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({listener:r,limit:Se(o)})}),m=await x(c);return{ok:c.ok&&m.ok!==!1,requestedLimit:m.requestedLimit??Se(o),matches:m.matches??[],error:m.error}}async function ar(t,n,r,o){let c=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/run-preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({listener:r,limit:Se(o)})}),m=await x(c);return{ok:c.ok&&m.ok!==!1,requestedLimit:m.requestedLimit??Se(o),matches:m.matches??[],results:m.results,error:m.error}}async function dr(t,n,r){let o=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/run-preview/${encodeURIComponent(r)}`),c=await x(o);return{ok:o.ok&&c.ok!==!1,runId:c.runId,results:c.results,error:c.error}}async function cr(t,n){let r=await fetch(`/api/groups/${encodeURIComponent(t)}/${encodeURIComponent(n)}/members-display`);return(await x(r)).members??[]}async function ur(t,n){let r=await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return x(r)}async function pr(t,n,r){return(await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:r,allowEmpty:!0})})).ok}async function mr(t,n){return(await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}async function fr(t,n){let r=await Promise.all(n.map(async f=>{try{let p=await fetch(`/api/role-profiles/${encodeURIComponent(f.profileId)}`),v=await x(p);return[f.profileId,Array.isArray(v.entries)?v.entries:[]]}catch{return[f.profileId,[]]}})),o=new Set,c=[];for(let f of t)for(let p of f.memberBots){if(!p.inChat||!p.hasRole)continue;let v=qe(p.larkAppId,f.chatId);o.has(v)||(o.add(v),c.push({larkAppId:p.larkAppId,chatId:f.chatId}))}let m=await Ot(c);return{entriesByProfile:new Map(r),effectiveRolesByBot:m}}async function gr(t){let n=await fetch(`/api/role-profiles/${encodeURIComponent(t.profileId)}/apply`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({chatId:t.chatId,larkAppId:t.larkAppId,force:t.force,preview:t.preview})}),r=await x(n);return{larkAppId:t.larkAppId,ok:n.ok&&r.ok!==!1,status:n.status,error:r.error,wouldRefuse:r.wouldRefuse}}var e=Ge(Bt(),1),hr=["text","post","image","interactive"],K={enabled:!1,prompt:"",senderPolicy:{mode:"include_only",includeSenderTypes:["user"],excludeSelf:!0},messagePolicy:{includeMsgTypes:[...hr],scope:"top_level"}};function ze(t){let n=t?.senderPolicy?.mode==="include_only"?"include_only":"all_except_excluded";return{enabled:t?.enabled===!0,name:t?.name??"",replyCardTitle:t?.replyCardTitle??"",workingDir:t?.workingDir??"",prompt:t?.prompt??"",senderPolicy:{mode:n,includeSenderOpenIds:[...t?.senderPolicy?.includeSenderOpenIds??[]],excludeSenderOpenIds:[...t?.senderPolicy?.excludeSenderOpenIds??[]],...t?.senderPolicy?.excludeSenderKinds?{excludeSenderKinds:{...t.senderPolicy.excludeSenderKinds}}:{},includeSenderTypes:[...t?.senderPolicy?.includeSenderTypes??K.senderPolicy?.includeSenderTypes??[]],excludeSenderTypes:[...t?.senderPolicy?.excludeSenderTypes??[]],excludeSelf:t?.senderPolicy?.excludeSelf!==!1},messagePolicy:{includeMsgTypes:[...t?.messagePolicy?.includeMsgTypes??K.messagePolicy?.includeMsgTypes??[]],scope:"top_level"}}}function yr(t){return!!t&&t.prompt.trim().length>0}function Pn(t){return t.memberBots.some(n=>n.inChat&&(n.hasRole||n.hasMessageListener))}function Ye(t,n){return t?.name||n}function In(t,n){let r=new Map;for(let o of t??[])r.set(o.messageId,o);for(let o of n)r.set(o.messageId,{...r.get(o.messageId),...o});return[...r.values()]}function Sn(t,n){return!n||t==="failed"?"error":t==="replied"?"ok":t==="running"?"running":"triggered"}function wn(t,n=[]){return ze(t??K)}function xn(){let t=(0,a.useRef)(!0);return(0,a.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Rn(){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>()=>{for(let n of t.current)window.clearTimeout(n);t.current.clear()},[]),(0,a.useCallback)((n,r)=>{let o=window.setTimeout(()=>{t.current.delete(o),n()},r);return t.current.add(o),o},[])}function Pr(t){return(0,e.jsx)(Dt,{html:Et({name:t.bot.botName,larkAppId:t.bot.larkAppId,avatarUrl:t.bot.botAvatarUrl,size:"sm"})})}function Ir(t){let n=_t(),r=xn(),o=Rn(),[c,m]=(0,a.useState)([]),[f,p]=(0,a.useState)([]),[v,T]=(0,a.useState)([]),[xe,R]=(0,a.useState)({entriesByProfile:new Map,effectiveRolesByBot:new Map}),[W,A]=(0,a.useState)(!1),[Re,Y]=(0,a.useState)(!0),[ke,_]=(0,a.useState)(!0),[F,k]=(0,a.useState)(""),[z,ge]=(0,a.useState)(""),[U,B]=(0,a.useState)(()=>new Set),[g,ye]=(0,a.useState)(null),[y,J]=(0,a.useState)(null),[d,b]=(0,a.useState)(null),[I,M]=(0,a.useState)(""),[X,Q]=(0,a.useState)("every"),[ve,Z]=(0,a.useState)(!1),[Je,Xe]=(0,a.useState)(!1),[Qe,Ze]=(0,a.useState)(!1),[Sr,et]=(0,a.useState)(!1),[wr,tt]=(0,a.useState)(!1),[xr,Ne]=(0,a.useState)(null),[Rr,rt]=(0,a.useState)(null),[kr,nt]=(0,a.useState)(null),[j,st]=(0,a.useState)("role"),[Nr,Lr]=(0,a.useState)(null),[P,D]=(0,a.useState)(()=>ze(K)),[Le,ot]=(0,a.useState)([]),[Tr,lt]=(0,a.useState)(!1),[Mr,it]=(0,a.useState)(!1),[at,dt]=(0,a.useState)(!1),[Te,ct]=(0,a.useState)(!1),[Cr,G]=(0,a.useState)(null),[Me,Er]=(0,a.useState)(je),[Ar,be]=(0,a.useState)({kind:"idle"}),ee=(0,a.useRef)(null),ut=(0,a.useRef)(0),[S,_r]=(0,a.useState)(null),[C,pt]=(0,a.useState)(null),[te,re]=(0,a.useState)([]),[ne,he]=(0,a.useState)(""),[$,se]=(0,a.useState)(null),[mt,Br]=(0,a.useState)(!1),[ft,gt]=(0,a.useState)(()=>new Set),[yt,vt]=(0,a.useState)(!1),[bt,ht]=(0,a.useState)(!1),[Dr,Ce]=(0,a.useState)(null),[Gr,oe]=(0,a.useState)({kind:"idle"}),H=(0,a.useRef)(0),le=(0,a.useRef)(0),Pt=(0,a.useRef)(null),Ee=g?c.find(s=>s.chatId===g):void 0,Fr=Ee&&y?Ee.memberBots.find(s=>s.larkAppId===y):void 0,Ae=C?f.find(s=>s.larkAppId===C):void 0,$r=me(te,C),_e=$?c.find(s=>s.chatId===$):void 0,Pe=_e?.memberBots.filter(s=>s.inChat)??[],Or=Pe.map(s=>s.larkAppId).join("\0"),Ur=te.map(s=>s.larkAppId).sort().join("\0"),jr=(0,a.useMemo)(()=>Jt(c,F),[c,F]),Hr=(0,a.useMemo)(()=>Xt(v,z),[v,z]),Be=we(I),De=we(ne),It=we(P.prompt),St=(0,a.useMemo)(()=>{let s=new Map;for(let l of Le)s.set(l.openId,l);return s},[Le]),N=(0,a.useCallback)((s,l,i=!1)=>{let u=Date.now()+Math.random();s({text:l,isError:i,id:u}),o(()=>{s(h=>h?.id===u?null:h)},i?3e3:2e3)},[o]),L=(0,a.useCallback)(async(s,l)=>{try{let i=await fr(s,l);if(!r.current)return;R(i),A(!0)}catch{if(!r.current)return;R({entriesByProfile:new Map,effectiveRolesByBot:new Map}),A(!0)}},[r]),E=(0,a.useCallback)(async()=>{let s=await Qt();return r.current&&(m(s.groups),p(s.bots)),s},[r]),ie=(0,a.useCallback)(async()=>{let s=await Zt();return r.current&&T(s),s},[r]),ae=(0,a.useCallback)((s,l=[])=>{let i=wn(s??K,l);Lr(s),D(i)},[]),wt=(0,a.useCallback)(async(s,l,i)=>{lt(!0),it(!0),ot([]);try{let[u,h]=await Promise.all([We(s,l).catch(()=>ze(K)),cr(s,l).catch(()=>[])]);if(!r.current||i!==H.current)return;ae(yr(u)?u:null,h),ot(h),G(null)}finally{r.current&&i===H.current&&(lt(!1),it(!1))}},[r,ae]),xt=(0,a.useCallback)(async()=>{Y(!0),_(!0),A(!1);try{let s=await E();if(!r.current)return;let l=await ie();if(!r.current||(await At(),!r.current))return;if(B(new Set(s.groups.filter(Pn).map(i=>i.chatId))),t.tab==="profiles"){let i=Wt();se(u=>u||(i&&s.groups.some(h=>h.chatId===i)?i:s.groups[0]?.chatId??null))}else se(i=>i??s.groups[0]?.chatId??null);Y(!1),_(!1),L(s.groups,l)}catch{if(!r.current)return;Y(!1),_(!1),A(!0)}},[r,t.tab,E,ie,L]);(0,a.useEffect)(()=>{xt()},[xt]),(0,a.useEffect)(()=>()=>{ut.current+=1,ee.current=null},[]),(0,a.useEffect)(()=>{$||c.length===0||se(c[0].chatId)},[c,$]),(0,a.useEffect)(()=>{let s=new Set(Pe.filter(l=>!!me(te,l.larkAppId)).map(l=>l.larkAppId));gt(s),oe({kind:"idle"})},[Ur,Or]);async function Vr(s,l){let i=++H.current;ye(s),J(l),Ne(null),rt(null),nt(null),G(null),ae(null);let u=await Ke(l,s);!r.current||i!==H.current||(b(u),M(u.content??""),Q(u.injectMode==="once"?"once":"every"),Z(u.dispatchCompletionEnabled===!0),await wt(l,s,i))}async function qr(){let s=await E();if(r.current&&(L(s.groups,v),g&&y)){let l=++H.current,i=await Ke(y,g);if(!r.current||l!==H.current)return;b(i),M(i.content??""),Q(i.injectMode==="once"?"once":"every"),Z(i.dispatchCompletionEnabled===!0),await wt(y,g,l)}}async function Kr(){if(!(!g||!y)){Xe(!0);try{let s=await er(y,g,I,X,ve);if(!r.current)return;if(s){let l=await E();if(!r.current)return;b(i=>i&&{...i,content:I,hasRole:!0,injectMode:X,dispatchCompletionEnabled:ve}),L(l.groups,v),N(Ne,n("roles.saved"))}else N(Ne,I.trim().length===0?n("roles.emptyError"):n("roles.saveFailed"),!0)}finally{r.current&&Xe(!1)}}}async function Wr(){if(!(!g||!y)&&confirm(n("roles.confirmDelete"))){Ze(!0);try{let s=await nr(y,g);if(!r.current)return;if(s){let l=await E();if(!r.current)return;ye(null),J(null),b(null),M(""),Q("every"),Z(!1),L(l.groups,v)}}finally{r.current&&Ze(!1)}}}async function Yr(s){if(!g||!y)return;let l=X;Q(s),et(!0);try{let i=await tr(y,g,s);if(!r.current)return;i||Q(l),N(rt,n(i?"roles.saved":"roles.saveFailed"),!i)}finally{r.current&&et(!1)}}async function zr(s){if(!g||!y)return;let l=ve;Z(s),tt(!0);try{let i=await rr(y,g,s);if(!r.current)return;i||Z(l),N(nt,n(i?"roles.saved":"roles.saveFailed"),!i)}finally{r.current&&tt(!1)}}function Jr(s){D(l=>({...l,...s}))}function Xr(s){D(l=>({...l,senderPolicy:{...l.senderPolicy??{},...s}}))}function Qr(s){D(l=>({...l,messagePolicy:{...l.messagePolicy??{scope:"top_level"},...s,scope:"top_level"}}))}function Zr(s,l){D(i=>{let u=new Set(i.senderPolicy?.includeSenderTypes??[]);if(l)u.add(s);else{if(u.size<=1&&u.has(s))return i;u.delete(s)}return{...i,senderPolicy:{...i.senderPolicy??{},includeSenderTypes:[...u]}}})}function en(s,l){D(i=>{let u=new Set(i.messagePolicy?.includeMsgTypes??[]);if(l)u.add(s);else{if(u.size<=1&&u.has(s))return i;u.delete(s)}return{...i,messagePolicy:{...i.messagePolicy??{scope:"top_level"},includeMsgTypes:[...u],scope:"top_level"}}})}function Rt(s,l){D(i=>{let u=i.senderPolicy?.mode==="all_except_excluded"?"all_except_excluded":"include_only",h=Ht({mode:u,include:i.senderPolicy?.includeSenderOpenIds??[],exclude:i.senderPolicy?.excludeSenderOpenIds??[],targetIds:s,listening:l});return{...i,senderPolicy:{...i.senderPolicy??{},mode:u,includeSenderOpenIds:h.include,excludeSenderOpenIds:h.exclude}}})}function tn(s,l){Rt([s],l)}function rn(s,l){Rt(s,l)}function nn(s){D(l=>({...l,senderPolicy:{...l.senderPolicy??{},mode:s,includeSenderOpenIds:[...l.senderPolicy?.includeSenderOpenIds??[]],excludeSenderOpenIds:[...l.senderPolicy?.excludeSenderOpenIds??[]]}}))}function kt(){let s=P.senderPolicy??{},l=P.messagePolicy??{},i=s.mode==="all_except_excluded"?"all_except_excluded":"include_only",u=[...new Set(s.includeSenderOpenIds??[])].filter(Boolean),h=[...new Set(s.excludeSenderOpenIds??[])].filter(Boolean),de=Vt(h,Ie=>St.get(Ie)?.memberType,s.excludeSenderKinds),w=[...new Set(s.includeSenderTypes??[])].filter(Ie=>Ie==="user"||Ie==="bot"),Ct=[...new Set(l.includeMsgTypes??[])].filter(Boolean);return{enabled:P.enabled,...P.name?.trim()?{name:P.name.trim()}:{},...P.replyCardTitle?.trim()?{replyCardTitle:P.replyCardTitle.trim()}:{},...P.workingDir?.trim()?{workingDir:P.workingDir.trim()}:{},prompt:P.prompt.trim(),senderPolicy:{mode:i,...i==="include_only"&&u.length>0?{includeSenderOpenIds:u}:{},...i==="all_except_excluded"&&h.length>0?{excludeSenderOpenIds:h}:{},...i==="all_except_excluded"&&Object.keys(de).length>0?{excludeSenderKinds:de}:{},...w.length>0?{includeSenderTypes:w}:{},excludeSelf:s.excludeSelf!==!1},messagePolicy:{...Ct.length>0?{includeMsgTypes:Ct}:{},scope:"top_level"}}}function sn(){return P.prompt.trim()?P.senderPolicy?.mode!=="all_except_excluded"&&(P.senderPolicy?.includeSenderOpenIds?.length??0)===0?(N(G,n("roles.listenerSenderRequired"),!0),null):{...kt(),enabled:!0}:(N(G,n("roles.listenerPromptRequired"),!0),null)}async function Nt(s){if(!g||!y)return;let l=sn();if(!l)return;let i=s?"run":"preview";be({kind:"loading",mode:i});try{let u=s?await ar(y,g,l,Me):await ir(y,g,l,Me);if(!r.current)return;be(u.ok?{kind:"result",response:u,mode:i}:{kind:"error",text:u.error||n("roles.listenerPreviewFailed")}),u.ok&&s&&u.runId&&on(u.runId)}catch(u){if(!r.current)return;be({kind:"error",text:u instanceof Error?u.message:n("roles.listenerPreviewFailed")})}}function on(s){if(!g||!y)return;let l=++ut.current;ee.current={runId:s,token:l};let i=async()=>{if(!r.current)return;let u=ee.current;if(!(!u||u.runId!==s||u.token!==l||!g||!y))try{let h=await dr(y,g,s);if(!r.current)return;if(h.ok&&h.results){let de=h.results;be(w=>w.kind!=="result"||w.mode!=="run"||w.response.runId!==s?w:{...w,response:{...w.response,results:In(w.response.results,de)}}),de.some(w=>w.state==="triggered"||w.state==="running")?o(i,1500):ee.current?.runId===s&&(ee.current=null)}}catch{o(i,2500)}};o(i,1500)}async function ln(){if(!(!g||!y)){if(!P.enabled&&!P.prompt.trim()){await Lt(!1);return}if(P.enabled){if(!P.prompt.trim()){N(G,n("roles.listenerPromptRequired"),!0);return}if(P.senderPolicy?.mode!=="all_except_excluded"&&(P.senderPolicy?.includeSenderOpenIds?.length??0)===0){N(G,n("roles.listenerSenderRequired"),!0);return}}dt(!0);try{let s=await sr(y,g,kt());if(!r.current)return;if(s){let l=await E();if(!r.current)return;let i=await We(y,g);if(!r.current)return;ae(yr(i)?i:null),L(l.groups,v)}N(G,n(s?"roles.saved":"roles.saveFailed"),!s)}finally{r.current&&dt(!1)}}}async function Lt(s=!0){if(!(!g||!y)&&!(s&&!confirm(n("roles.listenerConfirmDelete")))){ct(!0);try{let l=await or(y,g);if(!r.current)return;if(l){let i=await E();if(!r.current)return;ae(null),L(i.groups,v)}N(G,n(l?"roles.saved":"roles.saveFailed"),!l)}finally{r.current&&ct(!1)}}}async function Tt(s){let l=s.trim();if(!Ve(l))return;let i=++le.current;_r(l),pt(null),he(""),oe({kind:"idle"}),se(h=>h??c[0]?.chatId??null);let u=await q(l);!r.current||i!==le.current||(re(u),Ce(null))}async function an(s){if(!S)return;let l=++le.current;pt(s);let i=await ur(S,s);if(!r.current||l!==le.current)return;he(i.content??"");let u=await q(S);!r.current||l!==le.current||(re(u),Ce(null))}async function dn(){let s=await E();if(!r.current)return;let l=await ie();if(r.current){if(S){let i=await q(S);if(!r.current)return;re(i)}L(s.groups,l)}}async function cn(){let s=Pt.current,l=s?.value.trim()??"";if(l){if(!Ve(l)){s?.setCustomValidity(n("roles.profileIdInvalid")),s?.reportValidity();return}s?.setCustomValidity(""),await Tt(l),r.current&&(location.hash.startsWith("#/roles/profile")||(location.hash="#/roles/profile"))}}async function un(){if(!(!S||!C)){vt(!0);try{let s=await pr(S,C,ne);if(!r.current)return;let l=await ie();if(!r.current)return;let i=await q(S);if(!r.current)return;re(i),L(c,l),N(Ce,n(s?"roles.saved":"roles.saveFailed"),!s)}finally{r.current&&vt(!1)}}}async function pn(){if(!(!S||!C)&&confirm(n("roles.confirmDeleteProfileEntry"))){ht(!0);try{if(await mr(S,C),!r.current)return;he("");let s=await ie();if(!r.current)return;let l=await q(S);if(!r.current)return;re(l),L(c,s)}finally{r.current&&ht(!1)}}}function mn(s,l){gt(i=>{let u=new Set(i);return l?u.add(s):u.delete(s),u})}async function Mt(s){if(!S)return;let l=$??c[0]?.chatId;if(!l)return;let i=[...ft];if(i.length===0){oe({kind:"text",text:n("roles.applyPickBots")});return}oe({kind:"text",text:"..."});let u=await Promise.all(i.map(h=>gr({profileId:S,chatId:l,larkAppId:h,force:mt,preview:s})));if(r.current&&(oe({kind:"results",preview:s,results:u}),!s)){let h=await E();if(!r.current)return;L(h.groups,v)}}let fn=Je||Be>O||I.trim().length===0,gn=at||Te||It>pe||P.enabled&&P.prompt.trim().length===0,yn=yt||De>O||ne.trim().length===0,V=t.tab==="profiles",vn=(0,e.jsxs)("nav",{className:"roles-subnav insight-tabs",role:"tablist","aria-label":n("roles.title"),children:[(0,e.jsx)("a",{href:"#/roles",className:`itab${V?"":" on"}`,role:"tab","aria-selected":!V,children:n("roles.tabGroups")}),(0,e.jsx)("a",{href:"#/roles/profile",className:`itab${V?" on":""}`,role:"tab","aria-selected":V,children:n("roles.tabProfiles")})]});return(0,e.jsxs)("section",{className:"page roles-page",children:[(0,e.jsxs)("div",{className:"page-heading roles-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:n("nav.roles")}),(0,e.jsx)("h1",{children:n("roles.title")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:vn})]}),(0,e.jsxs)("div",{id:"roles-by-group-view",className:"roles-layout",hidden:V,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-search",placeholder:n("roles.search"),value:F,onChange:s=>k(s.target.value)}),(0,e.jsx)($e,{id:"roles-refresh",label:n("roles.refresh"),onClick:()=>{qr()}})]}),(0,e.jsx)("div",{id:"roles-tree",className:"roles-tree",children:Re?(0,e.jsx)(ce,{label:n("common.loading")}):(0,e.jsx)(Ln,{groups:jr,profiles:v,context:xe,contextLoaded:W,expandedGroups:U,selectedGroupId:g,selectedBotId:y,tr:n,onToggleGroup:s=>B(l=>kn(l,s)),onSelectBot:(s,l)=>{Vr(s,l)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:!g||!y?(0,e.jsx)("div",{id:"roles-editor-empty",className:"roles-editor-empty",children:n("roles.selectHint")}):(0,e.jsxs)("div",{id:"roles-editor-form",className:"roles-editor-form",children:[(0,e.jsxs)("div",{className:"roles-editor-head",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{id:"roles-editor-group-name",children:Ee?.name??g}),(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{id:"roles-editor-bot-name",children:Fr?.botName??y})]}),(0,e.jsx)("div",{className:"roles-editor-meta",children:(0,e.jsxs)("span",{id:"roles-editor-chat-id",className:"roles-editor-meta-line",children:[g," \xB7 ",y]})})]}),(0,e.jsx)("div",{className:"roles-editor-actions roles-editor-head-actions",children:j==="role"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",id:"roles-delete",className:"danger",style:{display:d?.hasRole?"":"none"},disabled:Qe,onClick:()=>{Wr()},children:Qe?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-save",className:"primary",disabled:fn,onClick:()=>{Kr()},children:Je?"...":n("roles.save")})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",id:"roles-listener-delete",className:"danger",style:{display:Nr?"":"none"},disabled:Te,onClick:()=>{Lt()},children:Te?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-listener-save",className:"primary",disabled:gn,onClick:()=>{ln()},children:at?"...":n("roles.save")})]})})]}),(0,e.jsxs)("div",{className:"roles-editor-switch segmented",role:"tablist","aria-label":n("roles.editorTabs"),children:[(0,e.jsx)("button",{type:"button",className:j==="role"?"active":"","aria-pressed":j==="role",onClick:()=>st("role"),children:n("roles.roleTab")}),(0,e.jsx)("button",{type:"button",className:j==="listener"?"active":"","aria-pressed":j==="listener",onClick:()=>st("listener"),children:n("roles.listenerTab")})]}),j==="role"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:n("roles.injectModeLabel")}),(0,e.jsx)(Oe,{id:"roles-editor-inject-mode",className:"roles-inline-menu",ariaLabel:n("roles.injectModeLabel"),disabled:Sr,label:n(X==="once"?"roles.injectModeOnce":"roles.injectModeEvery"),value:X,options:[{value:"every",label:n("roles.injectModeEvery")},{value:"once",label:n("roles.injectModeOnce")}],onChange:s=>{Yr(s==="once"?"once":"every")}}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:n("roles.injectModeHint")}),(0,e.jsx)(fe,{flash:Rr})]}),(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:n("roles.dispatchCompletionLabel")}),(0,e.jsxs)("label",{className:"filter-toggle roles-listener-enabled",children:[(0,e.jsx)("input",{id:"roles-editor-dispatch-completion-enabled",type:"checkbox",checked:ve,disabled:wr,onChange:s=>{zr(s.currentTarget.checked)}}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:n("roles.dispatchCompletionEnabled")})]}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:n("roles.dispatchCompletionHint")}),(0,e.jsx)(fe,{flash:kr})]}),(0,e.jsx)("textarea",{id:"roles-editor-textarea",placeholder:n("roles.editorPlaceholder"),rows:14,value:I,onChange:s=>M(s.target.value)}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-editor-bytecount",className:vr(Be),children:[Be," / ",O," bytes"]}),(0,e.jsx)(fe,{flash:xr})]}),(0,e.jsx)(br,{content:I,tr:n,id:"roles-preview"})]}):(0,e.jsx)(Mn,{listener:P,members:Le,memberById:St,promptByteLen:It,loading:Tr,membersLoading:Mr,flash:Cr,tr:n,onPatch:Jr,onSenderPolicyPatch:Xr,onMessagePolicyPatch:Qr,onToggleSenderType:Zr,onToggleMsgType:en,onSetTargetPolicy:tn,onSetTargetsPolicy:rn,onSetSenderMode:nn,previewLimit:Me,previewStatus:Ar,onPreviewLimitChange:Er,onPreview:()=>{Nt(!1)},onRunPreview:()=>{Nt(!0)}})]})})]}),(0,e.jsxs)("div",{id:"roles-profiles-view",className:"roles-layout roles-profiles-layout",hidden:!V,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header roles-profile-create dashboard-toolbar",children:[(0,e.jsx)("input",{type:"text",id:"roles-profile-id",placeholder:n("roles.profileIdPlaceholder"),maxLength:64,ref:Pt,onChange:s=>s.currentTarget.setCustomValidity("")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-select",onClick:()=>{cn()},children:n("roles.openProfile")})]}),(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-profile-search",placeholder:n("roles.profileSearch"),value:z,onChange:s=>ge(s.target.value)}),(0,e.jsx)($e,{id:"roles-profile-refresh",label:n("roles.refresh"),onClick:()=>{dn()}})]}),(0,e.jsx)("div",{id:"roles-profile-list",className:"roles-tree",children:ke?(0,e.jsx)(ce,{label:n("common.loading")}):(0,e.jsx)(An,{profiles:Hr,selectedProfileId:S,tr:n,onSelect:s=>{Tt(s)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:S?(0,e.jsxs)("div",{id:"roles-profile-detail",className:"roles-editor-form roles-profile-detail",children:[(0,e.jsx)("div",{className:"roles-profile-title",children:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{children:S}),Ae?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{children:Ae.botName??Ae.larkAppId})]}):null]}),(0,e.jsx)("div",{className:"roles-editor-meta-line",children:n("roles.profileRuntimeHint")})]})}),(0,e.jsxs)("div",{className:"roles-profile-grid",children:[(0,e.jsxs)("div",{className:"roles-profile-bots",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:n("roles.profileBots")}),(0,e.jsx)("div",{className:"roles-profile-bot-list",children:f.map(s=>{let l=!!me(te,s.larkAppId),i=C===s.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row roles-profile-bot-row ${i?"selected":""}`,"data-profile-bot-id":s.larkAppId,onClick:()=>{an(s.larkAppId)},children:[(0,e.jsx)(Pr,{bot:s}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:s.botName??s.larkAppId}),(0,e.jsx)("div",{className:"roles-bot-id",children:s.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${l?"has-role":"no-role"}`,children:n(l?"roles.configured":"roles.unconfigured")})]},s.larkAppId)})})]}),(0,e.jsx)("div",{className:"roles-profile-editor",children:C?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"roles-profile-editor-head",children:[(0,e.jsxs)("span",{id:"roles-profile-bytecount",className:vr(De),children:[De," / ",O," bytes"]}),(0,e.jsxs)("div",{className:"roles-editor-actions roles-editor-head-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-delete",className:"danger",style:{display:$r?"":"none"},disabled:bt,onClick:()=>{pn()},children:bt?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-save",className:"primary",disabled:yn,onClick:()=>{un()},children:yt?"...":n("roles.saveEntry")})]})]}),(0,e.jsx)("textarea",{id:"roles-profile-textarea",placeholder:n("roles.profileEditorPlaceholder"),rows:12,value:ne,onChange:s=>he(s.target.value)}),(0,e.jsx)("div",{className:"roles-editor-footer",children:(0,e.jsx)(fe,{flash:Dr})}),(0,e.jsx)(br,{content:ne,tr:n,id:"roles-profile-preview"})]}):(0,e.jsx)("div",{className:"roles-editor-empty roles-profile-inline-empty",children:n("roles.profileBotSelectHint")})})]}),(0,e.jsxs)("div",{className:"roles-profile-apply",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:n("roles.applyToGroup")}),(0,e.jsxs)("div",{className:"roles-profile-apply-controls",children:[(0,e.jsx)(Oe,{id:"roles-profile-apply-group",className:"roles-apply-group-menu",ariaLabel:n("roles.applyToGroup"),disabled:c.length===0,label:_e?.name??$??n("roles.noChats"),value:$??"",options:c.map(s=>({value:s.chatId,label:s.name??s.chatId})),onChange:s=>se(s)}),(0,e.jsxs)("label",{className:"roles-profile-force",children:[(0,e.jsx)("input",{type:"checkbox",id:"roles-profile-apply-force",checked:mt,onChange:s=>Br(s.target.checked)})," ",n("roles.applyForce")]})]}),(0,e.jsx)("div",{id:"roles-profile-apply-bots",children:!_e||Pe.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.noChats")}):Pe.map(s=>{let l=!!me(te,s.larkAppId);return(0,e.jsxs)("label",{className:"checkbox-row roles-profile-apply-bot",children:[(0,e.jsx)("input",{type:"checkbox",name:"profile-apply-bot",value:s.larkAppId,checked:ft.has(s.larkAppId),onChange:i=>mn(s.larkAppId,i.target.checked)}),(0,e.jsx)("span",{children:s.botName??s.larkAppId}),(0,e.jsx)("small",{children:n(l?"roles.configured":"roles.profileMissing")})]},s.larkAppId)})}),(0,e.jsxs)("div",{className:"roles-editor-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-preview-apply",onClick:()=>{Mt(!0)},children:n("roles.previewApply")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-apply",className:"primary",onClick:()=>{Mt(!1)},children:n("roles.applyProfile")})]}),(0,e.jsx)("div",{id:"roles-profile-apply-status",className:"roles-profile-status",children:(0,e.jsx)(_n,{status:Gr,bots:f,tr:n})})]})]}):(0,e.jsx)("div",{id:"roles-profile-empty",className:"roles-editor-empty",children:n("roles.profileSelectHint")})})]})]})}function kn(t,n){let r=new Set(t);return r.has(n)?r.delete(n):r.add(n),r}function vr(t){return`roles-bytecount ${t>qt?"warn":""} ${t>O?"over":""}`}function Nn(t){return`roles-bytecount ${t>Kt?"warn":""} ${t>pe?"over":""}`}function fe(t){return t.flash?(0,e.jsxs)("span",{className:`roles-saved-flash ${t.flash.isError?"roles-save-error":""}`,children:[" ",t.flash.text]}):null}function Ln(t){let{tr:n}=t;return t.groups.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.noChats")}):(0,e.jsx)(e.Fragment,{children:t.groups.map(r=>{let o=t.expandedGroups.has(r.chatId),c=r.memberBots.filter(p=>p.inChat),m=Yt(r),f=zt(r);return(0,e.jsxs)("div",{className:"roles-group-section",children:[(0,e.jsxs)("div",{className:`roles-group-row ${o?"expanded":""} ${t.selectedGroupId===r.chatId&&!t.selectedBotId?"selected":""}`,"data-group-id":r.chatId,onClick:()=>t.onToggleGroup(r.chatId),children:[(0,e.jsx)("span",{className:"roles-group-arrow",children:o?"\u25BE":"\u25B8"}),(0,e.jsx)("span",{className:"roles-group-icon","aria-hidden":"true",children:(0,e.jsxs)("svg",{viewBox:"0 0 16 16",children:[(0,e.jsx)("circle",{cx:"5.6",cy:"5.8",r:"2.4"}),(0,e.jsx)("path",{d:"M1.8 13.2c.5-2.4 2-3.6 3.8-3.6s3.3 1.2 3.8 3.6"}),(0,e.jsx)("circle",{cx:"11",cy:"6.8",r:"1.9"}),(0,e.jsx)("path",{d:"M9.8 12.6c.4-1.7 1.5-2.6 2.8-2.6 1 0 1.9.5 2.4 1.6"})]})}),(0,e.jsxs)("div",{className:"roles-group-info",children:[(0,e.jsx)("div",{className:"roles-group-name",children:r.name??r.chatId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[m,"/",f," ",n("roles.botsWithRoles")]}),(0,e.jsx)(Tn,{group:r,profiles:t.profiles,context:t.context,loaded:t.contextLoaded,tr:n})]}),(0,e.jsx)("span",{className:"roles-group-chevron"})]}),(0,e.jsx)("div",{className:"roles-bot-list",children:o?c.map(p=>{let v=t.selectedGroupId===r.chatId&&t.selectedBotId===p.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row ${v?"selected":""}`,"data-group-id":r.chatId,"data-bot-id":p.larkAppId,onClick:T=>{T.stopPropagation(),t.onSelectBot(r.chatId,p.larkAppId)},children:[(0,e.jsx)("span",{className:"roles-bot-indent"}),(0,e.jsx)(Pr,{bot:p}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:p.botName}),(0,e.jsx)("div",{className:"roles-bot-id",children:p.larkAppId})]}),(0,e.jsxs)("div",{className:"roles-bot-badges",children:[(0,e.jsx)("span",{className:`roles-badge ${p.hasRole?"has-role":"no-role"}`,children:p.hasRole?n("roles.configured"):n("roles.unconfigured")}),p.hasMessageListener?(0,e.jsx)("span",{className:"roles-badge has-listener",children:n("roles.listenerBadge")}):null]})]},p.larkAppId)}):null})]},r.chatId)})})}function Tn(t){let{group:n,profiles:r,context:o,loaded:c,tr:m}=t;if(!r.length||!c)return null;let f=new Map;for(let T of n.memberBots)T.inChat&&f.set(T.larkAppId,o.effectiveRolesByBot.get(qe(T.larkAppId,n.chatId))??null);if(!Gt(f))return null;let p=Ft(n.memberBots,r,o.entriesByProfile,f)[0];if(!p)return(0,e.jsx)("div",{className:"roles-profile-match muted",children:m("groups.profileStatusUnmatched")});let v=p.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`roles-profile-match ${p.kind}`,children:m(v,{name:p.profileId,matched:p.matched,total:p.total,chat:p.chatMatched})})}function Mn(t){let{listener:n,tr:r}=t,[o,c]=(0,a.useState)("members"),[m,f]=(0,a.useState)(""),[p,v]=(0,a.useState)(()=>new Set),T=new Set(n.senderPolicy?.includeSenderTypes??[]),xe=new Set(n.messagePolicy?.includeMsgTypes??[]),R=n.senderPolicy?.mode==="all_except_excluded"?"all_except_excluded":"include_only",W=new Set(n.senderPolicy?.includeSenderOpenIds??[]),A=new Set(n.senderPolicy?.excludeSenderOpenIds??[]),Re=[...[...R==="all_except_excluded"?A:W].filter(d=>!t.memberById.has(d))],Y=[...t.members.filter(d=>d.memberType!=="bot"),...Re.map(d=>({openId:d,name:d,memberType:"unknown"}))],ke=t.members.filter(d=>d.memberType==="bot"),_=o==="bots"?ke:Y,F=jt(_,m),k=F.map(d=>d.openId),z=k.filter(d=>p.has(d)),ge=k.length>0&&z.length===k.length,U=[...p].filter(d=>_.some(b=>b.openId===d)),B=U.length>0?U:k,g=Ue({mode:R,include:[...W],exclude:[...A],targetIds:B});(0,a.useEffect)(()=>{f(""),v(new Set)},[o]),(0,a.useEffect)(()=>{let d=new Set(_.map(b=>b.openId));v(b=>{let I=new Set([...b].filter(M=>d.has(M)));return I.size===b.size?b:I})},[_]);let ye=(d,b)=>{v(I=>{let M=new Set(I);return b?M.add(d):M.delete(d),M})},y=()=>{v(d=>{let b=new Set(d);if(ge)for(let I of k)b.delete(I);else for(let I of k)b.add(I);return b})},J=d=>{B.length!==0&&t.onSetTargetsPolicy(B,d)};return(0,e.jsxs)("div",{className:"roles-listener-editor",children:[t.loading?(0,e.jsx)(ce,{label:r("common.loading")}):null,(0,e.jsxs)("label",{className:"filter-toggle roles-listener-enabled",children:[(0,e.jsx)("input",{type:"checkbox",checked:n.enabled,onChange:d=>t.onPatch({enabled:d.currentTarget.checked})}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:r("roles.listenerEnabled")})]}),(0,e.jsx)("p",{className:"roles-listener-scope-help",children:r("roles.listenerScopeHelp")}),(0,e.jsxs)("div",{className:"roles-listener-grid",children:[(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerName")}),(0,e.jsx)("input",{type:"text",value:n.name??"",placeholder:r("roles.listenerNamePlaceholder"),onChange:d=>t.onPatch({name:d.currentTarget.value})})]}),(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerReplyCardTitle")}),(0,e.jsx)("input",{type:"text",value:n.replyCardTitle??"",placeholder:r("roles.listenerReplyCardTitlePlaceholder"),onChange:d=>t.onPatch({replyCardTitle:d.currentTarget.value})})]}),(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerWorkingDir")}),(0,e.jsx)("input",{type:"text",value:n.workingDir??"",placeholder:r("roles.listenerWorkingDirPlaceholder"),onChange:d=>t.onPatch({workingDir:d.currentTarget.value})})]})]}),(0,e.jsxs)("div",{className:"roles-listener-policy-row",children:[(0,e.jsxs)("div",{className:"roles-listener-policy",children:[(0,e.jsx)("div",{className:"roles-field-label",children:r("roles.listenerSenderTypes")}),(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:T.has("user"),onChange:d=>t.onToggleSenderType("user",d.currentTarget.checked)}),(0,e.jsx)("span",{children:r("roles.listenerSenderUser")})]}),(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:T.has("bot"),onChange:d=>t.onToggleSenderType("bot",d.currentTarget.checked)}),(0,e.jsx)("span",{children:r("roles.listenerSenderBot")})]})]}),(0,e.jsxs)("div",{className:"roles-listener-policy",children:[(0,e.jsx)("div",{className:"roles-field-label",children:r("roles.listenerMessageTypes")}),hr.map(d=>(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:xe.has(d),onChange:b=>t.onToggleMsgType(d,b.currentTarget.checked)}),(0,e.jsx)("span",{children:d})]},d))]}),(0,e.jsxs)("label",{className:"roles-listener-checkbox",children:[(0,e.jsx)("input",{type:"checkbox",checked:n.senderPolicy?.excludeSelf!==!1,onChange:d=>t.onSenderPolicyPatch({excludeSelf:d.currentTarget.checked})}),(0,e.jsx)("span",{children:r("roles.listenerExcludeSelf")})]})]}),(0,e.jsx)("div",{className:"roles-listener-policy-row",children:(0,e.jsxs)("div",{className:"roles-listener-policy",children:[(0,e.jsx)("div",{className:"roles-field-label",children:r("roles.listenerSenderMode")}),(0,e.jsxs)("div",{className:"roles-listener-target-tabs segmented",role:"tablist","aria-label":r("roles.listenerSenderMode"),children:[(0,e.jsx)("button",{type:"button",className:R==="include_only"?"active":"","aria-pressed":R==="include_only",onClick:()=>t.onSetSenderMode("include_only"),children:r("roles.listenerSenderModeInclude")}),(0,e.jsx)("button",{type:"button",className:R==="all_except_excluded"?"active":"","aria-pressed":R==="all_except_excluded",onClick:()=>t.onSetSenderMode("all_except_excluded"),children:r("roles.listenerSenderModeAllExcept")})]}),(0,e.jsx)("small",{className:"roles-listener-scope-help",children:r(R==="all_except_excluded"?"roles.listenerSenderModeAllExceptHelp":"roles.listenerSenderModeIncludeHelp")})]})}),(0,e.jsxs)("label",{className:"roles-listener-field",children:[(0,e.jsx)("span",{className:"roles-field-label",children:r("roles.listenerPrompt")}),(0,e.jsx)("textarea",{id:"roles-listener-prompt",placeholder:r("roles.listenerPromptPlaceholder"),rows:9,value:n.prompt,onChange:d=>t.onPatch({prompt:d.currentTarget.value})})]}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-listener-bytecount",className:Nn(t.promptByteLen),children:[t.promptByteLen," / ",pe," bytes"]}),(0,e.jsx)(fe,{flash:t.flash})]}),(0,e.jsxs)("div",{className:"roles-listener-preview-panel",children:[(0,e.jsxs)("div",{className:"roles-listener-preview-head",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:r("roles.listenerPreviewTitle")}),(0,e.jsx)("small",{children:r("roles.listenerPreviewHint")})]}),(0,e.jsxs)("div",{className:"roles-listener-preview-actions",children:[(0,e.jsxs)("label",{children:[(0,e.jsx)("span",{children:r("roles.listenerPreviewCount")}),(0,e.jsx)("select",{value:t.previewLimit,onChange:d=>t.onPreviewLimitChange(Number(d.currentTarget.value)),children:Array.from({length:He},(d,b)=>b+1).map(d=>(0,e.jsx)("option",{value:d,children:d},d))})]}),(0,e.jsx)("button",{type:"button",onClick:t.onPreview,disabled:t.previewStatus.kind==="loading",children:t.previewStatus.kind==="loading"&&t.previewStatus.mode==="preview"?"...":r("roles.listenerPreviewButton")}),(0,e.jsx)("button",{type:"button",className:"primary",onClick:t.onRunPreview,disabled:t.previewStatus.kind==="loading",children:t.previewStatus.kind==="loading"&&t.previewStatus.mode==="run"?"...":r("roles.listenerRunPreviewButton")})]})]}),(0,e.jsx)(Cn,{status:t.previewStatus,tr:r})]}),(0,e.jsxs)("div",{className:"roles-listener-members",children:[(0,e.jsxs)("div",{className:"roles-listener-members-head",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:r("roles.listenerFilters")}),(0,e.jsx)("small",{children:t.membersLoading?r("common.loading"):r("roles.listenerMembersHint")})]}),(0,e.jsxs)("div",{className:"roles-listener-target-tabs segmented",role:"tablist","aria-label":r("roles.listenerFilters"),children:[(0,e.jsx)("button",{type:"button",className:o==="members"?"active":"","aria-pressed":o==="members",onClick:()=>c("members"),children:r("roles.listenerMembers")}),(0,e.jsx)("button",{type:"button",className:o==="bots"?"active":"","aria-pressed":o==="bots",onClick:()=>c("bots"),children:r("roles.listenerBots")})]}),(0,e.jsxs)("div",{className:"roles-listener-filter-toolbar",children:[(0,e.jsx)("input",{type:"search",value:m,placeholder:r("roles.listenerSearchPlaceholder"),onChange:d=>f(d.currentTarget.value)}),m?(0,e.jsx)("button",{type:"button",className:"roles-listener-clear-search",onClick:()=>f(""),"aria-label":r("roles.listenerClearSearch"),children:"\xD7"}):null,(0,e.jsx)("button",{type:"button",className:"roles-listener-select-all",disabled:k.length===0,onClick:y,children:r(ge?"roles.listenerClearVisible":"roles.listenerSelectVisible",{count:k.length})})]}),(0,e.jsxs)("div",{className:"roles-listener-bulkbar",children:[(0,e.jsxs)("span",{children:[U.length>0?r("roles.listenerSelectedCount",{count:U.length}):r("roles.listenerFilteredCount",{count:k.length}),g==="mixed"?` \xB7 ${r("roles.listenerMixedMode")}`:""]}),(0,e.jsxs)("div",{className:"roles-listener-member-actions",role:"group","aria-label":r("roles.listenerBulkActions"),children:[(0,e.jsx)("button",{type:"button",className:g==="listen"?"active":"","aria-pressed":g==="listen",disabled:B.length===0,onClick:()=>J(!0),children:r("roles.listenerTargetListen")}),(0,e.jsx)("button",{type:"button",className:g==="ignore"?"active":"","aria-pressed":g==="ignore",disabled:B.length===0,onClick:()=>J(!1),children:r("roles.listenerTargetIgnore")})]})]}),(0,e.jsx)("div",{className:"roles-listener-member-list",children:F.length===0?(0,e.jsx)("div",{className:"roles-empty",children:r(o==="bots"?"roles.listenerBotsEmpty":"roles.listenerMembersEmpty")}):F.map(d=>{let b=Ue({mode:R,include:[...W],exclude:[...A],targetIds:[d.openId]});return(0,e.jsxs)("div",{className:"roles-listener-member",children:[(0,e.jsx)("label",{className:"roles-listener-member-select","aria-label":Ye(d,d.openId),children:(0,e.jsx)("input",{type:"checkbox",checked:p.has(d.openId),onChange:I=>ye(d.openId,I.currentTarget.checked)})}),(0,e.jsxs)("div",{className:"roles-listener-member-main",children:[(0,e.jsx)("strong",{children:Ye(d,d.openId)}),(0,e.jsx)("span",{children:d.openId})]}),(0,e.jsxs)("div",{className:"roles-listener-member-actions",role:"group","aria-label":Ye(d,d.openId),children:[(0,e.jsx)("button",{type:"button",className:b==="listen"?"active":"","aria-pressed":b==="listen",onClick:()=>t.onSetTargetPolicy(d.openId,!0),children:r("roles.listenerTargetListen")}),(0,e.jsx)("button",{type:"button",className:b==="ignore"?"active":"","aria-pressed":b==="ignore",onClick:()=>t.onSetTargetPolicy(d.openId,!1),children:r("roles.listenerTargetIgnore")})]})]},d.openId)})})]})]})}function br(t){return(0,e.jsx)("div",{id:t.id,className:"roles-preview",children:t.content.trim()?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("strong",{children:t.tr("roles.preview")}),(0,e.jsx)("pre",{children:t.content})]}):(0,e.jsx)("small",{children:t.tr("roles.previewEmpty")})})}function Cn(t){let{status:n,tr:r}=t;if(n.kind==="idle")return(0,e.jsx)("div",{className:"roles-listener-preview-empty",children:r("roles.listenerPreviewEmpty")});if(n.kind==="loading")return(0,e.jsx)(ce,{label:r("common.loading")});if(n.kind==="error")return(0,e.jsx)("div",{className:"roles-listener-preview-error",children:n.text});let o=n.response.matches??[],m=(n.response.results??[]).reduce((f,p)=>{let v=p.ok?p.state??"triggered":"failed";return f[v]=(f[v]??0)+1,f},{});return(0,e.jsxs)("div",{className:"roles-listener-preview-results",children:[(0,e.jsx)("div",{className:"roles-listener-preview-summary",children:n.mode==="run"?r("roles.listenerRunPreviewSummary",{count:o.length,triggered:m.triggered??0,running:m.running??0,replied:m.replied??0,failed:m.failed??0}):r("roles.listenerPreviewSummary",{count:o.length})}),o.length===0?(0,e.jsx)("div",{className:"roles-listener-preview-empty",children:r("roles.listenerPreviewNoMatches")}):(0,e.jsx)("div",{className:"roles-listener-preview-list",children:o.map(f=>(0,e.jsx)(En,{item:f,result:n.response.results?.find(p=>p.messageId===f.messageId),tr:r},f.messageId))})]})}function En(t){let n=t.item.messageText.length>300?`${t.item.messageText.slice(0,300)}...`:t.item.messageText,r=t.item.senderName||t.item.senderOpenId||t.item.senderType,o=lr(t.item.createTime);return(0,e.jsxs)("div",{className:"roles-listener-preview-item",children:[(0,e.jsxs)("div",{className:"roles-listener-preview-meta",children:[(0,e.jsx)("span",{children:t.item.msgType}),(0,e.jsx)("span",{children:t.item.senderType}),t.item.senderOpenId?(0,e.jsx)("span",{children:t.item.senderOpenId}):null,(0,e.jsx)("span",{children:t.item.messageId}),t.result?(0,e.jsx)("span",{className:Sn(t.result.state,t.result.ok),children:t.tr(`roles.listenerRunPreviewState.${t.result.ok?t.result.state??"triggered":"failed"}`)}):null]}),t.result?.sessionId||t.result?.replyMessageId||t.result?.error?(0,e.jsxs)("div",{className:"roles-listener-preview-run-detail",children:[t.result.sessionId?(0,e.jsx)("span",{children:t.result.sessionId}):null,t.result.replyMessageId?(0,e.jsx)("span",{children:t.result.replyMessageId}):null,t.result.error?(0,e.jsx)("strong",{children:t.result.error}):null]}):null,(0,e.jsxs)("div",{className:"roles-listener-preview-sender",children:[(0,e.jsx)("span",{children:t.tr("roles.listenerPreviewSender")}),(0,e.jsx)("strong",{children:r})]}),o?(0,e.jsxs)("div",{className:"roles-listener-preview-time",children:[(0,e.jsx)("span",{children:t.tr("roles.listenerPreviewTime")}),(0,e.jsx)("strong",{children:o})]}):null,t.item.messageTitle?(0,e.jsxs)("div",{className:"roles-listener-preview-title",children:[(0,e.jsx)("span",{children:t.tr("roles.listenerPreviewMessageTitle")}),(0,e.jsx)("strong",{children:t.item.messageTitle})]}):null,(0,e.jsx)("div",{className:"roles-listener-preview-content-label",children:t.tr("roles.listenerPreviewContent")}),(0,e.jsx)("pre",{children:n})]})}function An(t){let{tr:n}=t;return t.profiles.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.profileEmpty")}):(0,e.jsx)(e.Fragment,{children:t.profiles.map(r=>{let o=t.selectedProfileId===r.profileId,c=(r.botEntries??[]).some(m=>m.hasEntry);return(0,e.jsxs)("div",{className:`roles-profile-row ${o?"selected":""}`,"data-profile-id":r.profileId,onClick:()=>t.onSelect(r.profileId),children:[(0,e.jsxs)("div",{className:"roles-profile-row-main",children:[(0,e.jsx)("div",{className:"roles-profile-name",children:r.profileId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[r.entryCount," ",n("roles.profileEntries")]})]}),(0,e.jsx)("span",{className:`roles-badge ${c?"has-role":"no-role"}`,children:n(c?"roles.configured":"roles.profileMissing")})]},r.profileId)})})}function _n(t){let{status:n,bots:r,tr:o}=t;return n.kind==="idle"?null:n.kind==="text"?(0,e.jsx)(e.Fragment,{children:n.text}):(0,e.jsx)(e.Fragment,{children:n.results.map(c=>{let f=r.find(v=>v.larkAppId===c.larkAppId)?.botName??c.larkAppId,p=c.ok?n.preview?c.wouldRefuse?o("roles.applyWouldRefuse"):o("roles.applyPreviewOk"):o("roles.applyOk"):`${o("roles.applyFailed")}: ${String(c.error??`HTTP ${c.status}`)}`;return(0,e.jsxs)("div",{children:[f,": ",p]},c.larkAppId)})})}function qn(t){return Fe(t,(0,e.jsx)(Ir,{tab:"groups"}))}function Kn(t){return Fe(t,(0,e.jsx)(Ir,{tab:"profiles"}))}export{Kn as renderRoleProfilesPage,qn as renderRolesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G,c as F}from"./chunk-2WQDS65D.js";import{g as _,m as B,n as K,o as U,p as j,q as J}from"./chunk-5CJMHTT4.js";import"./chunk-G5XGBCM6.js";import{B as H,E as M}from"./chunk-Q2MT4VWH.js";import{a as q}from"./chunk-SYC6D5XU.js";import{a as Q,d as Z}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var a=L(Q(),1);var e=L(Z(),1),W=1e3;function V(t,l){if(!t)return"\u2014";try{return new Date(t).toLocaleString(void 0,l?{timeZone:l,timeZoneName:"short"}:void 0)}catch{return t}}function X(t,l){let n=l.q.toLowerCase();return t.filter(o=>!l.kind||o.parsed?.kind===l.kind).filter(o=>!l.enabledOnly||o.enabled).filter(o=>!n||JSON.stringify(o).toLowerCase().includes(n)).sort((o,r)=>{if(o.enabled!==r.enabled)return o.enabled?-1:1;let w=o.nextRunAt?Date.parse(o.nextRunAt):1/0,p=r.nextRunAt?Date.parse(r.nextRunAt):1/0;return w-p})}function O(t){return t.deliver==="local"?"local":t.executionPosition==="new-topic"?"new-topic":t.executionPosition==="topic"?t.rootMessageId?"thread":"chat":t.executionPosition==="top-level"?"chat":t.deliver==="new-topic"?"new-topic":t.scope==="chat"?"chat":t.rootMessageId?"thread":"chat"}function Y(t,l){let n=O(t);return l(n==="local"?"schedules.deliveryLocal":n==="new-topic"?"schedules.deliveryNewTopic":n==="thread"?"schedules.deliveryThread":"schedules.deliveryTopLevel")}function ee(t){return t.repeat?`${t.repeat.completed}/${t.repeat.times??"\u221E"}`:"\u2014"}function le(t){return new Promise(l=>window.setTimeout(l,t))}function te(t){let{schedule:l,scheduleTimeZone:n,tr:o}=t,r=M(l),w=String(l.parsed?.kind??"unknown"),p=l.enabled?"pause":"resume",N=`${l.id}:${p}`,b=`${l.id}:run`;return(0,e.jsxs)(K,{kind:"schedule",className:"schedule-list-row","data-id":l.id,children:[(0,e.jsxs)(U,{children:[(0,e.jsxs)("div",{className:"schedule-row-head",children:[(0,e.jsx)("b",{children:l.name??l.id}),(0,e.jsx)("span",{className:`schedule-state ${l.enabled?"enabled":"paused"}`,children:l.enabled?o("schedules.enabled"):o("schedules.paused")})]}),(0,e.jsxs)("div",{className:"schedule-row-meta",children:[(0,e.jsx)("span",{children:l.botName??l.larkAppId??"-"}),(0,e.jsx)("span",{children:"\xB7"}),(0,e.jsx)("code",{children:l.parsed?.display??"?"})]}),(0,e.jsxs)("div",{className:"schedule-chip-strip",children:[(0,e.jsx)("span",{children:w}),l.chatId?(0,e.jsxs)("span",{className:"schedule-chat-chip",title:r?`${r} \xB7 ${String(l.chatId)}`:String(l.chatId),children:[o("schedules.form.chat"),": ",r??l.chatId]}):null,(0,e.jsxs)("span",{children:[o("schedules.delivery"),": ",Y(l,o)]}),l.silent?(0,e.jsxs)("span",{children:["\u{1F507} ",o("schedules.silent")]}):null,(0,e.jsxs)("span",{children:[o("schedules.next"),": ",V(l.nextRunAt,n)]}),(0,e.jsxs)("span",{children:[o("schedules.last"),": ",V(l.lastRunAt,n)]}),l.lastStatus==="error"?(0,e.jsxs)("span",{className:"schedule-error-chip",title:typeof l.lastError=="string"?l.lastError:void 0,children:["\u26A0 ",o("schedules.error"),": ",typeof l.lastError=="string"&&l.lastError.length>60?l.lastError.slice(0,60)+"\u2026":l.lastError??o("schedules.errorUnknown")]}):null,(0,e.jsxs)("span",{children:[o("schedules.repeat"),": ",ee(l)]})]})]}),(0,e.jsx)(j,{children:(0,e.jsxs)("div",{className:"schedule-actions",children:[(0,e.jsx)(oe,{op:"run",label:o("schedules.runNow"),pending:t.pending===b,feedback:t.feedback[b]??null,onClick:()=>t.onAction(l.id,"run")}),(0,e.jsx)(ce,{checked:!!l.enabled,pending:t.pending===N,feedback:t.feedback[N]??null,tr:o,onClick:()=>t.onAction(l.id,p)}),(0,e.jsx)("button",{type:"button",className:"schedule-action-button schedule-edit-button",onClick:()=>t.onEdit(l),title:o("schedules.edit"),children:(0,e.jsx)("span",{className:"schedule-action-label",children:o("schedules.edit")})}),(0,e.jsx)("button",{type:"button",className:"schedule-action-button schedule-delete-button",onClick:()=>t.onDelete(l),title:o("schedules.delete"),children:(0,e.jsx)("span",{className:"schedule-action-label",children:o("schedules.delete")})})]})})]})}function se(){let t=F(),{scheduleRows:l,scheduleTimeZone:n}=G(s=>({scheduleRows:[...s.schedules.values()],scheduleTimeZone:s.scheduleTimeZone})),[o,r]=(0,a.useState)({q:"",kind:"",enabledOnly:!1}),[w,p]=(0,a.useState)(null),[N,b]=(0,a.useState)({}),k=(0,a.useRef)(new Map),[P,y]=(0,a.useState)(!1),[u,T]=(0,a.useState)(null),[S,A]=(0,a.useState)(null),[C,E]=(0,a.useState)([]),[,I]=(0,a.useState)(0);(0,a.useEffect)(()=>{fetch("/api/bots").then(s=>s.json()).then(s=>{Array.isArray(s?.bots)&&E(s.bots)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{H().then(()=>I(s=>s+1))},[]);let R=(0,a.useMemo)(()=>X(l,o),[l,o]);(0,a.useEffect)(()=>()=>{k.current.forEach(s=>window.clearTimeout(s)),k.current.clear()},[]);function m(s,c){b(f=>({...f,[s]:c}));let d=k.current.get(s);d&&window.clearTimeout(d);let v=window.setTimeout(()=>{b(f=>{let h={...f};return delete h[s],h}),k.current.delete(s)},c==="success"?1600:2200);k.current.set(s,v)}async function x(s,c){let d=`${s}:${c}`,v=performance.now(),f="success";p(d);try{let h=await fetch(`/api/schedules/${encodeURIComponent(s)}/${c}`,{method:"POST"}),D=await h.json().catch(()=>({}));if(!h.ok||D.ok===!1)throw new Error(`Failed: ${h.status} ${D?.error??""}`.trim())}catch{f="error"}finally{if(c==="run"){let h=W-(performance.now()-v);h>0&&await le(h)}m(d,f),p(h=>h===d?null:h)}}function g(){T(null),A(null),y(!0)}function $(s){T(s),A(null),y(!0)}async function i(s){if(!window.confirm(t("schedules.deleteConfirm")))return;let c=`${s.id}:delete`;p(c);try{let d=await fetch(`/api/schedules/${encodeURIComponent(s.id)}`,{method:"DELETE"}),v=await d.json().catch(()=>({}));if(!d.ok||v.ok===!1)throw new Error(v?.error??`HTTP ${d.status}`);m(c,"success")}catch{m(c,"error")}finally{p(d=>d===c?null:d)}}async function z(s){A(null);try{let c=u?`/api/schedules/${encodeURIComponent(u.id)}`:"/api/schedules",d=u?"PATCH":"POST",v=u?{name:s.name,schedule:s.schedule,prompt:s.prompt,silent:s.silent,...s.updateExecutionPosition?{executionPosition:s.executionPosition,rootMessageId:s.rootMessageId,topicTitle:s.topicTitle}:{}}:{name:s.name,schedule:s.schedule,prompt:s.prompt,silent:s.silent,executionPosition:s.executionPosition,rootMessageId:s.rootMessageId,topicTitle:s.topicTitle,chatId:s.chatId,larkAppId:s.larkAppId},f=await fetch(c,{method:d,headers:{"Content-Type":"application/json"},body:JSON.stringify(v)}),h=await f.json().catch(()=>({}));if(!f.ok||h.ok===!1)throw new Error(h?.error??`HTTP ${f.status}`);y(!1)}catch(c){A(c instanceof Error?c.message:String(c))}}return(0,e.jsxs)("section",{className:"page schedules-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("nav.schedules")}),(0,e.jsx)("h1",{children:t("schedules.title")})]}),(0,e.jsx)(_,{onClick:g,disabled:C.length===0,children:t("schedules.create")})]}),(0,e.jsxs)("form",{id:"sched-filters",className:"filters dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",name:"q",placeholder:t("schedules.search"),value:o.q,onChange:s=>{let c=s.currentTarget.value;r(d=>({...d,q:c}))}}),(0,e.jsx)(J,{id:"sched-kind-menu",ariaLabel:t("schedules.anyKind"),label:o.kind||t("schedules.anyKind"),value:o.kind,options:[{value:"",label:t("schedules.anyKind")},{value:"cron",label:"cron"},{value:"interval",label:"interval"},{value:"once",label:"once"}],onChange:s=>r(c=>({...c,kind:s}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",name:"enabled",checked:o.enabledOnly,onChange:s=>{let c=s.currentTarget.checked;r(d=>({...d,enabledOnly:c}))}}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("schedules.enabledOnly")}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"})]}),(0,e.jsx)("span",{className:"schedules-toolbar-spacer","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"schedules-toolbar-count",children:[R.length,"/",l.length]})]}),(0,e.jsx)("section",{className:"overview-block schedules-list-section",children:(0,e.jsx)("div",{className:"schedules-list-wrap",children:R.length===0?(0,e.jsx)("div",{id:"schedules-tbody",className:"empty schedules-list-empty",children:t("schedules.empty")}):(0,e.jsx)(B,{id:"schedules-tbody",className:"schedules-list",children:R.map(s=>(0,e.jsx)(te,{schedule:s,scheduleTimeZone:n,pending:w,feedback:N,tr:t,onAction:(c,d)=>{x(c,d)},onEdit:$,onDelete:c=>{i(c)}},s.id))})})}),P?(0,e.jsx)(ae,{editing:u,error:S,bots:C,tr:t,onClose:()=>y(!1),onSubmit:s=>{z(s)}}):null]})}function ne(t,l,n,o,r){return n?r(t==="run"?"schedules.running":"schedules.saving"):o==="success"?r(t==="run"?"schedules.runDone":"schedules.saved"):o==="error"?r("schedules.failed"):l}function oe(t){let l=F(),n=t.feedback?` is-${t.feedback}`:"";return(0,e.jsx)("button",{type:"button",className:`schedule-action-button${t.pending?" is-pending":""}${n}`,"data-op":t.op,disabled:t.pending,onClick:t.onClick,children:(0,e.jsx)("span",{className:"schedule-action-label",children:ne(t.op,t.label,t.pending,t.feedback,l)})})}function ce(t){let l=t.feedback==="error"?t.tr("schedules.failed"):t.checked?t.tr("schedules.enabled"):t.tr("schedules.paused");return(0,e.jsxs)("button",{type:"button",className:`schedule-enabled-switch${t.checked?" is-on":""}${t.pending?" is-pending":""}${t.feedback?` is-${t.feedback}`:""}`,"aria-pressed":t.checked,disabled:t.pending,onClick:t.onClick,children:[(0,e.jsx)("span",{className:"schedule-enabled-switch-label",children:l}),(0,e.jsx)("span",{className:"schedule-enabled-switch-track","aria-hidden":"true",children:(0,e.jsx)("span",{})})]})}function he(t){return q(t,(0,e.jsx)(se,{}))}function ae(t){let{editing:l,tr:n,bots:o}=t,[r,w]=(0,a.useState)(l?.name??""),[p,N]=(0,a.useState)(l?.schedule??""),[b,k]=(0,a.useState)(l?.prompt??""),[P,y]=(0,a.useState)(l?.silent===!0),[u,T]=(0,a.useState)(l&&O(l)==="thread"?"topic":l&&O(l)==="new-topic"?"new-topic":"top-level"),[S,A]=(0,a.useState)(l?.rootMessageId??""),[C,E]=(0,a.useState)(l?.topicTitle??""),[I,R]=(0,a.useState)(l?.chatId??""),[m,x]=(0,a.useState)(l?.larkAppId??o[0]?.larkAppId??""),g=l?.deliver==="local";(0,a.useEffect)(()=>{!l&&!m&&o.length>0&&x(o[0].larkAppId)},[l,m,o]);function $(i){i.preventDefault(),!(!l&&!m)&&(!g&&u==="topic"&&!S.trim()||t.onSubmit({name:r,schedule:p,prompt:b,silent:P,executionPosition:u,rootMessageId:S.trim(),topicTitle:C.trim(),updateExecutionPosition:!g,chatId:I,larkAppId:m}))}return(0,e.jsx)("div",{className:"schedule-form-overlay",onClick:t.onClose,children:(0,e.jsxs)("div",{className:"schedule-form-dialog",role:"dialog","aria-modal":"true",onClick:i=>i.stopPropagation(),children:[(0,e.jsx)("h2",{children:n(l?"schedules.edit":"schedules.create")}),(0,e.jsxs)("form",{onSubmit:$,className:"schedule-form",children:[l?null:(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.bot")}),(0,e.jsx)("select",{value:m,onChange:i=>x(i.target.value),required:!0,children:o.map(i=>(0,e.jsx)("option",{value:i.larkAppId,children:i.botName??i.larkAppId},i.larkAppId))})]}),(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.name")}),(0,e.jsx)("input",{type:"text",value:r,onChange:i=>w(i.target.value),required:!0,autoFocus:!0})]}),(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.schedule")}),(0,e.jsx)("input",{type:"text",value:p,onChange:i=>N(i.target.value),placeholder:n("schedules.form.scheduleHelp"),required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.scheduleHelp")})]}),(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.prompt")}),(0,e.jsx)("textarea",{value:b,onChange:i=>k(i.target.value),rows:4,required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.promptHelp")})]}),l?(0,e.jsxs)("div",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.chat")}),(0,e.jsx)("code",{title:I,children:M(l)??I})]}):(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.chat")}),(0,e.jsx)("input",{type:"text",value:I,onChange:i=>R(i.target.value),placeholder:"oc_...",required:!0})]}),g?(0,e.jsxs)("div",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.deliver")}),(0,e.jsxs)("div",{className:"schedule-form-placement",children:[(0,e.jsx)("strong",{children:n("schedules.deliveryLocal")}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.localHelp")})]})]}):(0,e.jsxs)("div",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.deliver")}),(0,e.jsxs)("div",{className:"schedule-form-radio-group",children:[(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"top-level",checked:u==="top-level",onChange:()=>T("top-level")}),n("schedules.deliveryTopLevel")]}),(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"topic",checked:u==="topic",onChange:()=>T("topic")}),n("schedules.deliveryThread")]}),(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"new-topic",checked:u==="new-topic",onChange:()=>{T("new-topic"),y(!1)}}),n("schedules.deliveryNewTopic")]})]}),(0,e.jsx)("small",{className:"schedule-form-help",children:n(u==="top-level"?"schedules.form.topLevelHelp":u==="topic"?"schedules.form.topicHelp":"schedules.form.newTopicHelp")})]}),!g&&u==="topic"?(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.topicRoot")}),(0,e.jsx)("input",{type:"text",value:S,onChange:i=>A(i.target.value),placeholder:"om_...",required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.topicRootHelp")})]}):null,!g&&u==="new-topic"?(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.topicTitle")}),(0,e.jsx)("input",{type:"text",value:C,onChange:i=>E(i.target.value),placeholder:n("schedules.form.topicTitlePlaceholder"),maxLength:200}),(0,e.jsxs)("small",{className:"schedule-form-help schedule-form-help-with-count",children:[n("schedules.form.topicTitleHelp"),(0,e.jsxs)("span",{children:[Array.from(C).length,"/200"]})]})]}):null,(0,e.jsxs)("label",{className:"schedule-form-field schedule-form-toggle",children:[(0,e.jsx)("input",{type:"checkbox",checked:P,onChange:i=>y(i.target.checked)}),(0,e.jsxs)("span",{children:[n("schedules.form.silent"),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.silentHelp")})]})]}),u==="new-topic"&&P?(0,e.jsx)("p",{className:"schedule-form-help",children:n("schedules.form.silentNewTopicConflict")}):null,t.error?(0,e.jsx)("p",{className:"schedule-form-error",children:t.error}):null,(0,e.jsxs)("div",{className:"schedule-form-actions",children:[(0,e.jsx)("button",{type:"button",className:"schedule-form-cancel",onClick:t.onClose,children:n("schedules.form.cancel")}),(0,e.jsx)("button",{type:"submit",className:"schedule-form-submit",disabled:!l&&!m||!g&&u==="topic"&&!S.trim(),children:n(l?"schedules.form.save":"schedules.form.create")})]})]})]})})}export{X as filterSchedules,V as fmtScheduleDate,he as renderSchedulesPage,O as scheduleExecutionPlacement};
|
|
1
|
+
import{g as B,m as K,n as U,o as j,p as J,q as G}from"./chunk-5CJMHTT4.js";import{b as Z,d as F}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import{G as H,J as M}from"./chunk-F6KNPF4R.js";import{a as q}from"./chunk-SYC6D5XU.js";import{a as Q,d as _}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var a=L(Q(),1);var e=L(_(),1),W=1e3;function V(t,l){if(!t)return"\u2014";try{return new Date(t).toLocaleString(void 0,l?{timeZone:l,timeZoneName:"short"}:void 0)}catch{return t}}function X(t,l){let n=l.q.toLowerCase();return t.filter(o=>!l.kind||o.parsed?.kind===l.kind).filter(o=>!l.enabledOnly||o.enabled).filter(o=>!n||JSON.stringify(o).toLowerCase().includes(n)).sort((o,r)=>{if(o.enabled!==r.enabled)return o.enabled?-1:1;let w=o.nextRunAt?Date.parse(o.nextRunAt):1/0,p=r.nextRunAt?Date.parse(r.nextRunAt):1/0;return w-p})}function O(t){return t.deliver==="local"?"local":t.executionPosition==="new-topic"?"new-topic":t.executionPosition==="topic"?t.rootMessageId?"thread":"chat":t.executionPosition==="top-level"?"chat":t.deliver==="new-topic"?"new-topic":t.scope==="chat"?"chat":t.rootMessageId?"thread":"chat"}function Y(t,l){let n=O(t);return l(n==="local"?"schedules.deliveryLocal":n==="new-topic"?"schedules.deliveryNewTopic":n==="thread"?"schedules.deliveryThread":"schedules.deliveryTopLevel")}function ee(t){return t.repeat?`${t.repeat.completed}/${t.repeat.times??"\u221E"}`:"\u2014"}function le(t){return new Promise(l=>window.setTimeout(l,t))}function te(t){let{schedule:l,scheduleTimeZone:n,tr:o}=t,r=M(l),w=String(l.parsed?.kind??"unknown"),p=l.enabled?"pause":"resume",N=`${l.id}:${p}`,b=`${l.id}:run`;return(0,e.jsxs)(U,{kind:"schedule",className:"schedule-list-row","data-id":l.id,children:[(0,e.jsxs)(j,{children:[(0,e.jsxs)("div",{className:"schedule-row-head",children:[(0,e.jsx)("b",{children:l.name??l.id}),(0,e.jsx)("span",{className:`schedule-state ${l.enabled?"enabled":"paused"}`,children:l.enabled?o("schedules.enabled"):o("schedules.paused")})]}),(0,e.jsxs)("div",{className:"schedule-row-meta",children:[(0,e.jsx)("span",{children:l.botName??l.larkAppId??"-"}),(0,e.jsx)("span",{children:"\xB7"}),(0,e.jsx)("code",{children:l.parsed?.display??"?"})]}),(0,e.jsxs)("div",{className:"schedule-chip-strip",children:[(0,e.jsx)("span",{children:w}),l.chatId?(0,e.jsxs)("span",{className:"schedule-chat-chip",title:r?`${r} \xB7 ${String(l.chatId)}`:String(l.chatId),children:[o("schedules.form.chat"),": ",r??l.chatId]}):null,(0,e.jsxs)("span",{children:[o("schedules.delivery"),": ",Y(l,o)]}),l.silent?(0,e.jsxs)("span",{children:["\u{1F507} ",o("schedules.silent")]}):null,(0,e.jsxs)("span",{children:[o("schedules.next"),": ",V(l.nextRunAt,n)]}),(0,e.jsxs)("span",{children:[o("schedules.last"),": ",V(l.lastRunAt,n)]}),l.lastStatus==="error"?(0,e.jsxs)("span",{className:"schedule-error-chip",title:typeof l.lastError=="string"?l.lastError:void 0,children:["\u26A0 ",o("schedules.error"),": ",typeof l.lastError=="string"&&l.lastError.length>60?l.lastError.slice(0,60)+"\u2026":l.lastError??o("schedules.errorUnknown")]}):null,(0,e.jsxs)("span",{children:[o("schedules.repeat"),": ",ee(l)]})]})]}),(0,e.jsx)(J,{children:(0,e.jsxs)("div",{className:"schedule-actions",children:[(0,e.jsx)(oe,{op:"run",label:o("schedules.runNow"),pending:t.pending===b,feedback:t.feedback[b]??null,onClick:()=>t.onAction(l.id,"run")}),(0,e.jsx)(ce,{checked:!!l.enabled,pending:t.pending===N,feedback:t.feedback[N]??null,tr:o,onClick:()=>t.onAction(l.id,p)}),(0,e.jsx)("button",{type:"button",className:"schedule-action-button schedule-edit-button",onClick:()=>t.onEdit(l),title:o("schedules.edit"),children:(0,e.jsx)("span",{className:"schedule-action-label",children:o("schedules.edit")})}),(0,e.jsx)("button",{type:"button",className:"schedule-action-button schedule-delete-button",onClick:()=>t.onDelete(l),title:o("schedules.delete"),children:(0,e.jsx)("span",{className:"schedule-action-label",children:o("schedules.delete")})})]})})]})}function se(){let t=F(),{scheduleRows:l,scheduleTimeZone:n}=Z(s=>({scheduleRows:[...s.schedules.values()],scheduleTimeZone:s.scheduleTimeZone})),[o,r]=(0,a.useState)({q:"",kind:"",enabledOnly:!1}),[w,p]=(0,a.useState)(null),[N,b]=(0,a.useState)({}),k=(0,a.useRef)(new Map),[P,y]=(0,a.useState)(!1),[u,T]=(0,a.useState)(null),[S,A]=(0,a.useState)(null),[C,E]=(0,a.useState)([]),[,I]=(0,a.useState)(0);(0,a.useEffect)(()=>{fetch("/api/bots").then(s=>s.json()).then(s=>{Array.isArray(s?.bots)&&E(s.bots)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{H().then(()=>I(s=>s+1))},[]);let R=(0,a.useMemo)(()=>X(l,o),[l,o]);(0,a.useEffect)(()=>()=>{k.current.forEach(s=>window.clearTimeout(s)),k.current.clear()},[]);function m(s,c){b(f=>({...f,[s]:c}));let d=k.current.get(s);d&&window.clearTimeout(d);let v=window.setTimeout(()=>{b(f=>{let h={...f};return delete h[s],h}),k.current.delete(s)},c==="success"?1600:2200);k.current.set(s,v)}async function x(s,c){let d=`${s}:${c}`,v=performance.now(),f="success";p(d);try{let h=await fetch(`/api/schedules/${encodeURIComponent(s)}/${c}`,{method:"POST"}),D=await h.json().catch(()=>({}));if(!h.ok||D.ok===!1)throw new Error(`Failed: ${h.status} ${D?.error??""}`.trim())}catch{f="error"}finally{if(c==="run"){let h=W-(performance.now()-v);h>0&&await le(h)}m(d,f),p(h=>h===d?null:h)}}function g(){T(null),A(null),y(!0)}function $(s){T(s),A(null),y(!0)}async function i(s){if(!window.confirm(t("schedules.deleteConfirm")))return;let c=`${s.id}:delete`;p(c);try{let d=await fetch(`/api/schedules/${encodeURIComponent(s.id)}`,{method:"DELETE"}),v=await d.json().catch(()=>({}));if(!d.ok||v.ok===!1)throw new Error(v?.error??`HTTP ${d.status}`);m(c,"success")}catch{m(c,"error")}finally{p(d=>d===c?null:d)}}async function z(s){A(null);try{let c=u?`/api/schedules/${encodeURIComponent(u.id)}`:"/api/schedules",d=u?"PATCH":"POST",v=u?{name:s.name,schedule:s.schedule,prompt:s.prompt,silent:s.silent,...s.updateExecutionPosition?{executionPosition:s.executionPosition,rootMessageId:s.rootMessageId,topicTitle:s.topicTitle}:{}}:{name:s.name,schedule:s.schedule,prompt:s.prompt,silent:s.silent,executionPosition:s.executionPosition,rootMessageId:s.rootMessageId,topicTitle:s.topicTitle,chatId:s.chatId,larkAppId:s.larkAppId},f=await fetch(c,{method:d,headers:{"Content-Type":"application/json"},body:JSON.stringify(v)}),h=await f.json().catch(()=>({}));if(!f.ok||h.ok===!1)throw new Error(h?.error??`HTTP ${f.status}`);y(!1)}catch(c){A(c instanceof Error?c.message:String(c))}}return(0,e.jsxs)("section",{className:"page schedules-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("nav.schedules")}),(0,e.jsx)("h1",{children:t("schedules.title")})]}),(0,e.jsx)(B,{onClick:g,disabled:C.length===0,children:t("schedules.create")})]}),(0,e.jsxs)("form",{id:"sched-filters",className:"filters dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",name:"q",placeholder:t("schedules.search"),value:o.q,onChange:s=>{let c=s.currentTarget.value;r(d=>({...d,q:c}))}}),(0,e.jsx)(G,{id:"sched-kind-menu",ariaLabel:t("schedules.anyKind"),label:o.kind||t("schedules.anyKind"),value:o.kind,options:[{value:"",label:t("schedules.anyKind")},{value:"cron",label:"cron"},{value:"interval",label:"interval"},{value:"once",label:"once"}],onChange:s=>r(c=>({...c,kind:s}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",name:"enabled",checked:o.enabledOnly,onChange:s=>{let c=s.currentTarget.checked;r(d=>({...d,enabledOnly:c}))}}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("schedules.enabledOnly")}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"})]}),(0,e.jsx)("span",{className:"schedules-toolbar-spacer","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"schedules-toolbar-count",children:[R.length,"/",l.length]})]}),(0,e.jsx)("section",{className:"overview-block schedules-list-section",children:(0,e.jsx)("div",{className:"schedules-list-wrap",children:R.length===0?(0,e.jsx)("div",{id:"schedules-tbody",className:"empty schedules-list-empty",children:t("schedules.empty")}):(0,e.jsx)(K,{id:"schedules-tbody",className:"schedules-list",children:R.map(s=>(0,e.jsx)(te,{schedule:s,scheduleTimeZone:n,pending:w,feedback:N,tr:t,onAction:(c,d)=>{x(c,d)},onEdit:$,onDelete:c=>{i(c)}},s.id))})})}),P?(0,e.jsx)(ae,{editing:u,error:S,bots:C,tr:t,onClose:()=>y(!1),onSubmit:s=>{z(s)}}):null]})}function ne(t,l,n,o,r){return n?r(t==="run"?"schedules.running":"schedules.saving"):o==="success"?r(t==="run"?"schedules.runDone":"schedules.saved"):o==="error"?r("schedules.failed"):l}function oe(t){let l=F(),n=t.feedback?` is-${t.feedback}`:"";return(0,e.jsx)("button",{type:"button",className:`schedule-action-button${t.pending?" is-pending":""}${n}`,"data-op":t.op,disabled:t.pending,onClick:t.onClick,children:(0,e.jsx)("span",{className:"schedule-action-label",children:ne(t.op,t.label,t.pending,t.feedback,l)})})}function ce(t){let l=t.feedback==="error"?t.tr("schedules.failed"):t.checked?t.tr("schedules.enabled"):t.tr("schedules.paused");return(0,e.jsxs)("button",{type:"button",className:`schedule-enabled-switch${t.checked?" is-on":""}${t.pending?" is-pending":""}${t.feedback?` is-${t.feedback}`:""}`,"aria-pressed":t.checked,disabled:t.pending,onClick:t.onClick,children:[(0,e.jsx)("span",{className:"schedule-enabled-switch-label",children:l}),(0,e.jsx)("span",{className:"schedule-enabled-switch-track","aria-hidden":"true",children:(0,e.jsx)("span",{})})]})}function he(t){return q(t,(0,e.jsx)(se,{}))}function ae(t){let{editing:l,tr:n,bots:o}=t,[r,w]=(0,a.useState)(l?.name??""),[p,N]=(0,a.useState)(l?.schedule??""),[b,k]=(0,a.useState)(l?.prompt??""),[P,y]=(0,a.useState)(l?.silent===!0),[u,T]=(0,a.useState)(l&&O(l)==="thread"?"topic":l&&O(l)==="new-topic"?"new-topic":"top-level"),[S,A]=(0,a.useState)(l?.rootMessageId??""),[C,E]=(0,a.useState)(l?.topicTitle??""),[I,R]=(0,a.useState)(l?.chatId??""),[m,x]=(0,a.useState)(l?.larkAppId??o[0]?.larkAppId??""),g=l?.deliver==="local";(0,a.useEffect)(()=>{!l&&!m&&o.length>0&&x(o[0].larkAppId)},[l,m,o]);function $(i){i.preventDefault(),!(!l&&!m)&&(!g&&u==="topic"&&!S.trim()||t.onSubmit({name:r,schedule:p,prompt:b,silent:P,executionPosition:u,rootMessageId:S.trim(),topicTitle:C.trim(),updateExecutionPosition:!g,chatId:I,larkAppId:m}))}return(0,e.jsx)("div",{className:"schedule-form-overlay",onClick:t.onClose,children:(0,e.jsxs)("div",{className:"schedule-form-dialog",role:"dialog","aria-modal":"true",onClick:i=>i.stopPropagation(),children:[(0,e.jsx)("h2",{children:n(l?"schedules.edit":"schedules.create")}),(0,e.jsxs)("form",{onSubmit:$,className:"schedule-form",children:[l?null:(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.bot")}),(0,e.jsx)("select",{value:m,onChange:i=>x(i.target.value),required:!0,children:o.map(i=>(0,e.jsx)("option",{value:i.larkAppId,children:i.botName??i.larkAppId},i.larkAppId))})]}),(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.name")}),(0,e.jsx)("input",{type:"text",value:r,onChange:i=>w(i.target.value),required:!0,autoFocus:!0})]}),(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.schedule")}),(0,e.jsx)("input",{type:"text",value:p,onChange:i=>N(i.target.value),placeholder:n("schedules.form.scheduleHelp"),required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.scheduleHelp")})]}),(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.prompt")}),(0,e.jsx)("textarea",{value:b,onChange:i=>k(i.target.value),rows:4,required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.promptHelp")})]}),l?(0,e.jsxs)("div",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.chat")}),(0,e.jsx)("code",{title:I,children:M(l)??I})]}):(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.chat")}),(0,e.jsx)("input",{type:"text",value:I,onChange:i=>R(i.target.value),placeholder:"oc_...",required:!0})]}),g?(0,e.jsxs)("div",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.deliver")}),(0,e.jsxs)("div",{className:"schedule-form-placement",children:[(0,e.jsx)("strong",{children:n("schedules.deliveryLocal")}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.localHelp")})]})]}):(0,e.jsxs)("div",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.deliver")}),(0,e.jsxs)("div",{className:"schedule-form-radio-group",children:[(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"top-level",checked:u==="top-level",onChange:()=>T("top-level")}),n("schedules.deliveryTopLevel")]}),(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"topic",checked:u==="topic",onChange:()=>T("topic")}),n("schedules.deliveryThread")]}),(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"new-topic",checked:u==="new-topic",onChange:()=>{T("new-topic"),y(!1)}}),n("schedules.deliveryNewTopic")]})]}),(0,e.jsx)("small",{className:"schedule-form-help",children:n(u==="top-level"?"schedules.form.topLevelHelp":u==="topic"?"schedules.form.topicHelp":"schedules.form.newTopicHelp")})]}),!g&&u==="topic"?(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.topicRoot")}),(0,e.jsx)("input",{type:"text",value:S,onChange:i=>A(i.target.value),placeholder:"om_...",required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.topicRootHelp")})]}):null,!g&&u==="new-topic"?(0,e.jsxs)("label",{className:"schedule-form-field",children:[(0,e.jsx)("span",{className:"schedule-form-label",children:n("schedules.form.topicTitle")}),(0,e.jsx)("input",{type:"text",value:C,onChange:i=>E(i.target.value),placeholder:n("schedules.form.topicTitlePlaceholder"),maxLength:200}),(0,e.jsxs)("small",{className:"schedule-form-help schedule-form-help-with-count",children:[n("schedules.form.topicTitleHelp"),(0,e.jsxs)("span",{children:[Array.from(C).length,"/200"]})]})]}):null,(0,e.jsxs)("label",{className:"schedule-form-field schedule-form-toggle",children:[(0,e.jsx)("input",{type:"checkbox",checked:P,onChange:i=>y(i.target.checked)}),(0,e.jsxs)("span",{children:[n("schedules.form.silent"),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.silentHelp")})]})]}),u==="new-topic"&&P?(0,e.jsx)("p",{className:"schedule-form-help",children:n("schedules.form.silentNewTopicConflict")}):null,t.error?(0,e.jsx)("p",{className:"schedule-form-error",children:t.error}):null,(0,e.jsxs)("div",{className:"schedule-form-actions",children:[(0,e.jsx)("button",{type:"button",className:"schedule-form-cancel",onClick:t.onClose,children:n("schedules.form.cancel")}),(0,e.jsx)("button",{type:"submit",className:"schedule-form-submit",disabled:!l&&!m||!g&&u==="topic"&&!S.trim(),children:n(l?"schedules.form.save":"schedules.form.create")})]})]})]})})}export{X as filterSchedules,V as fmtScheduleDate,he as renderSchedulesPage,O as scheduleExecutionPlacement};
|