botmux 3.7.1 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.runtime-build-id +1 -1
- package/dist/adapters/backend/capabilities.d.ts +17 -0
- package/dist/adapters/backend/capabilities.d.ts.map +1 -0
- package/dist/adapters/backend/capabilities.js +22 -0
- package/dist/adapters/backend/capabilities.js.map +1 -0
- package/dist/adapters/backend/critical-control-key.d.ts +19 -0
- package/dist/adapters/backend/critical-control-key.d.ts.map +1 -0
- package/dist/adapters/backend/critical-control-key.js +34 -0
- package/dist/adapters/backend/critical-control-key.js.map +1 -0
- package/dist/adapters/backend/herdr-backend.d.ts +9 -0
- package/dist/adapters/backend/herdr-backend.d.ts.map +1 -1
- package/dist/adapters/backend/herdr-backend.js +23 -4
- package/dist/adapters/backend/herdr-backend.js.map +1 -1
- package/dist/adapters/backend/riff-backend.d.ts.map +1 -1
- package/dist/adapters/backend/riff-backend.js +3 -2
- package/dist/adapters/backend/riff-backend.js.map +1 -1
- package/dist/adapters/backend/session-backend-selector.d.ts +61 -6
- package/dist/adapters/backend/session-backend-selector.d.ts.map +1 -1
- package/dist/adapters/backend/session-backend-selector.js +173 -9
- package/dist/adapters/backend/session-backend-selector.js.map +1 -1
- package/dist/adapters/backend/tmux-backend.d.ts +10 -3
- package/dist/adapters/backend/tmux-backend.d.ts.map +1 -1
- package/dist/adapters/backend/tmux-backend.js +25 -8
- package/dist/adapters/backend/tmux-backend.js.map +1 -1
- package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -1
- package/dist/adapters/backend/tmux-pipe-backend.js +3 -2
- package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -1
- package/dist/adapters/backend/types.d.ts +45 -4
- package/dist/adapters/backend/types.d.ts.map +1 -1
- package/dist/adapters/backend/types.js +11 -0
- package/dist/adapters/backend/types.js.map +1 -1
- package/dist/adapters/backend/zellij-backend.d.ts.map +1 -1
- package/dist/adapters/backend/zellij-backend.js +3 -2
- package/dist/adapters/backend/zellij-backend.js.map +1 -1
- package/dist/adapters/backend/zmx-backend.d.ts +286 -0
- package/dist/adapters/backend/zmx-backend.d.ts.map +1 -0
- package/dist/adapters/backend/zmx-backend.js +2396 -0
- package/dist/adapters/backend/zmx-backend.js.map +1 -0
- package/dist/adapters/cli/claude-code.d.ts.map +1 -1
- package/dist/adapters/cli/claude-code.js +3 -0
- package/dist/adapters/cli/claude-code.js.map +1 -1
- package/dist/adapters/cli/codex-app.d.ts.map +1 -1
- package/dist/adapters/cli/codex-app.js +5 -1
- 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 +26 -1
- package/dist/adapters/cli/codex.js.map +1 -1
- package/dist/adapters/cli/fs-policy.d.ts +79 -1
- package/dist/adapters/cli/fs-policy.d.ts.map +1 -1
- package/dist/adapters/cli/fs-policy.js +290 -13
- package/dist/adapters/cli/fs-policy.js.map +1 -1
- package/dist/adapters/cli/grok.d.ts.map +1 -1
- package/dist/adapters/cli/grok.js +4 -1
- package/dist/adapters/cli/grok.js.map +1 -1
- package/dist/adapters/cli/oh-my-pi.d.ts.map +1 -1
- package/dist/adapters/cli/oh-my-pi.js +5 -3
- package/dist/adapters/cli/oh-my-pi.js.map +1 -1
- package/dist/adapters/cli/shared-hints.d.ts +7 -4
- package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
- package/dist/adapters/cli/shared-hints.js +52 -35
- package/dist/adapters/cli/shared-hints.js.map +1 -1
- package/dist/adapters/cli/strict-input-handle.d.ts +13 -0
- package/dist/adapters/cli/strict-input-handle.d.ts.map +1 -0
- package/dist/adapters/cli/strict-input-handle.js +39 -0
- package/dist/adapters/cli/strict-input-handle.js.map +1 -0
- package/dist/adapters/cli/traex.d.ts.map +1 -1
- package/dist/adapters/cli/traex.js +6 -4
- package/dist/adapters/cli/traex.js.map +1 -1
- package/dist/adapters/cli/types.d.ts +16 -0
- package/dist/adapters/cli/types.d.ts.map +1 -1
- package/dist/bot-registry.d.ts +137 -8
- package/dist/bot-registry.d.ts.map +1 -1
- package/dist/bot-registry.js +298 -12
- package/dist/bot-registry.js.map +1 -1
- package/dist/cli/session-list-liveness.d.ts +1 -1
- package/dist/cli/session-list-liveness.js +1 -1
- package/dist/cli/zmx-managed-attach.d.ts +41 -0
- package/dist/cli/zmx-managed-attach.d.ts.map +1 -0
- package/dist/cli/zmx-managed-attach.js +72 -0
- package/dist/cli/zmx-managed-attach.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +780 -131
- package/dist/cli.js.map +1 -1
- package/dist/codex-app-runner.js +90 -2
- package/dist/codex-app-runner.js.map +1 -1
- package/dist/codex-rpc-engine.d.ts.map +1 -1
- package/dist/codex-rpc-engine.js +22 -6
- package/dist/codex-rpc-engine.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +29 -1
- package/dist/config.js.map +1 -1
- package/dist/core/ask-broker.d.ts +22 -1
- package/dist/core/ask-broker.d.ts.map +1 -1
- package/dist/core/ask-broker.js +12 -5
- package/dist/core/ask-broker.js.map +1 -1
- package/dist/core/botmux-wrapper.d.ts +18 -0
- package/dist/core/botmux-wrapper.d.ts.map +1 -1
- package/dist/core/botmux-wrapper.js +25 -1
- package/dist/core/botmux-wrapper.js.map +1 -1
- package/dist/core/chat-rename.d.ts +27 -0
- package/dist/core/chat-rename.d.ts.map +1 -0
- package/dist/core/chat-rename.js +53 -0
- package/dist/core/chat-rename.js.map +1 -0
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +160 -12
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/cost-calculator.d.ts +25 -1
- package/dist/core/cost-calculator.d.ts.map +1 -1
- package/dist/core/cost-calculator.js +102 -4
- package/dist/core/cost-calculator.js.map +1 -1
- package/dist/core/dashboard-ipc-server.d.ts +16 -2
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
- package/dist/core/dashboard-ipc-server.js +611 -62
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/core/dashboard-rows.d.ts +22 -1
- package/dist/core/dashboard-rows.d.ts.map +1 -1
- package/dist/core/dashboard-rows.js +61 -0
- package/dist/core/dashboard-rows.js.map +1 -1
- package/dist/core/dashboard-url.d.ts +6 -0
- package/dist/core/dashboard-url.d.ts.map +1 -1
- package/dist/core/dashboard-url.js +11 -1
- package/dist/core/dashboard-url.js.map +1 -1
- package/dist/core/device-isolation-daemon.d.ts +28 -6
- package/dist/core/device-isolation-daemon.d.ts.map +1 -1
- package/dist/core/device-isolation-daemon.js +96 -13
- package/dist/core/device-isolation-daemon.js.map +1 -1
- package/dist/core/host-overload-alert.d.ts +75 -0
- package/dist/core/host-overload-alert.d.ts.map +1 -1
- package/dist/core/host-overload-alert.js +103 -0
- package/dist/core/host-overload-alert.js.map +1 -1
- package/dist/core/idle-worker-sweeper.js +1 -1
- package/dist/core/idle-worker-sweeper.js.map +1 -1
- package/dist/core/inflight-input-tracker.d.ts +3 -0
- package/dist/core/inflight-input-tracker.d.ts.map +1 -1
- package/dist/core/inflight-input-tracker.js +9 -0
- package/dist/core/inflight-input-tracker.js.map +1 -1
- package/dist/core/passthrough-commands.d.ts.map +1 -1
- package/dist/core/passthrough-commands.js +10 -0
- package/dist/core/passthrough-commands.js.map +1 -1
- package/dist/core/persistent-backend.d.ts +32 -4
- package/dist/core/persistent-backend.d.ts.map +1 -1
- package/dist/core/persistent-backend.js +75 -6
- package/dist/core/persistent-backend.js.map +1 -1
- package/dist/core/plugins/mcp/gateway.js +2 -2
- package/dist/core/plugins/mcp/gateway.js.map +1 -1
- package/dist/core/plugins/runtime.d.ts +3 -0
- package/dist/core/plugins/runtime.d.ts.map +1 -1
- package/dist/core/plugins/runtime.js.map +1 -1
- package/dist/core/plugins/service-manager.d.ts +4 -1
- package/dist/core/plugins/service-manager.d.ts.map +1 -1
- package/dist/core/plugins/service-manager.js +11 -6
- package/dist/core/plugins/service-manager.js.map +1 -1
- package/dist/core/role-library.d.ts +48 -1
- package/dist/core/role-library.d.ts.map +1 -1
- package/dist/core/role-library.js +111 -3
- package/dist/core/role-library.js.map +1 -1
- package/dist/core/role-resolver.d.ts +14 -2
- package/dist/core/role-resolver.d.ts.map +1 -1
- package/dist/core/role-resolver.js +47 -4
- package/dist/core/role-resolver.js.map +1 -1
- package/dist/core/session-activity.d.ts +14 -0
- package/dist/core/session-activity.d.ts.map +1 -1
- package/dist/core/session-activity.js +46 -1
- package/dist/core/session-activity.js.map +1 -1
- package/dist/core/session-board.d.ts +5 -2
- package/dist/core/session-board.d.ts.map +1 -1
- package/dist/core/session-board.js +5 -2
- package/dist/core/session-board.js.map +1 -1
- package/dist/core/session-liveness.d.ts +6 -5
- package/dist/core/session-liveness.d.ts.map +1 -1
- package/dist/core/session-liveness.js +34 -13
- package/dist/core/session-liveness.js.map +1 -1
- package/dist/core/session-manager.d.ts +3 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +397 -103
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-marker.d.ts +11 -2
- package/dist/core/session-marker.d.ts.map +1 -1
- package/dist/core/session-marker.js +50 -11
- package/dist/core/session-marker.js.map +1 -1
- package/dist/core/session-message-preview.d.ts +20 -0
- package/dist/core/session-message-preview.d.ts.map +1 -0
- package/dist/core/session-message-preview.js +188 -0
- package/dist/core/session-message-preview.js.map +1 -0
- package/dist/core/session-title.d.ts +5 -1
- package/dist/core/session-title.d.ts.map +1 -1
- package/dist/core/session-title.js +20 -3
- package/dist/core/session-title.js.map +1 -1
- package/dist/core/startup-commands.d.ts +1 -1
- package/dist/core/startup-commands.js +1 -1
- package/dist/core/terminal-url.d.ts.map +1 -1
- package/dist/core/terminal-url.js +3 -2
- package/dist/core/terminal-url.js.map +1 -1
- package/dist/core/trigger-session.d.ts.map +1 -1
- package/dist/core/trigger-session.js +75 -12
- package/dist/core/trigger-session.js.map +1 -1
- package/dist/core/types.d.ts +35 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +23 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-ipc.d.ts +11 -0
- package/dist/core/worker-ipc.d.ts.map +1 -0
- package/dist/core/worker-ipc.js +26 -0
- package/dist/core/worker-ipc.js.map +1 -0
- package/dist/core/worker-pool.d.ts +179 -29
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +2118 -331
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts +132 -3
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +1327 -449
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/auth.d.ts +2 -0
- package/dist/dashboard/auth.d.ts.map +1 -1
- package/dist/dashboard/auth.js +9 -0
- package/dist/dashboard/auth.js.map +1 -1
- package/dist/dashboard/bot-payload.d.ts +4 -0
- package/dist/dashboard/bot-payload.d.ts.map +1 -1
- package/dist/dashboard/bot-payload.js +5 -0
- package/dist/dashboard/bot-payload.js.map +1 -1
- package/dist/dashboard/federation-api.d.ts.map +1 -1
- package/dist/dashboard/federation-api.js +4 -0
- package/dist/dashboard/federation-api.js.map +1 -1
- package/dist/dashboard/federation-spoke-api.d.ts.map +1 -1
- package/dist/dashboard/federation-spoke-api.js +32 -5
- package/dist/dashboard/federation-spoke-api.js.map +1 -1
- package/dist/dashboard/public-redact.d.ts +8 -2
- package/dist/dashboard/public-redact.d.ts.map +1 -1
- package/dist/dashboard/public-redact.js +34 -7
- package/dist/dashboard/public-redact.js.map +1 -1
- package/dist/dashboard/session-card-model.d.ts.map +1 -1
- package/dist/dashboard/session-card-model.js +10 -2
- package/dist/dashboard/session-card-model.js.map +1 -1
- package/dist/dashboard/settings-write-applier.d.ts +35 -1
- package/dist/dashboard/settings-write-applier.d.ts.map +1 -1
- package/dist/dashboard/settings-write-applier.js +88 -1
- package/dist/dashboard/settings-write-applier.js.map +1 -1
- package/dist/dashboard/web/app.d.ts.map +1 -1
- package/dist/dashboard/web/app.js +0 -1
- package/dist/dashboard/web/app.js.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.d.ts +15 -0
- package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.js +212 -58
- package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
- package/dist/dashboard/web/bot-defaults.d.ts +3 -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/bot-onboarding.d.ts +2 -1
- package/dist/dashboard/web/bot-onboarding.d.ts.map +1 -1
- package/dist/dashboard/web/bot-onboarding.js.map +1 -1
- package/dist/dashboard/web/clipboard.d.ts +2 -0
- package/dist/dashboard/web/clipboard.d.ts.map +1 -0
- package/dist/dashboard/web/clipboard.js +42 -0
- package/dist/dashboard/web/clipboard.js.map +1 -0
- package/dist/dashboard/web/connectors-page.d.ts.map +1 -1
- package/dist/dashboard/web/connectors-page.js +12 -8
- package/dist/dashboard/web/connectors-page.js.map +1 -1
- package/dist/dashboard/web/dashboard-components.d.ts +17 -16
- package/dist/dashboard/web/dashboard-components.d.ts.map +1 -1
- package/dist/dashboard/web/dashboard-components.js.map +1 -1
- package/dist/dashboard/web/groups-page.d.ts.map +1 -1
- package/dist/dashboard/web/groups-page.js +7 -3
- 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 +205 -12
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/icon-tooltip.d.ts.map +1 -1
- package/dist/dashboard/web/icon-tooltip.js +16 -1
- package/dist/dashboard/web/icon-tooltip.js.map +1 -1
- package/dist/dashboard/web/listener-filters.d.ts +23 -0
- package/dist/dashboard/web/listener-filters.d.ts.map +1 -0
- package/dist/dashboard/web/listener-filters.js +36 -0
- package/dist/dashboard/web/listener-filters.js.map +1 -0
- package/dist/dashboard/web/overview-page.d.ts.map +1 -1
- package/dist/dashboard/web/overview-page.js.map +1 -1
- package/dist/dashboard/web/plugin-page.d.ts.map +1 -1
- package/dist/dashboard/web/plugin-page.js.map +1 -1
- package/dist/dashboard/web/preview-markdown.d.ts +5 -0
- package/dist/dashboard/web/preview-markdown.d.ts.map +1 -0
- package/dist/dashboard/web/preview-markdown.js +52 -0
- package/dist/dashboard/web/preview-markdown.js.map +1 -0
- package/dist/dashboard/web/roles-page.d.ts.map +1 -1
- package/dist/dashboard/web/roles-page.js +535 -10
- package/dist/dashboard/web/roles-page.js.map +1 -1
- package/dist/dashboard/web/roles.d.ts +77 -0
- package/dist/dashboard/web/roles.d.ts.map +1 -1
- package/dist/dashboard/web/roles.js +98 -0
- package/dist/dashboard/web/roles.js.map +1 -1
- package/dist/dashboard/web/session-terminal.d.ts.map +1 -1
- package/dist/dashboard/web/session-terminal.js +6 -4
- package/dist/dashboard/web/session-terminal.js.map +1 -1
- package/dist/dashboard/web/sessions-kanban.d.ts +4 -1
- package/dist/dashboard/web/sessions-kanban.d.ts.map +1 -1
- package/dist/dashboard/web/sessions-kanban.js +1 -1
- package/dist/dashboard/web/sessions-kanban.js.map +1 -1
- package/dist/dashboard/web/sessions-page.d.ts +3 -2
- package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
- package/dist/dashboard/web/sessions-page.js +163 -28
- package/dist/dashboard/web/sessions-page.js.map +1 -1
- package/dist/dashboard/web/sessions.d.ts +25 -0
- package/dist/dashboard/web/sessions.d.ts.map +1 -1
- package/dist/dashboard/web/sessions.js +58 -7
- package/dist/dashboard/web/sessions.js.map +1 -1
- package/dist/dashboard/web/settings-page.d.ts +28 -3
- package/dist/dashboard/web/settings-page.d.ts.map +1 -1
- package/dist/dashboard/web/settings-page.js +61 -1
- package/dist/dashboard/web/settings-page.js.map +1 -1
- package/dist/dashboard/web/skills-page.d.ts +6 -5
- package/dist/dashboard/web/skills-page.d.ts.map +1 -1
- package/dist/dashboard/web/skills-page.js +2 -0
- package/dist/dashboard/web/skills-page.js.map +1 -1
- package/dist/dashboard/web/v3-components.d.ts +3 -2
- package/dist/dashboard/web/v3-components.d.ts.map +1 -1
- package/dist/dashboard/web/v3-components.js.map +1 -1
- package/dist/dashboard/web/vc-consumer-profiles-section.d.ts +12 -2
- package/dist/dashboard/web/vc-consumer-profiles-section.d.ts.map +1 -1
- package/dist/dashboard/web/vc-consumer-profiles-section.js +0 -9
- package/dist/dashboard/web/vc-consumer-profiles-section.js.map +1 -1
- package/dist/dashboard/web/webhook-logs-page.d.ts +2 -1
- package/dist/dashboard/web/webhook-logs-page.d.ts.map +1 -1
- package/dist/dashboard/web/webhook-logs-page.js +4 -1
- package/dist/dashboard/web/webhook-logs-page.js.map +1 -1
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/bot-defaults-page-FAPIMQV3.js +10 -0
- package/dist/dashboard-web/chunks/{chunk-QFMH6ITB.js → chunk-5CJMHTT4.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-KQB42ML5.js → chunk-DLZK52JU.js} +14 -12
- package/dist/dashboard-web/chunks/chunk-FDZ7WOBW.js +16 -0
- package/dist/dashboard-web/chunks/{chunk-3QAUJXAS.js → chunk-GTAJV5YC.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-FNPGOZMX.js → chunk-IHNG6KE6.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-FLGXZJTD.js → chunk-VA6QWSGQ.js} +1 -1
- package/dist/dashboard-web/chunks/chunk-XJ7BGPJH.js +1 -0
- package/dist/dashboard-web/chunks/chunk-ZJVTGU5X.js +1 -0
- package/dist/dashboard-web/chunks/connectors-page-LKWRT3GS.js +1 -0
- package/dist/dashboard-web/chunks/groups-page-V6654ICQ.js +8 -0
- package/dist/dashboard-web/chunks/insights-page-237RMFQ5.js +7 -0
- package/dist/dashboard-web/chunks/{monitor-room-7IVIS75W.js → monitor-room-OO5Y4FRQ.js} +1 -1
- package/dist/dashboard-web/chunks/{monitoring-page-5SSJRQZF.js → monitoring-page-OUEITM5P.js} +1 -1
- package/dist/dashboard-web/chunks/{office-page-EOND3L5D.js → office-page-4KNAHQ4Q.js} +1 -1
- package/dist/dashboard-web/chunks/{overview-page-NISBVBBJ.js → overview-page-QDP4YK2S.js} +1 -1
- package/dist/dashboard-web/chunks/{plugin-page-JXC5F5YV.js → plugin-page-VEGTCEAS.js} +1 -1
- package/dist/dashboard-web/chunks/roles-page-PGXNZZNP.js +1 -0
- package/dist/dashboard-web/chunks/{schedules-page-AVOOKLUH.js → schedules-page-BJNC5TID.js} +1 -1
- package/dist/dashboard-web/chunks/sessions-page-M2ZYYCMO.js +6 -0
- package/dist/dashboard-web/chunks/settings-page-IJFZKUUW.js +2 -0
- package/dist/dashboard-web/chunks/{skills-page-5MW54PCC.js → skills-page-YRAIRZOQ.js} +3 -3
- package/dist/dashboard-web/chunks/{team-federation-page-2SNIMVXI.js → team-federation-page-DEU27GRU.js} +1 -1
- package/dist/dashboard-web/chunks/{v3-page-W6SBXXQC.js → v3-page-6KHEW2YL.js} +5 -5
- package/dist/dashboard-web/chunks/{whiteboards-page-STC54KTP.js → whiteboards-page-VDECAALH.js} +1 -1
- package/dist/dashboard-web/style.css +12545 -11432
- package/dist/dashboard.js +215 -36
- package/dist/dashboard.js.map +1 -1
- package/dist/global-config.d.ts +41 -2
- package/dist/global-config.d.ts.map +1 -1
- package/dist/global-config.js +47 -0
- package/dist/global-config.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +71 -19
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +71 -19
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/callback-button-marker.d.ts +34 -0
- package/dist/im/lark/callback-button-marker.d.ts.map +1 -0
- package/dist/im/lark/callback-button-marker.js +99 -0
- package/dist/im/lark/callback-button-marker.js.map +1 -0
- package/dist/im/lark/card-builder.d.ts +46 -10
- package/dist/im/lark/card-builder.d.ts.map +1 -1
- package/dist/im/lark/card-builder.js +299 -78
- package/dist/im/lark/card-builder.js.map +1 -1
- package/dist/im/lark/card-handler.d.ts +3 -4
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +380 -148
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/client.d.ts +24 -1
- package/dist/im/lark/client.d.ts.map +1 -1
- package/dist/im/lark/client.js +101 -8
- package/dist/im/lark/client.js.map +1 -1
- package/dist/im/lark/doc-comment.d.ts.map +1 -1
- package/dist/im/lark/doc-comment.js +6 -1
- package/dist/im/lark/doc-comment.js.map +1 -1
- package/dist/im/lark/event-dispatcher.d.ts +115 -3
- package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
- package/dist/im/lark/event-dispatcher.js +534 -147
- package/dist/im/lark/event-dispatcher.js.map +1 -1
- package/dist/im/lark/grant-command.d.ts +16 -12
- package/dist/im/lark/grant-command.d.ts.map +1 -1
- package/dist/im/lark/grant-command.js +48 -151
- package/dist/im/lark/grant-command.js.map +1 -1
- package/dist/im/lark/grant-pending.d.ts +12 -4
- package/dist/im/lark/grant-pending.d.ts.map +1 -1
- package/dist/im/lark/grant-pending.js +31 -8
- package/dist/im/lark/grant-pending.js.map +1 -1
- package/dist/im/lark/invite-command.d.ts +20 -0
- package/dist/im/lark/invite-command.d.ts.map +1 -0
- package/dist/im/lark/invite-command.js +239 -0
- package/dist/im/lark/invite-command.js.map +1 -0
- package/dist/im/lark/md-card.d.ts +66 -4
- package/dist/im/lark/md-card.d.ts.map +1 -1
- package/dist/im/lark/md-card.js +201 -31
- package/dist/im/lark/md-card.js.map +1 -1
- package/dist/im/lark/mention-targets.d.ts +43 -0
- package/dist/im/lark/mention-targets.d.ts.map +1 -0
- package/dist/im/lark/mention-targets.js +190 -0
- package/dist/im/lark/mention-targets.js.map +1 -0
- package/dist/im/lark/message-parser.d.ts +31 -0
- package/dist/im/lark/message-parser.d.ts.map +1 -1
- package/dist/im/lark/message-parser.js +305 -32
- package/dist/im/lark/message-parser.js.map +1 -1
- package/dist/im/lark/reply-card-footer-signature.d.ts +7 -0
- package/dist/im/lark/reply-card-footer-signature.d.ts.map +1 -0
- package/dist/im/lark/reply-card-footer-signature.js +7 -0
- package/dist/im/lark/reply-card-footer-signature.js.map +1 -0
- package/dist/im/lark/sessions-card.d.ts.map +1 -1
- package/dist/im/lark/sessions-card.js +4 -1
- package/dist/im/lark/sessions-card.js.map +1 -1
- package/dist/im/lark/substitute-command.d.ts.map +1 -1
- package/dist/im/lark/substitute-command.js +8 -0
- package/dist/im/lark/substitute-command.js.map +1 -1
- package/dist/im/lark/topic-root-context.d.ts +35 -0
- package/dist/im/lark/topic-root-context.d.ts.map +1 -0
- package/dist/im/lark/topic-root-context.js +37 -0
- package/dist/im/lark/topic-root-context.js.map +1 -0
- package/dist/im/lark/v3-blocked-card.d.ts.map +1 -1
- package/dist/im/lark/v3-blocked-card.js +2 -1
- package/dist/im/lark/v3-blocked-card.js.map +1 -1
- package/dist/im/lark/v3-gate-card.d.ts.map +1 -1
- package/dist/im/lark/v3-gate-card.js +2 -1
- package/dist/im/lark/v3-gate-card.js.map +1 -1
- package/dist/im/lark/v3-loop-grant-card.d.ts.map +1 -1
- package/dist/im/lark/v3-loop-grant-card.js +2 -1
- package/dist/im/lark/v3-loop-grant-card.js.map +1 -1
- package/dist/im/lark/v3-progress-card.d.ts.map +1 -1
- package/dist/im/lark/v3-progress-card.js +2 -1
- package/dist/im/lark/v3-progress-card.js.map +1 -1
- package/dist/im/lark/v3-revisit-grant-card.d.ts.map +1 -1
- package/dist/im/lark/v3-revisit-grant-card.js +2 -1
- package/dist/im/lark/v3-revisit-grant-card.js.map +1 -1
- package/dist/index-core-only.d.ts +3 -0
- package/dist/index-core-only.d.ts.map +1 -0
- package/dist/index-core-only.js +107 -0
- package/dist/index-core-only.js.map +1 -0
- package/dist/services/async-trigger-state.d.ts +8 -0
- package/dist/services/async-trigger-state.d.ts.map +1 -1
- package/dist/services/async-trigger-state.js +3 -2
- package/dist/services/async-trigger-state.js.map +1 -1
- package/dist/services/async-trigger-store.d.ts +10 -2
- package/dist/services/async-trigger-store.d.ts.map +1 -1
- package/dist/services/async-trigger-store.js +3 -2
- package/dist/services/async-trigger-store.js.map +1 -1
- package/dist/services/backend-availability.d.ts +3 -1
- package/dist/services/backend-availability.d.ts.map +1 -1
- package/dist/services/backend-availability.js +14 -1
- package/dist/services/backend-availability.js.map +1 -1
- package/dist/services/backend-type-store.d.ts.map +1 -1
- package/dist/services/backend-type-store.js +1 -1
- package/dist/services/backend-type-store.js.map +1 -1
- package/dist/services/bot-config-store.d.ts.map +1 -1
- package/dist/services/bot-config-store.js +2 -1
- package/dist/services/bot-config-store.js.map +1 -1
- package/dist/services/bridge-fallback-gate.d.ts +14 -1
- package/dist/services/bridge-fallback-gate.d.ts.map +1 -1
- package/dist/services/bridge-fallback-gate.js +65 -1
- package/dist/services/bridge-fallback-gate.js.map +1 -1
- package/dist/services/card-prefs-store.d.ts +7 -2
- package/dist/services/card-prefs-store.d.ts.map +1 -1
- package/dist/services/card-prefs-store.js +30 -4
- package/dist/services/card-prefs-store.js.map +1 -1
- package/dist/services/codex-app-runner-protocol.d.ts +9 -0
- package/dist/services/codex-app-runner-protocol.d.ts.map +1 -1
- package/dist/services/codex-app-runner-protocol.js +17 -0
- package/dist/services/codex-app-runner-protocol.js.map +1 -1
- package/dist/services/codex-app-token-usage.d.ts +93 -0
- package/dist/services/codex-app-token-usage.d.ts.map +1 -0
- package/dist/services/codex-app-token-usage.js +190 -0
- package/dist/services/codex-app-token-usage.js.map +1 -0
- package/dist/services/codex-transcript.d.ts +6 -1
- package/dist/services/codex-transcript.d.ts.map +1 -1
- package/dist/services/codex-transcript.js +103 -32
- package/dist/services/codex-transcript.js.map +1 -1
- package/dist/services/federation-roster.d.ts +4 -0
- package/dist/services/federation-roster.d.ts.map +1 -1
- package/dist/services/federation-roster.js +3 -0
- package/dist/services/federation-roster.js.map +1 -1
- package/dist/services/federation-store.d.ts +6 -0
- package/dist/services/federation-store.d.ts.map +1 -1
- package/dist/services/federation-store.js.map +1 -1
- package/dist/services/grant-policy.d.ts +13 -0
- package/dist/services/grant-policy.d.ts.map +1 -0
- package/dist/services/grant-policy.js +40 -0
- package/dist/services/grant-policy.js.map +1 -0
- package/dist/services/grant-store.d.ts +24 -3
- package/dist/services/grant-store.d.ts.map +1 -1
- package/dist/services/grant-store.js +196 -12
- package/dist/services/grant-store.js.map +1 -1
- package/dist/services/groups-store.d.ts +36 -0
- package/dist/services/groups-store.d.ts.map +1 -1
- package/dist/services/groups-store.js +123 -1
- package/dist/services/groups-store.js.map +1 -1
- package/dist/services/jsonl-cursor.d.ts.map +1 -1
- package/dist/services/jsonl-cursor.js +8 -2
- package/dist/services/jsonl-cursor.js.map +1 -1
- package/dist/services/local-cli-opener.d.ts.map +1 -1
- package/dist/services/local-cli-opener.js +32 -0
- package/dist/services/local-cli-opener.js.map +1 -1
- package/dist/services/message-listener-run-preview-store.d.ts +43 -0
- package/dist/services/message-listener-run-preview-store.d.ts.map +1 -0
- package/dist/services/message-listener-run-preview-store.js +152 -0
- package/dist/services/message-listener-run-preview-store.js.map +1 -0
- package/dist/services/message-listener-store.d.ts +26 -0
- package/dist/services/message-listener-store.d.ts.map +1 -0
- package/dist/services/message-listener-store.js +138 -0
- package/dist/services/message-listener-store.js.map +1 -0
- package/dist/services/message-listener.d.ts +112 -0
- package/dist/services/message-listener.d.ts.map +1 -0
- package/dist/services/message-listener.js +391 -0
- package/dist/services/message-listener.js.map +1 -0
- package/dist/services/overload-alert-migration.d.ts +15 -0
- package/dist/services/overload-alert-migration.d.ts.map +1 -0
- package/dist/services/overload-alert-migration.js +115 -0
- package/dist/services/overload-alert-migration.js.map +1 -0
- package/dist/services/send-policy.d.ts +38 -0
- package/dist/services/send-policy.d.ts.map +1 -1
- package/dist/services/send-policy.js +34 -0
- package/dist/services/send-policy.js.map +1 -1
- package/dist/services/session-store.d.ts +12 -1
- package/dist/services/session-store.d.ts.map +1 -1
- package/dist/services/session-store.js +44 -2
- package/dist/services/session-store.js.map +1 -1
- package/dist/services/skill-registry-store.d.ts.map +1 -1
- package/dist/services/skill-registry-store.js +87 -12
- package/dist/services/skill-registry-store.js.map +1 -1
- package/dist/services/substitute-mode-normalize.d.ts +3 -0
- package/dist/services/substitute-mode-normalize.d.ts.map +1 -1
- package/dist/services/substitute-mode-normalize.js +8 -0
- package/dist/services/substitute-mode-normalize.js.map +1 -1
- package/dist/services/substitute-mode-store.d.ts.map +1 -1
- package/dist/services/substitute-mode-store.js +8 -1
- package/dist/services/substitute-mode-store.js.map +1 -1
- package/dist/services/transcript-resolver.d.ts +6 -1
- package/dist/services/transcript-resolver.d.ts.map +1 -1
- package/dist/services/transcript-resolver.js +145 -29
- package/dist/services/transcript-resolver.js.map +1 -1
- package/dist/services/trigger-types.d.ts +16 -0
- package/dist/services/trigger-types.d.ts.map +1 -1
- package/dist/services/trigger-types.js +6 -0
- package/dist/services/trigger-types.js.map +1 -1
- package/dist/setup/bot-config-editor.js +2 -2
- package/dist/setup/bot-config-editor.js.map +1 -1
- package/dist/setup/ensure-zmx.d.ts +31 -0
- package/dist/setup/ensure-zmx.d.ts.map +1 -0
- package/dist/setup/ensure-zmx.js +161 -0
- package/dist/setup/ensure-zmx.js.map +1 -0
- package/dist/setup/index.d.ts +1 -1
- package/dist/setup/index.js +1 -1
- package/dist/setup/open-platform-automation.d.ts +9 -0
- package/dist/setup/open-platform-automation.d.ts.map +1 -1
- package/dist/setup/open-platform-automation.js +15 -2
- package/dist/setup/open-platform-automation.js.map +1 -1
- package/dist/setup/setup-args.d.ts +1 -1
- package/dist/setup/setup-args.d.ts.map +1 -1
- package/dist/setup/setup-args.js +1 -1
- package/dist/skills/definitions.d.ts.map +1 -1
- package/dist/skills/definitions.js +32 -0
- package/dist/skills/definitions.js.map +1 -1
- package/dist/skills/injection-mode.d.ts +6 -2
- package/dist/skills/injection-mode.d.ts.map +1 -1
- package/dist/skills/injection-mode.js +10 -5
- package/dist/skills/injection-mode.js.map +1 -1
- package/dist/types.d.ts +79 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/child-env.d.ts +1 -1
- package/dist/utils/child-env.d.ts.map +1 -1
- package/dist/utils/child-env.js +4 -0
- package/dist/utils/child-env.js.map +1 -1
- package/dist/utils/effort-confirm-dialog.d.ts +40 -0
- package/dist/utils/effort-confirm-dialog.d.ts.map +1 -0
- package/dist/utils/effort-confirm-dialog.js +74 -0
- package/dist/utils/effort-confirm-dialog.js.map +1 -0
- package/dist/utils/pending-input-queue.d.ts +56 -0
- package/dist/utils/pending-input-queue.d.ts.map +1 -1
- package/dist/utils/pending-input-queue.js +80 -0
- package/dist/utils/pending-input-queue.js.map +1 -1
- package/dist/utils/render-dimensions.d.ts +8 -0
- package/dist/utils/render-dimensions.d.ts.map +1 -1
- package/dist/utils/render-dimensions.js +10 -0
- package/dist/utils/render-dimensions.js.map +1 -1
- package/dist/utils/stuck-key-guard.d.ts +3 -2
- package/dist/utils/stuck-key-guard.d.ts.map +1 -1
- package/dist/utils/stuck-key-guard.js +3 -3
- package/dist/utils/stuck-key-guard.js.map +1 -1
- package/dist/utils/terminal-renderer.d.ts +6 -0
- package/dist/utils/terminal-renderer.d.ts.map +1 -1
- package/dist/utils/terminal-renderer.js +15 -0
- package/dist/utils/terminal-renderer.js.map +1 -1
- package/dist/utils/tui-input-delivery.d.ts +32 -0
- package/dist/utils/tui-input-delivery.d.ts.map +1 -0
- package/dist/utils/tui-input-delivery.js +53 -0
- package/dist/utils/tui-input-delivery.js.map +1 -0
- package/dist/utils/xml.d.ts +19 -0
- package/dist/utils/xml.d.ts.map +1 -0
- package/dist/utils/xml.js +26 -0
- package/dist/utils/xml.js.map +1 -0
- package/dist/worker.js +1852 -374
- package/dist/worker.js.map +1 -1
- package/dist/workflows/definition.d.ts +8 -8
- package/dist/workflows/events/payloads.d.ts +8 -8
- package/dist/workflows/events/schema.d.ts +160 -160
- package/dist/workflows/v3/session-relay-client.js +1 -1
- package/dist/workflows/v3/session-relay-client.js.map +1 -1
- package/dist/workflows/v3/worker-fence.d.ts.map +1 -1
- package/dist/workflows/v3/worker-fence.js +15 -10
- package/dist/workflows/v3/worker-fence.js.map +1 -1
- package/package.json +1 -1
- package/dist/dashboard-web/chunks/bot-defaults-page-UKA7K4JV.js +0 -10
- package/dist/dashboard-web/chunks/chunk-DFLNXQNT.js +0 -1
- package/dist/dashboard-web/chunks/connectors-page-A77YAB5Y.js +0 -1
- package/dist/dashboard-web/chunks/groups-page-RUZNVXQB.js +0 -8
- package/dist/dashboard-web/chunks/insights-page-RF7U7RTA.js +0 -22
- package/dist/dashboard-web/chunks/roles-page-BUMKD7Y4.js +0 -1
- package/dist/dashboard-web/chunks/sessions-page-6HLSEAB7.js +0 -2
- package/dist/dashboard-web/chunks/settings-page-MJDZHQ4X.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as w}from"./chunk-
|
|
1
|
+
import{c as w}from"./chunk-VA6QWSGQ.js";import"./chunk-DLZK52JU.js";import{a as p}from"./chunk-SYC6D5XU.js";import{a as S,d as x}from"./chunk-5THX4DI2.js";import{c as g}from"./chunk-7SZRL6FY.js";var n=g(S(),1);var e=g(x(),1),u=78222186;function y(t){return(t/1048576).toFixed(0)}function T(){let t=w(),[i,a]=(0,n.useState)(null),[c,l]=(0,n.useState)(""),[m,h]=(0,n.useState)(!1),d=(0,n.useRef)(null),r=(0,n.useRef)(!1),v=()=>{d.current&&(clearTimeout(d.current),d.current=null)};async function f(){if(!r.current)try{let s=await fetch("/api/game/status");if(r.current)return;if(!s.ok){a({state:"absent",received:0,total:u});return}let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch{r.current||(d.current=setTimeout(()=>{f()},1500))}}(0,n.useEffect)(()=>(r.current=!1,f(),()=>{r.current=!0,v()}),[]);async function b(){v(),h(!0),a({state:"downloading",received:0,total:u});try{let s=await fetch("/api/game/download",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({proxy:c.trim()})});if(r.current)return;if(!s.ok)throw new Error(`HTTP ${s.status}`);let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch(s){if(r.current)return;a({state:"error",received:0,total:u,error:s instanceof Error?s.message:String(s)})}finally{r.current||h(!1)}}return i?.state==="ready"?(0,e.jsx)("div",{className:"office-frame-shell",children:(0,e.jsx)("iframe",{className:"office-game-frame",src:"/game/index.html",title:"HD2D Office",allow:"autoplay"})}):(0,e.jsx)(P,{status:i??{state:"absent",received:0,total:u},title:t("nav.office"),proxy:c,starting:m,onProxyChange:l,onStart:()=>{b()}})}function P(t){let i=t.status.total||u,a=(0,n.useMemo)(()=>i?Math.min(100,Math.round(t.status.received/i*100)):0,[t.status.received,i]),c=t.status.state==="downloading",l=t.status.state==="error";return(0,e.jsxs)("div",{style:{margin:"auto",textAlign:"center",maxWidth:440,padding:32,color:"var(--fg,#e6e6e6)"},children:[(0,e.jsx)("h1",{style:{fontSize:18,fontWeight:600,lineHeight:1.2,margin:"0 0 8px"},children:t.title}),(0,e.jsxs)("div",{style:{fontSize:13,opacity:.7,lineHeight:1.7,marginBottom:20},children:["\u628A\u6BCF\u4E2A\u4F1A\u8BDD\u53D8\u6210\u529E\u516C\u5BA4\u91CC\u7684\u4E00\u4E2A\u673A\u5668\u4EBA\uFF0C\u5B9E\u65F6\u6620\u5C04\u5C4F\u5E55\u72B6\u6001\u3002",(0,e.jsx)("br",{}),"\u9996\u6B21\u8FDB\u5165\u9700\u4E0B\u8F7D\u7EA6 ",y(i)," MB \u6E38\u620F\u8D44\u6E90\uFF08\u4EC5\u4E00\u6B21\uFF0C\u4E4B\u540E\u672C\u5730\u7F13\u5B58\uFF09\u3002"]}),l?(0,e.jsxs)("div",{style:{color:"#e06c75",fontSize:12,marginBottom:14},children:["\u4E0A\u6B21\u4E0B\u8F7D\u5931\u8D25\uFF1A",t.status.error??"\u672A\u77E5\u9519\u8BEF",(0,e.jsx)("br",{}),(0,e.jsx)("span",{style:{opacity:.7},children:"\u586B\u4EE3\u7406\u540E\u70B9\u91CD\u8BD5"})]}):null,c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{background:"var(--surface-muted)",borderRadius:"var(--radius-lg)",height:10,overflow:"hidden",marginBottom:10},children:(0,e.jsx)("div",{style:{height:"100%",width:`${a}%`,background:"var(--accent)",transition:"width .3s"}})}),(0,e.jsxs)("div",{style:{fontSize:12,opacity:.7},children:["\u4E0B\u8F7D\u4E2D... ",y(t.status.received)," / ",y(i)," MB\uFF08",a,"%\uFF09"]})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("input",{id:"hd2d-proxy",className:"office-proxy-input",type:"text",value:t.proxy,onChange:m=>t.onProxyChange(m.currentTarget.value),placeholder:"HTTP \u4EE3\u7406\uFF08\u53EF\u9009\uFF0C\u5982 http://127.0.0.1:7890\uFF09"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.5,marginBottom:14,textAlign:"left"},children:"\u8FDE\u4E0D\u4E0A GitHub \u65F6\u586B\u4EE3\u7406\uFF08\u4EC5\u7528\u4E8E\u4E0B\u8F7D\u672C\u8D44\u6E90\uFF0C\u4F1A\u8BB0\u4F4F\uFF09\u3002\u7559\u7A7A\u8D70\u76F4\u8FDE/\u7CFB\u7EDF\u4EE3\u7406\u73AF\u5883\u53D8\u91CF\u3002"}),(0,e.jsxs)("button",{id:"hd2d-load",type:"button",className:"page-primary-action office-load-button",disabled:t.starting,onClick:t.onStart,children:[l?"\u91CD\u8BD5":"\u52A0\u8F7D\u529E\u516C\u5BA4","\uFF08\u7EA6 ",y(i)," MB\uFF09"]})]})]})}function B(t){let i={maxWidth:t.style.maxWidth,padding:t.style.padding,flex:t.style.flex,minHeight:t.style.minHeight,minWidth:t.style.minWidth,display:t.style.display,overflow:t.style.overflow};t.style.maxWidth="none",t.style.padding="0",t.style.flex="1 1 auto",t.style.minHeight="0",t.style.minWidth="0",t.style.display="flex",t.style.overflow="hidden";let a=p(t,(0,e.jsx)(T,{}));return()=>{a(),t.style.maxWidth=i.maxWidth,t.style.padding=i.padding,t.style.flex=i.flex,t.style.minHeight=i.minHeight,t.style.minWidth=i.minWidth,t.style.display=i.display,t.style.overflow=i.overflow}}export{B as renderOfficePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Q,b as j}from"./chunk-
|
|
1
|
+
import{a as Q,b as j}from"./chunk-GTAJV5YC.js";import{a as J,c as A}from"./chunk-VA6QWSGQ.js";import{b as H,d as M,e as T,f as O,k as W,m as x,n as I,o as P,p as X,r as G}from"./chunk-5CJMHTT4.js";import{C as $,E as C,F as q,G as y,H as f,I as h,w as L,y as k}from"./chunk-DLZK52JU.js";import{a as V}from"./chunk-SYC6D5XU.js";import{a as ae,d as K}from"./chunk-5THX4DI2.js";import{c as E}from"./chunk-7SZRL6FY.js";var r=E(ae(),1);var t=E(K(),1),re=new Set(["working","analyzing","active","starting"]),le=new Set(["idle","dormant"]),ee="botmux.overview.teamExpanded",te="botmux.overview.activeSort",_=5,z=1,ce=260;function ve(){try{return window.localStorage.getItem(ee)==="1"}catch{return!1}}function me(e){try{window.localStorage.setItem(ee,e?"1":"0")}catch{}}function de(e){return e==="attention"?"attention":"time"}function ue(){try{return de(window.localStorage.getItem(te))}catch{return"time"}}function we(e){try{window.localStorage.setItem(te,e)}catch{}}function pe(e,s){let o=(i,a)=>Number(a.lastMessageAt??0)-Number(i.lastMessageAt??0);return s==="attention"?[...e].sort((i,a)=>{let d=f(i)?0:1,l=f(a)?0:1;if(d!==l)return d-l;if(d===0){let p=h(i)-h(a);if(p!==0)return p}return o(i,a)}):[...e].sort(o)}function fe(e){return String(e??"unknown").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function ge(e,s){let o=String(e??"unknown"),i=`sessions.status.${o}`,a=s(i);return a===i?o:a}function Se(e){if(!e)return z*_;let s=window.getComputedStyle(e).gridTemplateColumns.split(/\s+/).filter(i=>Number.parseFloat(i)>0);return Math.max(1,s.length||_)*z}function be(e,s){if(!e)return;let o=document.querySelector(".sidebar");if(!o||window.matchMedia("(max-width: 980px)").matches){e.style.removeProperty(s);return}let i=o.getBoundingClientRect().bottom,a=e.getBoundingClientRect().top,l=`${Math.max(ce,Math.round(i-a))}px`;e.style.getPropertyValue(s)!==l&&e.style.setProperty(s,l)}function he({card:e}){let s=A(),o=!e.online&&e.active.length===0,i=e.attention.length>0,a=e.busy.length>0,d=i?"warn":a?"busy":o?"off":"ok",l;if(i){let v=[...e.attention].sort((g,S)=>h(g)-h(S))[0];l=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:(y(v.title)||v.sessionId).slice(0,60)})," \xB7 ",f(v)??""]})}else if(a){let v=[...e.busy].sort((g,S)=>Number(S.lastMessageAt??0)-Number(g.lastMessageAt??0))[0];l=(0,t.jsx)("b",{children:(y(v.title)||v.sessionId).slice(0,60)})}else o?l=s("overview.botOffline"):l=s("overview.botIdle");let p=i?(0,t.jsx)("span",{className:"tag tag-warn",children:s("overview.botNeedsYou")}):a?(0,t.jsx)("span",{className:"tag tag-run",children:s("overview.botBusy",{count:e.busy.length})}):o?(0,t.jsx)("span",{className:"tag tag-off",children:s("overview.botOff")}):(0,t.jsx)("span",{className:"tag tag-ok",children:s("overview.botReady")});return(0,t.jsxs)("article",{className:`mate${i?" mate-attn":""}${o?" mate-off":""}`,children:[(0,t.jsxs)("div",{className:"mate-top",children:[(0,t.jsx)(H,{html:k({name:e.botName,larkAppId:e.larkAppId,avatarUrl:e.botAvatarUrl,dot:d})}),(0,t.jsxs)("div",{className:"mate-id",children:[(0,t.jsx)("b",{children:e.botName}),(0,t.jsx)("span",{className:"mate-role",children:e.cliId})]})]}),(0,t.jsx)("div",{className:"mate-task",children:l}),(0,t.jsxs)("div",{className:"mate-foot",children:[p,(0,t.jsx)("span",{children:e.lastActiveAt?s("overview.lastActive",{time:L(e.lastActiveAt)}):s("common.never")})]})]})}function Ae({session:e}){let s=A(),o=C(e),i=String(e.status??"unknown"),a=f(e);return(0,t.jsxs)(I,{kind:"session",children:[(0,t.jsx)(H,{html:k({name:o,larkAppId:e.larkAppId,size:"sm"})}),(0,t.jsxs)(P,{children:[(0,t.jsx)("b",{children:(y(e.title)||e.sessionId).slice(0,64)}),(0,t.jsxs)("span",{children:[o," \xB7 ",q(e)??e.cliId??"unknown"," \xB7 ",L(e.lastMessageAt)]})]}),(0,t.jsx)(X,{children:a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("a",{className:"overview-list-action",href:"#/sessions",children:s("strip.handle")}),(0,t.jsx)("span",{className:"status overview-list-status status-attention",children:a})]}):(0,t.jsx)("span",{className:`status overview-list-status status-${fe(i)}`,children:ge(i,s)})})]})}function Ne({schedule:e,timeZone:s}){let o=e.nextRunAt?new Date(e.nextRunAt).toLocaleString(void 0,s?{timeZone:s,timeZoneName:"short"}:void 0):"-";return(0,t.jsxs)(I,{kind:"schedule",children:[(0,t.jsxs)(P,{children:[(0,t.jsx)("strong",{children:e.name??e.id}),(0,t.jsxs)("span",{children:[C(e)," \xB7 ",e.parsed?.display??""]})]}),(0,t.jsx)("span",{className:"overview-list-meta",children:(0,t.jsx)(W,{text:o,showPopover:!1,durationMs:2600})})]})}function ye({mode:e,onModeChange:s}){let o=A(),i=o(e==="attention"?"overview.sortAttentionFirst":"overview.sortByTime");return(0,t.jsx)(G,{className:"overview-active-sort-menu",label:i,value:e,options:[{value:"time",label:o("overview.sortByTime")},{value:"attention",label:o("overview.sortAttentionFirst")}],onChange:s})}function Me(){let e=A(),s=(0,r.useRef)(null),o=(0,r.useRef)(null),i=(0,r.useRef)(null),[a,d]=(0,r.useState)(ve),[l,p]=(0,r.useState)(ue),[v,g]=(0,r.useState)(z*_),[S,D]=(0,r.useState)(0),{sessions:N,schedules:B,scheduleTimeZone:ne}=J(n=>({sessions:[...n.sessions.values()],schedules:[...n.schedules.values()],scheduleTimeZone:n.scheduleTimeZone}));(0,r.useEffect)(()=>{let n=0,m=()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let w=Se(s.current);g(c=>c===w?c:w)})};m();let u=typeof ResizeObserver>"u"||!s.current?null:new ResizeObserver(m);return u&&s.current&&u.observe(s.current),window.addEventListener("resize",m),()=>{window.cancelAnimationFrame(n),u?.disconnect(),window.removeEventListener("resize",m)}},[]),(0,r.useEffect)(()=>{Q().then(()=>D(n=>n+1)),$().then(()=>D(n=>n+1))},[]);let F=(0,r.useMemo)(()=>N.filter(n=>n.status!=="closed"),[N]),b=(0,r.useMemo)(()=>j(N),[N,S]),U=a?b:b.slice(0,v),Y=(0,r.useMemo)(()=>pe(F.filter(n=>f(n)||re.has(n.status)||le.has(n.status)),l).slice(0,7),[F,l]),R=(0,r.useMemo)(()=>B.filter(n=>n.nextRunAt).sort((n,m)=>Date.parse(n.nextRunAt)-Date.parse(m.nextRunAt)).slice(0,5),[B]);(0,r.useEffect)(()=>{let n=[{el:o.current,propertyName:"--active-sessions-min-height"},{el:i.current,propertyName:"--schedules-panel-min-height"}].filter(c=>!!c.el);if(!n.length)return;let m=0,u=()=>{window.cancelAnimationFrame(m),m=window.requestAnimationFrame(()=>{for(let c of n)be(c.el,c.propertyName)})};u();let w=typeof ResizeObserver>"u"?null:new ResizeObserver(u);if(w){for(let ie of n)w.observe(ie.el);let c=document.querySelector(".sidebar"),Z=n[0].el.closest(".page");c&&w.observe(c),Z&&w.observe(Z)}return window.addEventListener("resize",u),()=>{window.cancelAnimationFrame(m),w?.disconnect(),window.removeEventListener("resize",u);for(let c of n)c.el.style.removeProperty(c.propertyName)}},[a,v,b.length,R.length]);let se=()=>{d(n=>(me(!n),!n))},oe=n=>{p(n),we(n)};return(0,t.jsxs)("section",{className:"page hero-page",children:[(0,t.jsx)("div",{className:"page-heading",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"eyebrow",children:e("app.subtitle")}),(0,t.jsx)("h1",{children:e("overview.title")})]})}),(0,t.jsxs)("div",{className:"overview-layout",children:[(0,t.jsxs)("div",{className:"overview-main",children:[(0,t.jsxs)("section",{className:"overview-block team-section",children:[(0,t.jsx)(M,{title:e("overview.team"),count:e("overview.teamCount",{count:b.length}),hint:e("overview.teamHint"),children:(0,t.jsx)(O,{children:(0,t.jsx)(T,{href:"#/bot-defaults",children:e("overview.viewAllPlain")})})}),(0,t.jsx)("div",{className:"team-grid",id:"team-grid",ref:s,children:U.length?U.map(n=>(0,t.jsx)(he,{card:n},n.larkAppId??n.botName)):(0,t.jsx)("div",{className:"empty",children:e("overview.noSessions")})}),b.length>v?(0,t.jsx)("button",{type:"button",className:"team-toggle",id:"team-toggle",onClick:se,children:e(a?"overview.teamCollapse":"overview.teamExpand")}):null]}),(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(M,{title:e("overview.activeSessions"),children:(0,t.jsxs)(O,{children:[(0,t.jsx)(ye,{mode:l,onModeChange:oe}),(0,t.jsx)(T,{href:"#/sessions",children:e("overview.viewAllPlain")})]})}),(0,t.jsx)("section",{className:"panel active-sessions-panel",ref:o,children:(0,t.jsx)(x,{id:"recent-sessions",children:Y.length?Y.map(n=>(0,t.jsx)(Ae,{session:n},n.sessionId)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSessions")})})})]})]}),(0,t.jsx)("aside",{className:"overview-side",children:(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(M,{title:e("overview.nextSchedules"),children:(0,t.jsx)(T,{href:"#/schedules",children:e("overview.viewAllPlain")})}),(0,t.jsx)("section",{className:"panel schedules-panel",ref:i,children:(0,t.jsx)(x,{id:"next-schedules",children:R.length?R.map(n=>(0,t.jsx)(Ne,{schedule:n,timeZone:ne},n.id)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSchedules")})})})]})})]})]})}function Ce(e){e.classList.add("overview-root");let s=V(e,(0,t.jsx)(Me,{}));return()=>{s(),e.classList.remove("overview-root")}}export{Ce as renderOverviewPage};
|
|
@@ -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 R(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 R(await e.json())}async function z(e,a,i){let t=i==="global"?"global":`bots/${encodeURIComponent(i)}`,c=await fetch(`/api/plugins/${encodeURIComponent(e)}/${t}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})}),l=await c.json().catch(()=>({}));if(!c.ok)throw new Error(typeof l?.error=="string"?l.error:`HTTP ${c.status}`);return R(l)}async function Q(e,a){let i=await fetch(`/api/plugins/${encodeURIComponent(e)}/pin`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({pinned:a})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return R(await i.json())}async function M(e,a){let i=await fetch(`/api/plugins/${encodeURIComponent(e)}/services/${a}`,{method:"POST"});if(!i.ok)throw new Error(`HTTP ${i.status}`);return R(await i.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,i)=>(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}:${i}`))})}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 i=a.serviceReport,t=[{label:"\u72B6\u6001",content:(0,n.jsx)("span",{className:`plugin-status ${X(i)}`,children:B(i)})},{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:i?.port?(0,n.jsx)(y,{children:i.port}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u4E0A\u62A5"})},{label:"PID",content:i?.pid?(0,n.jsx)(y,{children:i.pid}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u4E0A\u62A5"})},{label:"\u8BBF\u95EE\u5730\u5740",content:(0,n.jsx)(I,{url:i?.openUrl})},{label:"\u5065\u5EB7\u68C0\u67E5",content:(0,n.jsx)(I,{url:i?.healthUrl,health:!0})}];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(N,{rows:t}),i?.warning?(0,n.jsx)("div",{className:"plugin-warning",children:i.warning}):null]})}function nn(e){let{plugin:a}=e;if(!a.service)return null;let i=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(i)}`,children:B(i)})]}),(0,n.jsxs)("div",{className:"plugin-action-meta",children:[i?.port?(0,n.jsxs)("span",{children:["\u7AEF\u53E3 ",i.port]}):null,i?.pid?(0,n.jsxs)("span",{children:["PID ",i.pid]}):null,(0,n.jsx)(I,{url:i?.openUrl})]}),(0,n.jsx)("div",{className:"plugin-service-actions",children:["start","stop","restart"].map(t=>(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-service":a.id,"data-action":t,disabled:e.busy,onClick:()=>e.onAction(t),children:t==="start"?"\u542F\u52A8":t==="stop"?"\u505C\u6B62":"\u91CD\u542F"},t))})]})}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(i=>(0,n.jsxs)("a",{className:"btn-link primary",href:i.route,children:["\u6253\u5F00 ",i.id]},i.id))})]})}function an(e){let a=!!e.plugin.service,i=(e.plugin.dashboard?.length??0)>0;return!a&&!i?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 E(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 i=(e.plugin.contributions?.skills??[]).map(t=>({label:t.name||t.path||"skill",content:t.path?(0,n.jsx)(y,{children:t.path}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u58F0\u660E\u8DEF\u5F84"})}));return(0,n.jsxs)(E,{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"}),i.length>0?(0,n.jsx)(N,{rows:i}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B Skills\u3002"})]})}function ln(e){let a=e.plugin,i=a.contributions?.mcp,t=i?[{label:i.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:[i.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"]})]})]})}]:[],c=(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)(E,{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"}),c.length>0?(0,n.jsx)(N,{rows:c}):null,l.length>0?(0,n.jsx)(N,{rows:l}):null,t.length>0?(0,n.jsx)(N,{rows:t}):(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,i=[...a?.entry?[{label:"\u5165\u53E3\u6587\u4EF6",content:(0,n.jsx)(y,{children:a.entry})}]:[],...(a?.commands??[]).map(t=>({label:t.name,content:t.description?(0,n.jsx)("span",{children:t.description}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u65E0\u63CF\u8FF0"})}))];return(0,n.jsxs)(E,{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"}),i.length>0?(0,n.jsx)(N,{rows:i}):(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(i=>({label:i.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:i.route})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u5165\u53E3"}),(0,n.jsx)(y,{children:i.entry})]})]})}));return(0,n.jsxs)(E,{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)(E,{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 gn(e){let a=e.plugin.contributions?.cli?.commands??[],i=(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]),[t,c]=(0,r.useState)(()=>i.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:i.map(l=>(0,n.jsxs)("button",{type:"button",className:`plugin-tab-button${t===l.id?" is-active":""}`,role:"tab","aria-selected":t===l.id,"data-plugin-tab":l.id,onClick:()=>c(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:t==="skills"}),(0,n.jsx)(ln,{plugin:e.plugin,active:t==="mcp"}),(0,n.jsx)(sn,{plugin:e.plugin,active:t==="cli"}),(0,n.jsx)(on,{plugin:e.plugin,active:t==="dashboard"}),(0,n.jsx)(rn,{plugin:e.plugin,active:t==="service"})]})]})}function x(e,a){return`${e}:${a}`}function w(e,a,i){let t=i.get(x(e.id,a));return t!==void 0?t:a==="global"?e.enabledGlobal===!0:e.enabledByBot?.[a]===!0}function cn(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:i=>e.onToggle("global",i.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"})]})}function dn(e){let{plugin:a,bots:i,pendingToggles:t}=e,c=i.filter(l=>w(a,l.id,t)).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:[c,"/",i.length," \u4E2A Bot \u5DF2\u542F\u7528"]})]}),(0,n.jsxs)("div",{className:"plugin-enable-list",children:[i.map(l=>{let s=w(a,l.id,t),p=s?"\u5DF2\u542F\u7528":"\u672A\u542F\u7528";return(0,n.jsx)(cn,{plugin:a,scope:l.id,label:l.name,hint:`\u5F53\u524D${p}`,checked:s,busy:e.busy,onToggle:e.onToggle},l.id)}),i.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??[],i=[{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(t=>t.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:[i.map(t=>(0,n.jsxs)("span",{className:"plugin-capability-chip",children:[(0,n.jsx)("strong",{children:t.count}),t.label]},t.label)),e.plugin.service?(0,n.jsxs)("span",{className:`plugin-capability-chip ${X(e.plugin.serviceReport)}`,children:["Service ",B(e.plugin.serviceReport)]}):null,i.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 i=a.current;if(i)if(e.feedback&&!i.open)try{i.showModal()}catch{i.setAttribute("open","")}else!e.feedback&&i.open&&i.close()},[e.feedback]),(0,n.jsx)("dialog",{className:"plugin-feedback-dialog","data-plugin-feedback-dialog":!0,ref:a,onClose:e.onClose,onClick:i=>{i.target===i.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,[i,t]=(0,r.useState)(!1),c=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${i?" 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:c}),(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":i,"aria-controls":P,onClick:()=>t(d=>!d),children:i?"\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}),i?(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)(gn,{plugin:a})})]}):null]})}function A(e,a,i){let t=new Map(e);return i===void 0?t.delete(a):t.set(a,i),t}function vn(e,a,i){let t=new Set(e);return i?t.add(a):t.delete(a),t}function hn(){let[e,a]=(0,r.useState)(null),[i,t]=(0,r.useState)(null),[c,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),t(null);try{a(await _())}catch(o){t(o instanceof Error?o.message:String(o))}finally{l(!1)}},[]);(0,r.useEffect)(()=>{D()},[D]);let v=(0,r.useCallback)((o,u)=>{p(g=>vn(g,o,u))},[]),F=(0,r.useCallback)(async(o,u,g)=>{let L=x(o,u);b(h=>A(h,L,g)),v(o,!0);try{let h=await z(o,g,u);a(h)}catch(h){d({title:g?"\u65E0\u6CD5\u542F\u7528\u63D2\u4EF6":"\u65E0\u6CD5\u7981\u7528\u63D2\u4EF6",message:h instanceof Error?h.message:String(h)})}finally{b(h=>A(h,L,void 0)),v(o,!1)}},[v]),K=(0,r.useCallback)(async(o,u)=>{m(g=>A(g,o,u)),v(o,!0);try{let g=await Q(o,u);a(g),window.dispatchEvent(new Event(G))}catch(g){d({title:"\u65E0\u6CD5\u66F4\u65B0\u4FA7\u680F\u56FA\u5B9A",message:g instanceof Error?g.message:String(g)})}finally{m(g=>A(g,o,void 0)),v(o,!1)}},[v]),V=(0,r.useCallback)(async(o,u)=>{v(o,!0);try{let g=await M(o,u);a(g)}catch(g){d({title:"Service \u64CD\u4F5C\u5931\u8D25",message:g instanceof Error?g.message:String(g)})}finally{v(o,!1)}},[v]);if(!e&&!i)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",i]})});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:c,onClick:()=>{D()},children:c?"\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,g)=>{F(o.id,u,g)},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(i=>i.id===e)?.serviceReport},async startService(){return M(e,"start")},async stopService(){return M(e,"stop")},async restartService(){return M(e,"restart")}}}function yn(e){let[a,i]=(0,r.useState)(null),[t,c]=(0,r.useState)(null),[l,s]=(0,r.useState)(null);(0,r.useEffect)(()=>{let b=!1;return i(null),c(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;i(m),c(()=>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||!t||!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)(t,{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 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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as xt,b as Ct,c as Et,d as At}from"./chunk-R3FXBFQH.js";import{c as Mt}from"./chunk-VA6QWSGQ.js";import{b as Tt,c as ae,h as Ge,q as _e}from"./chunk-5CJMHTT4.js";import{C as Nt,y as kt}from"./chunk-DLZK52JU.js";import{a as De}from"./chunk-SYC6D5XU.js";import{a as nn,d as Lt}from"./chunk-5THX4DI2.js";import{c as Be}from"./chunk-7SZRL6FY.js";var d=Be(nn(),1);function Bt(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 sn(t){return[...new Set([...t].filter(Boolean))]}function Fe(t){let n=new Set(t.targetIds.filter(Boolean)),r=new Set(t.include);for(let o of n)r.delete(o),t.listening&&r.add(o);return{include:sn(r),exclude:[]}}function $e(t){let n=t.targetIds.filter(Boolean);if(n.length===0)return"ignore";let r=new Set(t.include),o=new Set;for(let u of n)o.add(r.has(u)?"listen":"ignore");return o.size===1?[...o][0]:"mixed"}var $=32768,Dt=Math.floor($*.95),ce=32768,Gt=Math.floor(ce*.95),Oe=5,Ue=20,on=/^[A-Za-z0-9._-]{1,64}$/;function je(t){return on.test(t)&&t!=="."&&t!==".."}function _t(t=location.hash){let[,n=""]=t.split("?");return new URLSearchParams(n).get("chatId")?.trim()||null}function Ve(t,n){return Et(t,n)}function he(t){return new TextEncoder().encode(t).length}function Ft(t){return t.memberBots.filter(n=>n.inChat&&n.hasRole).length}function $t(t){return t.memberBots.filter(n=>n.inChat).length}function ue(t,n){return n?t.find(r=>r.larkAppId===n):void 0}function Ot(t,n){let r=n.toLowerCase();return r?t.filter(o=>{let u=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 u||m}):t}function Ut(t,n){let r=n.toLowerCase();return t.filter(o=>!r||o.profileId.toLowerCase().includes(r))}async function S(t){return t.json().catch(()=>({}))}async function jt(){let t=await fetch("/api/groups"),n=await S(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 Vt(){let t=await fetch("/api/role-profiles");return(await S(t)).profiles??[]}async function W(t){let n=await fetch(`/api/role-profiles/${encodeURIComponent(t)}`);return(await S(n)).entries??[]}async function He(t,n){let r=await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return S(r)}async function Ht(t,n,r,o){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:r,injectMode:o})})).ok}async function qt(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 Wt(t,n){return(await fetch(`/api/roles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}async function qe(t,n){let r=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return(await S(r)).listener??{enabled:!1,prompt:"",messagePolicy:{scope:"top_level"}}}async function zt(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 Yt(t,n){return(await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}function be(t){return Number.isFinite(t)?Math.min(Ue,Math.max(1,Math.floor(t))):Oe}function de(t){return String(t).padStart(2,"0")}function Jt(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(),"-",de(o.getMonth()+1),"-",de(o.getDate())," ",de(o.getHours()),":",de(o.getMinutes()),":",de(o.getSeconds())].join(""):""}async function Xt(t,n,r,o){let u=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({listener:r,limit:be(o)})}),m=await S(u);return{ok:u.ok&&m.ok!==!1,requestedLimit:m.requestedLimit??be(o),matches:m.matches??[],error:m.error}}async function Kt(t,n,r,o){let u=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/run-preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({listener:r,limit:be(o)})}),m=await S(u);return{ok:u.ok&&m.ok!==!1,requestedLimit:m.requestedLimit??be(o),matches:m.matches??[],results:m.results,error:m.error}}async function Qt(t,n,r){let o=await fetch(`/api/message-listeners/${encodeURIComponent(t)}/${encodeURIComponent(n)}/run-preview/${encodeURIComponent(r)}`),u=await S(o);return{ok:o.ok&&u.ok!==!1,runId:u.runId,results:u.results,error:u.error}}async function Zt(t,n){let r=await fetch(`/api/groups/${encodeURIComponent(t)}/${encodeURIComponent(n)}/members-display`);return(await S(r)).members??[]}async function er(t,n){let r=await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`);return S(r)}async function tr(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 rr(t,n){return(await fetch(`/api/role-profiles/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:"DELETE"})).ok}async function nr(t,n){let r=await Promise.all(n.map(async f=>{try{let p=await fetch(`/api/role-profiles/${encodeURIComponent(f.profileId)}`),g=await S(p);return[f.profileId,Array.isArray(g.entries)?g.entries:[]]}catch{return[f.profileId,[]]}})),o=new Set,u=[];for(let f of t)for(let p of f.memberBots){if(!p.inChat||!p.hasRole)continue;let g=Ve(p.larkAppId,f.chatId);o.has(g)||(o.add(g),u.push({larkAppId:p.larkAppId,chatId:f.chatId}))}let m=await At(u);return{entriesByProfile:new Map(r),effectiveRolesByBot:m}}async function sr(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 S(n);return{larkAppId:t.larkAppId,ok:n.ok&&r.ok!==!1,status:n.status,error:r.error,wouldRefuse:r.wouldRefuse}}var e=Be(Lt(),1),ar=["text","post","image","interactive"],O={enabled:!1,prompt:"",senderPolicy:{mode:"include_only",includeSenderTypes:["user"],excludeSelf:!0},messagePolicy:{includeMsgTypes:[...ar],scope:"top_level"}};function ze(t){return{enabled:t?.enabled===!0,name:t?.name??"",replyCardTitle:t?.replyCardTitle??"",workingDir:t?.workingDir??"",prompt:t?.prompt??"",senderPolicy:{mode:"include_only",includeSenderOpenIds:[...t?.senderPolicy?.includeSenderOpenIds??[]],excludeSenderOpenIds:[],includeSenderTypes:[...t?.senderPolicy?.includeSenderTypes??O.senderPolicy?.includeSenderTypes??[]],excludeSenderTypes:[...t?.senderPolicy?.excludeSenderTypes??[]],excludeSelf:t?.senderPolicy?.excludeSelf!==!1},messagePolicy:{includeMsgTypes:[...t?.messagePolicy?.includeMsgTypes??O.messagePolicy?.includeMsgTypes??[]],scope:"top_level"}}}function or(t){return t?.enabled===!0&&t.prompt.trim().length>0}function ln(t){return t.memberBots.some(n=>n.inChat&&(n.hasRole||n.hasMessageListener))}function We(t,n){return t?.name||n}function an(t,n){let r=new Set(n.senderPolicy?.includeSenderTypes??O.senderPolicy?.includeSenderTypes??[]);return r.size===0?!0:(t.memberType==="user"||t.memberType==="bot")&&r.has(t.memberType)}function dn(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 cn(t,n){return!n||t==="failed"?"error":t==="replied"?"ok":t==="running"?"running":"triggered"}function un(t,n=[]){let r=ze(t??O);if(t?.senderPolicy?.mode!=="all_except_excluded")return r;let o=new Set(t.senderPolicy.excludeSenderOpenIds??[]);return r.senderPolicy={...r.senderPolicy??{},mode:"include_only",includeSenderOpenIds:n.filter(u=>an(u,r)&&!o.has(u.openId)).map(u=>u.openId),excludeSenderOpenIds:[]},r}function pn(){let t=(0,d.useRef)(!0);return(0,d.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function fn(){let t=(0,d.useRef)(new Set);return(0,d.useEffect)(()=>()=>{for(let n of t.current)window.clearTimeout(n);t.current.clear()},[]),(0,d.useCallback)((n,r)=>{let o=window.setTimeout(()=>{t.current.delete(o),n()},r);return t.current.add(o),o},[])}function dr(t){return(0,e.jsx)(Tt,{html:kt({name:t.bot.botName,larkAppId:t.bot.larkAppId,avatarUrl:t.bot.botAvatarUrl,size:"sm"})})}function cr(t){let n=Mt(),r=pn(),o=fn(),[u,m]=(0,d.useState)([]),[f,p]=(0,d.useState)([]),[g,k]=(0,d.useState)([]),[Ie,U]=(0,d.useState)({entriesByProfile:new Map,effectiveRolesByBot:new Map}),[we,j]=(0,d.useState)(!1),[Se,C]=(0,d.useState)(!0),[z,I]=(0,d.useState)(!0),[Y,pe]=(0,d.useState)(""),[E,D]=(0,d.useState)(""),[G,fe]=(0,d.useState)(()=>new Set),[y,J]=(0,d.useState)(null),[l,v]=(0,d.useState)(null),[w,N]=(0,d.useState)(null),[_,me]=(0,d.useState)(""),[X,K]=(0,d.useState)("every"),[Ye,Je]=(0,d.useState)(!1),[Xe,Ke]=(0,d.useState)(!1),[ur,Qe]=(0,d.useState)(!1),[pr,Re]=(0,d.useState)(null),[fr,Ze]=(0,d.useState)(null),[V,et]=(0,d.useState)("role"),[mr,gr]=(0,d.useState)(null),[h,A]=(0,d.useState)(()=>ze(O)),[ke,tt]=(0,d.useState)([]),[yr,rt]=(0,d.useState)(!1),[vr,nt]=(0,d.useState)(!1),[st,ot]=(0,d.useState)(!1),[Ne,lt]=(0,d.useState)(!1),[br,B]=(0,d.useState)(null),[Le,hr]=(0,d.useState)(Oe),[Pr,ge]=(0,d.useState)({kind:"idle"}),Q=(0,d.useRef)(null),it=(0,d.useRef)(0),[P,Ir]=(0,d.useState)(null),[M,at]=(0,d.useState)(null),[Z,ee]=(0,d.useState)([]),[te,ye]=(0,d.useState)(""),[F,re]=(0,d.useState)(null),[dt,wr]=(0,d.useState)(!1),[ct,ut]=(0,d.useState)(()=>new Set),[pt,ft]=(0,d.useState)(!1),[mt,gt]=(0,d.useState)(!1),[Sr,Te]=(0,d.useState)(null),[Rr,ne]=(0,d.useState)({kind:"idle"}),H=(0,d.useRef)(0),se=(0,d.useRef)(0),yt=(0,d.useRef)(null),Me=y?u.find(s=>s.chatId===y):void 0,kr=Me&&l?Me.memberBots.find(s=>s.larkAppId===l):void 0,xe=M?f.find(s=>s.larkAppId===M):void 0,Nr=ue(Z,M),Ce=F?u.find(s=>s.chatId===F):void 0,ve=Ce?.memberBots.filter(s=>s.inChat)??[],Lr=ve.map(s=>s.larkAppId).join("\0"),Tr=Z.map(s=>s.larkAppId).sort().join("\0"),Mr=(0,d.useMemo)(()=>Ot(u,Y),[u,Y]),xr=(0,d.useMemo)(()=>Ut(g,E),[g,E]),Ee=he(_),Ae=he(te),vt=he(h.prompt),Cr=(0,d.useMemo)(()=>{let s=new Map;for(let i of ke)s.set(i.openId,i);return s},[ke]),L=(0,d.useCallback)((s,i,a=!1)=>{let c=Date.now()+Math.random();s({text:i,isError:a,id:c}),o(()=>{s(b=>b?.id===c?null:b)},a?3e3:2e3)},[o]),R=(0,d.useCallback)(async(s,i)=>{try{let a=await nr(s,i);if(!r.current)return;U(a),j(!0)}catch{if(!r.current)return;U({entriesByProfile:new Map,effectiveRolesByBot:new Map}),j(!0)}},[r]),x=(0,d.useCallback)(async()=>{let s=await jt();return r.current&&(m(s.groups),p(s.bots)),s},[r]),oe=(0,d.useCallback)(async()=>{let s=await Vt();return r.current&&k(s),s},[r]),le=(0,d.useCallback)((s,i=[])=>{let a=un(s??O,i);gr(s),A(a)},[]),bt=(0,d.useCallback)(async(s,i,a)=>{rt(!0),nt(!0),tt([]);try{let[c,b]=await Promise.all([qe(s,i).catch(()=>ze(O)),Zt(s,i).catch(()=>[])]);if(!r.current||a!==H.current)return;le(or(c)?c:null,b),tt(b),B(null)}finally{r.current&&a===H.current&&(rt(!1),nt(!1))}},[r,le]),ht=(0,d.useCallback)(async()=>{C(!0),I(!0),j(!1);try{let s=await x();if(!r.current)return;let i=await oe();if(!r.current||(await Nt(),!r.current))return;if(fe(new Set(s.groups.filter(ln).map(a=>a.chatId))),t.tab==="profiles"){let a=_t();re(c=>c||(a&&s.groups.some(b=>b.chatId===a)?a:s.groups[0]?.chatId??null))}else re(a=>a??s.groups[0]?.chatId??null);C(!1),I(!1),R(s.groups,i)}catch{if(!r.current)return;C(!1),I(!1),j(!0)}},[r,t.tab,x,oe,R]);(0,d.useEffect)(()=>{ht()},[ht]),(0,d.useEffect)(()=>()=>{it.current+=1,Q.current=null},[]),(0,d.useEffect)(()=>{F||u.length===0||re(u[0].chatId)},[u,F]),(0,d.useEffect)(()=>{let s=new Set(ve.filter(i=>!!ue(Z,i.larkAppId)).map(i=>i.larkAppId));ut(s),ne({kind:"idle"})},[Tr,Lr]);async function Er(s,i){let a=++H.current;J(s),v(i),Re(null),Ze(null),B(null),le(null);let c=await He(i,s);!r.current||a!==H.current||(N(c),me(c.content??""),K(c.injectMode==="once"?"once":"every"),await bt(i,s,a))}async function Ar(){let s=await x();if(r.current&&(R(s.groups,g),y&&l)){let i=++H.current,a=await He(l,y);if(!r.current||i!==H.current)return;N(a),me(a.content??""),K(a.injectMode==="once"?"once":"every"),await bt(l,y,i)}}async function Br(){if(!(!y||!l)){Je(!0);try{let s=await Ht(l,y,_,X);if(!r.current)return;if(s){let i=await x();if(!r.current)return;N(a=>a&&{...a,content:_,hasRole:!0,injectMode:X}),R(i.groups,g),L(Re,n("roles.saved"))}else L(Re,_.trim().length===0?n("roles.emptyError"):n("roles.saveFailed"),!0)}finally{r.current&&Je(!1)}}}async function Dr(){if(!(!y||!l)&&confirm(n("roles.confirmDelete"))){Ke(!0);try{let s=await Wt(l,y);if(!r.current)return;if(s){let i=await x();if(!r.current)return;J(null),v(null),N(null),me(""),K("every"),R(i.groups,g)}}finally{r.current&&Ke(!1)}}}async function Gr(s){if(!y||!l)return;let i=X;K(s),Qe(!0);try{let a=await qt(l,y,s);if(!r.current)return;a||K(i),L(Ze,n(a?"roles.saved":"roles.saveFailed"),!a)}finally{r.current&&Qe(!1)}}function _r(s){A(i=>({...i,...s}))}function Fr(s){A(i=>({...i,senderPolicy:{...i.senderPolicy??{},...s}}))}function $r(s){A(i=>({...i,messagePolicy:{...i.messagePolicy??{scope:"top_level"},...s,scope:"top_level"}}))}function Or(s,i){A(a=>{let c=new Set(a.senderPolicy?.includeSenderTypes??[]);if(i)c.add(s);else{if(c.size<=1&&c.has(s))return a;c.delete(s)}return{...a,senderPolicy:{...a.senderPolicy??{},includeSenderTypes:[...c]}}})}function Ur(s,i){A(a=>{let c=new Set(a.messagePolicy?.includeMsgTypes??[]);if(i)c.add(s);else{if(c.size<=1&&c.has(s))return a;c.delete(s)}return{...a,messagePolicy:{...a.messagePolicy??{scope:"top_level"},includeMsgTypes:[...c],scope:"top_level"}}})}function jr(s,i){A(a=>{let c=Fe({include:a.senderPolicy?.includeSenderOpenIds??[],exclude:a.senderPolicy?.excludeSenderOpenIds??[],targetIds:[s],listening:i});return{...a,senderPolicy:{...a.senderPolicy??{},mode:"include_only",includeSenderOpenIds:c.include,excludeSenderOpenIds:c.exclude}}})}function Vr(s,i){A(a=>{let c=Fe({include:a.senderPolicy?.includeSenderOpenIds??[],exclude:a.senderPolicy?.excludeSenderOpenIds??[],targetIds:s,listening:i});return{...a,senderPolicy:{...a.senderPolicy??{},mode:"include_only",includeSenderOpenIds:c.include,excludeSenderOpenIds:c.exclude}}})}function Pt(){let s=h.senderPolicy??{},i=h.messagePolicy??{},a=[...new Set(s.includeSenderOpenIds??[])].filter(Boolean),c=[...new Set(s.includeSenderTypes??[])].filter(ie=>ie==="user"||ie==="bot"),b=[...new Set(i.includeMsgTypes??[])].filter(Boolean);return{enabled:h.enabled,...h.name?.trim()?{name:h.name.trim()}:{},...h.replyCardTitle?.trim()?{replyCardTitle:h.replyCardTitle.trim()}:{},...h.workingDir?.trim()?{workingDir:h.workingDir.trim()}:{},prompt:h.prompt.trim(),senderPolicy:{...a.length>0?{includeSenderOpenIds:a}:{},mode:"include_only",...c.length>0?{includeSenderTypes:c}:{},excludeSelf:s.excludeSelf!==!1},messagePolicy:{...b.length>0?{includeMsgTypes:b}:{},scope:"top_level"}}}function Hr(){return h.prompt.trim()?(h.senderPolicy?.includeSenderOpenIds?.length??0)===0?(L(B,n("roles.listenerSenderRequired"),!0),null):{...Pt(),enabled:!0}:(L(B,n("roles.listenerPromptRequired"),!0),null)}async function It(s){if(!y||!l)return;let i=Hr();if(!i)return;let a=s?"run":"preview";ge({kind:"loading",mode:a});try{let c=s?await Kt(l,y,i,Le):await Xt(l,y,i,Le);if(!r.current)return;ge(c.ok?{kind:"result",response:c,mode:a}:{kind:"error",text:c.error||n("roles.listenerPreviewFailed")}),c.ok&&s&&c.runId&&qr(c.runId)}catch(c){if(!r.current)return;ge({kind:"error",text:c instanceof Error?c.message:n("roles.listenerPreviewFailed")})}}function qr(s){if(!y||!l)return;let i=++it.current;Q.current={runId:s,token:i};let a=async()=>{if(!r.current)return;let c=Q.current;if(!(!c||c.runId!==s||c.token!==i||!y||!l))try{let b=await Qt(l,y,s);if(!r.current)return;if(b.ok&&b.results){let ie=b.results;ge(T=>T.kind!=="result"||T.mode!=="run"||T.response.runId!==s?T:{...T,response:{...T.response,results:dn(T.response.results,ie)}}),ie.some(T=>T.state==="triggered"||T.state==="running")?o(a,1500):Q.current?.runId===s&&(Q.current=null)}}catch{o(a,2500)}};o(a,1500)}async function Wr(){if(!(!y||!l)){if(!h.enabled){await wt(!1);return}if(!h.prompt.trim()){L(B,n("roles.listenerPromptRequired"),!0);return}if((h.senderPolicy?.includeSenderOpenIds?.length??0)===0){L(B,n("roles.listenerSenderRequired"),!0);return}ot(!0);try{let s=await zt(l,y,Pt());if(!r.current)return;if(s){let i=await x();if(!r.current)return;let a=await qe(l,y);if(!r.current)return;le(or(a)?a:null),R(i.groups,g)}L(B,n(s?"roles.saved":"roles.saveFailed"),!s)}finally{r.current&&ot(!1)}}}async function wt(s=!0){if(!(!y||!l)&&!(s&&!confirm(n("roles.listenerConfirmDelete")))){lt(!0);try{let i=await Yt(l,y);if(!r.current)return;if(i){let a=await x();if(!r.current)return;le(null),R(a.groups,g)}L(B,n(i?"roles.saved":"roles.saveFailed"),!i)}finally{r.current&<(!1)}}}async function St(s){let i=s.trim();if(!je(i))return;let a=++se.current;Ir(i),at(null),ye(""),ne({kind:"idle"}),re(b=>b??u[0]?.chatId??null);let c=await W(i);!r.current||a!==se.current||(ee(c),Te(null))}async function zr(s){if(!P)return;let i=++se.current;at(s);let a=await er(P,s);if(!r.current||i!==se.current)return;ye(a.content??"");let c=await W(P);!r.current||i!==se.current||(ee(c),Te(null))}async function Yr(){let s=await x();if(!r.current)return;let i=await oe();if(r.current){if(P){let a=await W(P);if(!r.current)return;ee(a)}R(s.groups,i)}}async function Jr(){let s=yt.current,i=s?.value.trim()??"";if(i){if(!je(i)){s?.setCustomValidity(n("roles.profileIdInvalid")),s?.reportValidity();return}s?.setCustomValidity(""),await St(i),r.current&&(location.hash.startsWith("#/roles/profile")||(location.hash="#/roles/profile"))}}async function Xr(){if(!(!P||!M)){ft(!0);try{let s=await tr(P,M,te);if(!r.current)return;let i=await oe();if(!r.current)return;let a=await W(P);if(!r.current)return;ee(a),R(u,i),L(Te,n(s?"roles.saved":"roles.saveFailed"),!s)}finally{r.current&&ft(!1)}}}async function Kr(){if(!(!P||!M)&&confirm(n("roles.confirmDeleteProfileEntry"))){gt(!0);try{if(await rr(P,M),!r.current)return;ye("");let s=await oe();if(!r.current)return;let i=await W(P);if(!r.current)return;ee(i),R(u,s)}finally{r.current&>(!1)}}}function Qr(s,i){ut(a=>{let c=new Set(a);return i?c.add(s):c.delete(s),c})}async function Rt(s){if(!P)return;let i=F??u[0]?.chatId;if(!i)return;let a=[...ct];if(a.length===0){ne({kind:"text",text:n("roles.applyPickBots")});return}ne({kind:"text",text:"..."});let c=await Promise.all(a.map(b=>sr({profileId:P,chatId:i,larkAppId:b,force:dt,preview:s})));if(r.current&&(ne({kind:"results",preview:s,results:c}),!s)){let b=await x();if(!r.current)return;R(b.groups,g)}}let Zr=Ye||Ee>$||_.trim().length===0,en=st||Ne||vt>ce||h.enabled&&h.prompt.trim().length===0,tn=pt||Ae>$||te.trim().length===0,q=t.tab==="profiles",rn=(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${q?"":" on"}`,role:"tab","aria-selected":!q,children:n("roles.tabGroups")}),(0,e.jsx)("a",{href:"#/roles/profile",className:`itab${q?" on":""}`,role:"tab","aria-selected":q,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:rn})]}),(0,e.jsxs)("div",{id:"roles-by-group-view",className:"roles-layout",hidden:q,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:Y,onChange:s=>pe(s.target.value)}),(0,e.jsx)(Ge,{id:"roles-refresh",label:n("roles.refresh"),onClick:()=>{Ar()}})]}),(0,e.jsx)("div",{id:"roles-tree",className:"roles-tree",children:Se?(0,e.jsx)(ae,{label:n("common.loading")}):(0,e.jsx)(yn,{groups:Mr,profiles:g,context:Ie,contextLoaded:we,expandedGroups:G,selectedGroupId:y,selectedBotId:l,tr:n,onToggleGroup:s=>fe(i=>mn(i,s)),onSelectBot:(s,i)=>{Er(s,i)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:!y||!l?(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:Me?.name??y}),(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{id:"roles-editor-bot-name",children:kr?.botName??l})]}),(0,e.jsx)("div",{className:"roles-editor-meta",children:(0,e.jsxs)("span",{id:"roles-editor-chat-id",className:"roles-editor-meta-line",children:[y," \xB7 ",l]})})]}),(0,e.jsx)("div",{className:"roles-editor-actions roles-editor-head-actions",children:V==="role"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",id:"roles-delete",className:"danger",style:{display:w?.hasRole?"":"none"},disabled:Xe,onClick:()=>{Dr()},children:Xe?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-save",className:"primary",disabled:Zr,onClick:()=>{Br()},children:Ye?"...":n("roles.save")})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",id:"roles-listener-delete",className:"danger",style:{display:mr?.enabled?"":"none"},disabled:Ne,onClick:()=>{wt()},children:Ne?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-listener-save",className:"primary",disabled:en,onClick:()=>{Wr()},children:st?"...":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:V==="role"?"active":"","aria-pressed":V==="role",onClick:()=>et("role"),children:n("roles.roleTab")}),(0,e.jsx)("button",{type:"button",className:V==="listener"?"active":"","aria-pressed":V==="listener",onClick:()=>et("listener"),children:n("roles.listenerTab")})]}),V==="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)(_e,{id:"roles-editor-inject-mode",className:"roles-inline-menu",ariaLabel:n("roles.injectModeLabel"),disabled:ur,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=>{Gr(s==="once"?"once":"every")}}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:n("roles.injectModeHint")}),(0,e.jsx)(Pe,{flash:fr})]}),(0,e.jsx)("textarea",{id:"roles-editor-textarea",placeholder:n("roles.editorPlaceholder"),rows:14,value:_,onChange:s=>me(s.target.value)}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-editor-bytecount",className:lr(Ee),children:[Ee," / ",$," bytes"]}),(0,e.jsx)(Pe,{flash:pr})]}),(0,e.jsx)(ir,{content:_,tr:n,id:"roles-preview"})]}):(0,e.jsx)(bn,{listener:h,members:ke,memberById:Cr,promptByteLen:vt,loading:yr,membersLoading:vr,flash:br,tr:n,onPatch:_r,onSenderPolicyPatch:Fr,onMessagePolicyPatch:$r,onToggleSenderType:Or,onToggleMsgType:Ur,onSetTargetPolicy:jr,onSetTargetsPolicy:Vr,previewLimit:Le,previewStatus:Pr,onPreviewLimitChange:hr,onPreview:()=>{It(!1)},onRunPreview:()=>{It(!0)}})]})})]}),(0,e.jsxs)("div",{id:"roles-profiles-view",className:"roles-layout roles-profiles-layout",hidden:!q,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:yt,onChange:s=>s.currentTarget.setCustomValidity("")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-select",onClick:()=>{Jr()},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:E,onChange:s=>D(s.target.value)}),(0,e.jsx)(Ge,{id:"roles-profile-refresh",label:n("roles.refresh"),onClick:()=>{Yr()}})]}),(0,e.jsx)("div",{id:"roles-profile-list",className:"roles-tree",children:z?(0,e.jsx)(ae,{label:n("common.loading")}):(0,e.jsx)(In,{profiles:xr,selectedProfileId:P,tr:n,onSelect:s=>{St(s)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:P?(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:P}),xe?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{children:xe.botName??xe.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 i=!!ue(Z,s.larkAppId),a=M===s.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row roles-profile-bot-row ${a?"selected":""}`,"data-profile-bot-id":s.larkAppId,onClick:()=>{zr(s.larkAppId)},children:[(0,e.jsx)(dr,{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 ${i?"has-role":"no-role"}`,children:n(i?"roles.configured":"roles.unconfigured")})]},s.larkAppId)})})]}),(0,e.jsx)("div",{className:"roles-profile-editor",children:M?(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:lr(Ae),children:[Ae," / ",$," 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:Nr?"":"none"},disabled:mt,onClick:()=>{Kr()},children:mt?"...":n("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-save",className:"primary",disabled:tn,onClick:()=>{Xr()},children:pt?"...":n("roles.saveEntry")})]})]}),(0,e.jsx)("textarea",{id:"roles-profile-textarea",placeholder:n("roles.profileEditorPlaceholder"),rows:12,value:te,onChange:s=>ye(s.target.value)}),(0,e.jsx)("div",{className:"roles-editor-footer",children:(0,e.jsx)(Pe,{flash:Sr})}),(0,e.jsx)(ir,{content:te,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)(_e,{id:"roles-profile-apply-group",className:"roles-apply-group-menu",ariaLabel:n("roles.applyToGroup"),disabled:u.length===0,label:Ce?.name??F??n("roles.noChats"),value:F??"",options:u.map(s=>({value:s.chatId,label:s.name??s.chatId})),onChange:s=>re(s)}),(0,e.jsxs)("label",{className:"roles-profile-force",children:[(0,e.jsx)("input",{type:"checkbox",id:"roles-profile-apply-force",checked:dt,onChange:s=>wr(s.target.checked)})," ",n("roles.applyForce")]})]}),(0,e.jsx)("div",{id:"roles-profile-apply-bots",children:!Ce||ve.length===0?(0,e.jsx)("div",{className:"roles-empty",children:n("roles.noChats")}):ve.map(s=>{let i=!!ue(Z,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:ct.has(s.larkAppId),onChange:a=>Qr(s.larkAppId,a.target.checked)}),(0,e.jsx)("span",{children:s.botName??s.larkAppId}),(0,e.jsx)("small",{children:n(i?"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:()=>{Rt(!0)},children:n("roles.previewApply")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-apply",className:"primary",onClick:()=>{Rt(!1)},children:n("roles.applyProfile")})]}),(0,e.jsx)("div",{id:"roles-profile-apply-status",className:"roles-profile-status",children:(0,e.jsx)(wn,{status:Rr,bots:f,tr:n})})]})]}):(0,e.jsx)("div",{id:"roles-profile-empty",className:"roles-editor-empty",children:n("roles.profileSelectHint")})})]})]})}function mn(t,n){let r=new Set(t);return r.has(n)?r.delete(n):r.add(n),r}function lr(t){return`roles-bytecount ${t>Dt?"warn":""} ${t>$?"over":""}`}function gn(t){return`roles-bytecount ${t>Gt?"warn":""} ${t>ce?"over":""}`}function Pe(t){return t.flash?(0,e.jsxs)("span",{className:`roles-saved-flash ${t.flash.isError?"roles-save-error":""}`,children:[" ",t.flash.text]}):null}function yn(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),u=r.memberBots.filter(p=>p.inChat),m=Ft(r),f=$t(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)(vn,{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?u.map(p=>{let g=t.selectedGroupId===r.chatId&&t.selectedBotId===p.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row ${g?"selected":""}`,"data-group-id":r.chatId,"data-bot-id":p.larkAppId,onClick:k=>{k.stopPropagation(),t.onSelectBot(r.chatId,p.larkAppId)},children:[(0,e.jsx)("span",{className:"roles-bot-indent"}),(0,e.jsx)(dr,{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 vn(t){let{group:n,profiles:r,context:o,loaded:u,tr:m}=t;if(!r.length||!u)return null;let f=new Map;for(let k of n.memberBots)k.inChat&&f.set(k.larkAppId,o.effectiveRolesByBot.get(Ve(k.larkAppId,n.chatId))??null);if(!xt(f))return null;let p=Ct(n.memberBots,r,o.entriesByProfile,f)[0];if(!p)return(0,e.jsx)("div",{className:"roles-profile-match muted",children:m("groups.profileStatusUnmatched")});let g=p.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`roles-profile-match ${p.kind}`,children:m(g,{name:p.profileId,matched:p.matched,total:p.total,chat:p.chatMatched})})}function bn(t){let{listener:n,tr:r}=t,[o,u]=(0,d.useState)("members"),[m,f]=(0,d.useState)(""),[p,g]=(0,d.useState)(()=>new Set),k=new Set(n.senderPolicy?.includeSenderTypes??[]),Ie=new Set(n.messagePolicy?.includeMsgTypes??[]),U=new Set(n.senderPolicy?.includeSenderOpenIds??[]),we=[...[...U].filter(l=>!t.memberById.has(l))],j=[...t.members.filter(l=>l.memberType!=="bot"),...we.map(l=>({openId:l,name:l,memberType:"unknown"}))],Se=t.members.filter(l=>l.memberType==="bot"),C=o==="bots"?Se:j,z=Bt(C,m),I=z.map(l=>l.openId),Y=I.filter(l=>p.has(l)),pe=I.length>0&&Y.length===I.length,E=[...p].filter(l=>C.some(v=>v.openId===l)),D=E.length>0?E:I,G=$e({include:[...U],exclude:[],targetIds:D});(0,d.useEffect)(()=>{f(""),g(new Set)},[o]),(0,d.useEffect)(()=>{let l=new Set(C.map(v=>v.openId));g(v=>{let w=new Set([...v].filter(N=>l.has(N)));return w.size===v.size?v:w})},[C]);let fe=(l,v)=>{g(w=>{let N=new Set(w);return v?N.add(l):N.delete(l),N})},y=()=>{g(l=>{let v=new Set(l);if(pe)for(let w of I)v.delete(w);else for(let w of I)v.add(w);return v})},J=l=>{D.length!==0&&t.onSetTargetsPolicy(D,l)};return(0,e.jsxs)("div",{className:"roles-listener-editor",children:[t.loading?(0,e.jsx)(ae,{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:l=>t.onPatch({enabled:l.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:l=>t.onPatch({name:l.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:l=>t.onPatch({replyCardTitle:l.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:l=>t.onPatch({workingDir:l.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:k.has("user"),onChange:l=>t.onToggleSenderType("user",l.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:k.has("bot"),onChange:l=>t.onToggleSenderType("bot",l.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")}),ar.map(l=>(0,e.jsxs)("label",{className:"roles-listener-chip",children:[(0,e.jsx)("input",{type:"checkbox",checked:Ie.has(l),onChange:v=>t.onToggleMsgType(l,v.currentTarget.checked)}),(0,e.jsx)("span",{children:l})]},l))]}),(0,e.jsxs)("label",{className:"roles-listener-checkbox",children:[(0,e.jsx)("input",{type:"checkbox",checked:n.senderPolicy?.excludeSelf!==!1,onChange:l=>t.onSenderPolicyPatch({excludeSelf:l.currentTarget.checked})}),(0,e.jsx)("span",{children:r("roles.listenerExcludeSelf")})]})]}),(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:l=>t.onPatch({prompt:l.currentTarget.value})})]}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-listener-bytecount",className:gn(t.promptByteLen),children:[t.promptByteLen," / ",ce," bytes"]}),(0,e.jsx)(Pe,{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:l=>t.onPreviewLimitChange(Number(l.currentTarget.value)),children:Array.from({length:Ue},(l,v)=>v+1).map(l=>(0,e.jsx)("option",{value:l,children:l},l))})]}),(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)(hn,{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:()=>u("members"),children:r("roles.listenerMembers")}),(0,e.jsx)("button",{type:"button",className:o==="bots"?"active":"","aria-pressed":o==="bots",onClick:()=>u("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:l=>f(l.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:I.length===0,onClick:y,children:r(pe?"roles.listenerClearVisible":"roles.listenerSelectVisible",{count:I.length})})]}),(0,e.jsxs)("div",{className:"roles-listener-bulkbar",children:[(0,e.jsxs)("span",{children:[E.length>0?r("roles.listenerSelectedCount",{count:E.length}):r("roles.listenerFilteredCount",{count:I.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:D.length===0,onClick:()=>J(!0),children:r("roles.listenerTargetListen")}),(0,e.jsx)("button",{type:"button",className:G==="ignore"?"active":"","aria-pressed":G==="ignore",disabled:D.length===0,onClick:()=>J(!1),children:r("roles.listenerTargetIgnore")})]})]}),(0,e.jsx)("div",{className:"roles-listener-member-list",children:z.length===0?(0,e.jsx)("div",{className:"roles-empty",children:r(o==="bots"?"roles.listenerBotsEmpty":"roles.listenerMembersEmpty")}):z.map(l=>{let v=$e({include:[...U],exclude:[],targetIds:[l.openId]});return(0,e.jsxs)("div",{className:"roles-listener-member",children:[(0,e.jsx)("label",{className:"roles-listener-member-select","aria-label":We(l,l.openId),children:(0,e.jsx)("input",{type:"checkbox",checked:p.has(l.openId),onChange:w=>fe(l.openId,w.currentTarget.checked)})}),(0,e.jsxs)("div",{className:"roles-listener-member-main",children:[(0,e.jsx)("strong",{children:We(l,l.openId)}),(0,e.jsx)("span",{children:l.openId})]}),(0,e.jsxs)("div",{className:"roles-listener-member-actions",role:"group","aria-label":We(l,l.openId),children:[(0,e.jsx)("button",{type:"button",className:v==="listen"?"active":"","aria-pressed":v==="listen",onClick:()=>t.onSetTargetPolicy(l.openId,!0),children:r("roles.listenerTargetListen")}),(0,e.jsx)("button",{type:"button",className:v==="ignore"?"active":"","aria-pressed":v==="ignore",onClick:()=>t.onSetTargetPolicy(l.openId,!1),children:r("roles.listenerTargetIgnore")})]})]},l.openId)})})]})]})}function ir(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 hn(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)(ae,{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 g=p.ok?p.state??"triggered":"failed";return f[g]=(f[g]??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)(Pn,{item:f,result:n.response.results?.find(p=>p.messageId===f.messageId),tr:r},f.messageId))})]})}function Pn(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=Jt(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:cn(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 In(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,u=(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 ${u?"has-role":"no-role"}`,children:n(u?"roles.configured":"roles.profileMissing")})]},r.profileId)})})}function wn(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(u=>{let f=r.find(g=>g.larkAppId===u.larkAppId)?.botName??u.larkAppId,p=u.ok?n.preview?u.wouldRefuse?o("roles.applyWouldRefuse"):o("roles.applyPreviewOk"):o("roles.applyOk"):`${o("roles.applyFailed")}: ${String(u.error??`HTTP ${u.status}`)}`;return(0,e.jsxs)("div",{children:[f,": ",p]},u.larkAppId)})})}function An(t){return De(t,(0,e.jsx)(cr,{tab:"groups"}))}function Bn(t){return De(t,(0,e.jsx)(cr,{tab:"profiles"}))}export{Bn as renderRoleProfilesPage,An as renderRolesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as j,c as F}from"./chunk-FLGXZJTD.js";import{g as q,l as Z,m as _,n as B,o as K,p as U}from"./chunk-QFMH6ITB.js";import"./chunk-KQB42ML5.js";import{a as D}from"./chunk-SYC6D5XU.js";import{a as G,d as H}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var i=$(G(),1);var e=$(H(),1),z=1e3;function J(l,t){if(!l)return"\u2014";try{return new Date(l).toLocaleString(void 0,t?{timeZone:t,timeZoneName:"short"}:void 0)}catch{return l}}function Q(l,t){let n=t.q.toLowerCase();return l.filter(o=>!t.kind||o.parsed?.kind===t.kind).filter(o=>!t.enabledOnly||o.enabled).filter(o=>!n||JSON.stringify(o).toLowerCase().includes(n)).sort((o,d)=>{if(o.enabled!==d.enabled)return o.enabled?-1:1;let f=o.nextRunAt?Date.parse(o.nextRunAt):1/0,p=d.nextRunAt?Date.parse(d.nextRunAt):1/0;return f-p})}function O(l){return l.deliver==="local"?"local":l.executionPosition==="new-topic"?"new-topic":l.executionPosition==="topic"?l.rootMessageId?"thread":"chat":l.executionPosition==="top-level"?"chat":l.deliver==="new-topic"?"new-topic":l.scope==="chat"?"chat":l.rootMessageId?"thread":"chat"}function V(l,t){let n=O(l);return t(n==="local"?"schedules.deliveryLocal":n==="new-topic"?"schedules.deliveryNewTopic":n==="thread"?"schedules.deliveryThread":"schedules.deliveryTopLevel")}function W(l){return l.repeat?`${l.repeat.completed}/${l.repeat.times??"\u221E"}`:"\u2014"}function X(l){return new Promise(t=>window.setTimeout(t,l))}function Y(l){let{schedule:t,scheduleTimeZone:n,tr:o}=l,d=String(t.parsed?.kind??"unknown"),f=t.enabled?"pause":"resume",p=`${t.id}:${f}`,y=`${t.id}:run`;return(0,e.jsxs)(_,{kind:"schedule",className:"schedule-list-row","data-id":t.id,children:[(0,e.jsxs)(B,{children:[(0,e.jsxs)("div",{className:"schedule-row-head",children:[(0,e.jsx)("b",{children:t.name??t.id}),(0,e.jsx)("span",{className:`schedule-state ${t.enabled?"enabled":"paused"}`,children:t.enabled?o("schedules.enabled"):o("schedules.paused")})]}),(0,e.jsxs)("div",{className:"schedule-row-meta",children:[(0,e.jsx)("span",{children:t.botName??t.larkAppId??"-"}),(0,e.jsx)("span",{children:"\xB7"}),(0,e.jsx)("code",{children:t.parsed?.display??"?"})]}),(0,e.jsxs)("div",{className:"schedule-chip-strip",children:[(0,e.jsx)("span",{children:d}),(0,e.jsxs)("span",{children:[o("schedules.delivery"),": ",V(t,o)]}),t.silent?(0,e.jsxs)("span",{children:["\u{1F507} ",o("schedules.silent")]}):null,(0,e.jsxs)("span",{children:[o("schedules.next"),": ",J(t.nextRunAt,n)]}),(0,e.jsxs)("span",{children:[o("schedules.last"),": ",J(t.lastRunAt,n)]}),t.lastStatus==="error"?(0,e.jsxs)("span",{className:"schedule-error-chip",title:typeof t.lastError=="string"?t.lastError:void 0,children:["\u26A0 ",o("schedules.error"),": ",typeof t.lastError=="string"&&t.lastError.length>60?t.lastError.slice(0,60)+"\u2026":t.lastError??o("schedules.errorUnknown")]}):null,(0,e.jsxs)("span",{children:[o("schedules.repeat"),": ",W(t)]})]})]}),(0,e.jsx)(K,{children:(0,e.jsxs)("div",{className:"schedule-actions",children:[(0,e.jsx)(te,{op:"run",label:o("schedules.runNow"),pending:l.pending===y,feedback:l.feedback[y]??null,onClick:()=>l.onAction(t.id,"run")}),(0,e.jsx)(se,{checked:!!t.enabled,pending:l.pending===p,feedback:l.feedback[p]??null,tr:o,onClick:()=>l.onAction(t.id,f)}),(0,e.jsx)("button",{type:"button",className:"schedule-action-button schedule-edit-button",onClick:()=>l.onEdit(t),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:()=>l.onDelete(t),title:o("schedules.delete"),children:(0,e.jsx)("span",{className:"schedule-action-label",children:o("schedules.delete")})})]})})]})}function ee(){let l=F(),{scheduleRows:t,scheduleTimeZone:n}=j(s=>({scheduleRows:[...s.schedules.values()],scheduleTimeZone:s.scheduleTimeZone})),[o,d]=(0,i.useState)({q:"",kind:"",enabledOnly:!1}),[f,p]=(0,i.useState)(null),[y,I]=(0,i.useState)({}),w=(0,i.useRef)(new Map),[P,k]=(0,i.useState)(!1),[u,N]=(0,i.useState)(null),[T,S]=(0,i.useState)(null),[A,E]=(0,i.useState)([]);(0,i.useEffect)(()=>{fetch("/api/bots").then(s=>s.json()).then(s=>{Array.isArray(s?.bots)&&E(s.bots)}).catch(()=>{})},[]);let C=(0,i.useMemo)(()=>Q(t,o),[t,o]);(0,i.useEffect)(()=>()=>{w.current.forEach(s=>window.clearTimeout(s)),w.current.clear()},[]);function R(s,c){I(m=>({...m,[s]:c}));let r=w.current.get(s);r&&window.clearTimeout(r);let v=window.setTimeout(()=>{I(m=>{let h={...m};return delete h[s],h}),w.current.delete(s)},c==="success"?1600:2200);w.current.set(s,v)}async function b(s,c){let r=`${s}:${c}`,v=performance.now(),m="success";p(r);try{let h=await fetch(`/api/schedules/${encodeURIComponent(s)}/${c}`,{method:"POST"}),M=await h.json().catch(()=>({}));if(!h.ok||M.ok===!1)throw new Error(`Failed: ${h.status} ${M?.error??""}`.trim())}catch{m="error"}finally{if(c==="run"){let h=z-(performance.now()-v);h>0&&await X(h)}R(r,m),p(h=>h===r?null:h)}}function x(){N(null),S(null),k(!0)}function g(s){N(s),S(null),k(!0)}async function L(s){if(!window.confirm(l("schedules.deleteConfirm")))return;let c=`${s.id}:delete`;p(c);try{let r=await fetch(`/api/schedules/${encodeURIComponent(s.id)}`,{method:"DELETE"}),v=await r.json().catch(()=>({}));if(!r.ok||v.ok===!1)throw new Error(v?.error??`HTTP ${r.status}`);R(c,"success")}catch{R(c,"error")}finally{p(r=>r===c?null:r)}}async function a(s){S(null);try{let c=u?`/api/schedules/${encodeURIComponent(u.id)}`:"/api/schedules",r=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},m=await fetch(c,{method:r,headers:{"Content-Type":"application/json"},body:JSON.stringify(v)}),h=await m.json().catch(()=>({}));if(!m.ok||h.ok===!1)throw new Error(h?.error??`HTTP ${m.status}`);k(!1)}catch(c){S(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:l("nav.schedules")}),(0,e.jsx)("h1",{children:l("schedules.title")})]}),(0,e.jsx)(q,{onClick:x,disabled:A.length===0,children:l("schedules.create")})]}),(0,e.jsxs)("form",{id:"sched-filters",className:"filters dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",name:"q",placeholder:l("schedules.search"),value:o.q,onChange:s=>{let c=s.currentTarget.value;d(r=>({...r,q:c}))}}),(0,e.jsx)(U,{id:"sched-kind-menu",ariaLabel:l("schedules.anyKind"),label:o.kind||l("schedules.anyKind"),value:o.kind,options:[{value:"",label:l("schedules.anyKind")},{value:"cron",label:"cron"},{value:"interval",label:"interval"},{value:"once",label:"once"}],onChange:s=>d(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;d(r=>({...r,enabledOnly:c}))}}),(0,e.jsx)("span",{className:"filter-toggle-label",children:l("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:[C.length,"/",t.length]})]}),(0,e.jsx)("section",{className:"overview-block schedules-list-section",children:(0,e.jsx)("div",{className:"schedules-list-wrap",children:C.length===0?(0,e.jsx)("div",{id:"schedules-tbody",className:"empty schedules-list-empty",children:l("schedules.empty")}):(0,e.jsx)(Z,{id:"schedules-tbody",className:"schedules-list",children:C.map(s=>(0,e.jsx)(Y,{schedule:s,scheduleTimeZone:n,pending:f,feedback:y,tr:l,onAction:(c,r)=>{b(c,r)},onEdit:g,onDelete:c=>{L(c)}},s.id))})})}),P?(0,e.jsx)(ne,{editing:u,error:T,bots:A,tr:l,onClose:()=>k(!1),onSubmit:s=>{a(s)}}):null]})}function le(l,t,n,o,d){return n?d(l==="run"?"schedules.running":"schedules.saving"):o==="success"?d(l==="run"?"schedules.runDone":"schedules.saved"):o==="error"?d("schedules.failed"):t}function te(l){let t=F(),n=l.feedback?` is-${l.feedback}`:"";return(0,e.jsx)("button",{type:"button",className:`schedule-action-button${l.pending?" is-pending":""}${n}`,"data-op":l.op,disabled:l.pending,onClick:l.onClick,children:(0,e.jsx)("span",{className:"schedule-action-label",children:le(l.op,l.label,l.pending,l.feedback,t)})})}function se(l){let t=l.feedback==="error"?l.tr("schedules.failed"):l.checked?l.tr("schedules.enabled"):l.tr("schedules.paused");return(0,e.jsxs)("button",{type:"button",className:`schedule-enabled-switch${l.checked?" is-on":""}${l.pending?" is-pending":""}${l.feedback?` is-${l.feedback}`:""}`,"aria-pressed":l.checked,disabled:l.pending,onClick:l.onClick,children:[(0,e.jsx)("span",{className:"schedule-enabled-switch-label",children:t}),(0,e.jsx)("span",{className:"schedule-enabled-switch-track","aria-hidden":"true",children:(0,e.jsx)("span",{})})]})}function ie(l){return D(l,(0,e.jsx)(ee,{}))}function ne(l){let{editing:t,tr:n,bots:o}=l,[d,f]=(0,i.useState)(t?.name??""),[p,y]=(0,i.useState)(t?.schedule??""),[I,w]=(0,i.useState)(t?.prompt??""),[P,k]=(0,i.useState)(t?.silent===!0),[u,N]=(0,i.useState)(t&&O(t)==="thread"?"topic":t&&O(t)==="new-topic"?"new-topic":"top-level"),[T,S]=(0,i.useState)(t?.rootMessageId??""),[A,E]=(0,i.useState)(t?.topicTitle??""),[C,R]=(0,i.useState)(t?.chatId??""),[b,x]=(0,i.useState)(t?.larkAppId??o[0]?.larkAppId??""),g=t?.deliver==="local";(0,i.useEffect)(()=>{!t&&!b&&o.length>0&&x(o[0].larkAppId)},[t,b,o]);function L(a){a.preventDefault(),!(!t&&!b)&&(!g&&u==="topic"&&!T.trim()||l.onSubmit({name:d,schedule:p,prompt:I,silent:P,executionPosition:u,rootMessageId:T.trim(),topicTitle:A.trim(),updateExecutionPosition:!g,chatId:C,larkAppId:b}))}return(0,e.jsx)("div",{className:"schedule-form-overlay",onClick:l.onClose,children:(0,e.jsxs)("div",{className:"schedule-form-dialog",role:"dialog","aria-modal":"true",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h2",{children:n(t?"schedules.edit":"schedules.create")}),(0,e.jsxs)("form",{onSubmit:L,className:"schedule-form",children:[t?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:b,onChange:a=>x(a.target.value),required:!0,children:o.map(a=>(0,e.jsx)("option",{value:a.larkAppId,children:a.botName??a.larkAppId},a.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:d,onChange:a=>f(a.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:a=>y(a.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:I,onChange:a=>w(a.target.value),rows:4,required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.promptHelp")})]}),t?null:(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:C,onChange:a=>R(a.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:()=>N("top-level")}),n("schedules.deliveryTopLevel")]}),(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"topic",checked:u==="topic",onChange:()=>N("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:()=>{N("new-topic"),k(!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:T,onChange:a=>S(a.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:A,onChange:a=>E(a.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(A).length,"/200"]})]})]}):null,(0,e.jsxs)("label",{className:"schedule-form-field schedule-form-toggle",children:[(0,e.jsx)("input",{type:"checkbox",checked:P,onChange:a=>k(a.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,l.error?(0,e.jsx)("p",{className:"schedule-form-error",children:l.error}):null,(0,e.jsxs)("div",{className:"schedule-form-actions",children:[(0,e.jsx)("button",{type:"button",className:"schedule-form-cancel",onClick:l.onClose,children:n("schedules.form.cancel")}),(0,e.jsx)("button",{type:"submit",className:"schedule-form-submit",disabled:!t&&!b||!g&&u==="topic"&&!T.trim(),children:n(t?"schedules.form.save":"schedules.form.create")})]})]})]})})}export{Q as filterSchedules,J as fmtScheduleDate,ie as renderSchedulesPage,O as scheduleExecutionPlacement};
|
|
1
|
+
import{a as j,c as F}from"./chunk-VA6QWSGQ.js";import{g as q,m as Z,n as _,o as B,p as K,q as U}from"./chunk-5CJMHTT4.js";import"./chunk-DLZK52JU.js";import{a as D}from"./chunk-SYC6D5XU.js";import{a as G,d as H}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var i=$(G(),1);var e=$(H(),1),z=1e3;function J(l,t){if(!l)return"\u2014";try{return new Date(l).toLocaleString(void 0,t?{timeZone:t,timeZoneName:"short"}:void 0)}catch{return l}}function Q(l,t){let n=t.q.toLowerCase();return l.filter(o=>!t.kind||o.parsed?.kind===t.kind).filter(o=>!t.enabledOnly||o.enabled).filter(o=>!n||JSON.stringify(o).toLowerCase().includes(n)).sort((o,d)=>{if(o.enabled!==d.enabled)return o.enabled?-1:1;let f=o.nextRunAt?Date.parse(o.nextRunAt):1/0,p=d.nextRunAt?Date.parse(d.nextRunAt):1/0;return f-p})}function O(l){return l.deliver==="local"?"local":l.executionPosition==="new-topic"?"new-topic":l.executionPosition==="topic"?l.rootMessageId?"thread":"chat":l.executionPosition==="top-level"?"chat":l.deliver==="new-topic"?"new-topic":l.scope==="chat"?"chat":l.rootMessageId?"thread":"chat"}function V(l,t){let n=O(l);return t(n==="local"?"schedules.deliveryLocal":n==="new-topic"?"schedules.deliveryNewTopic":n==="thread"?"schedules.deliveryThread":"schedules.deliveryTopLevel")}function W(l){return l.repeat?`${l.repeat.completed}/${l.repeat.times??"\u221E"}`:"\u2014"}function X(l){return new Promise(t=>window.setTimeout(t,l))}function Y(l){let{schedule:t,scheduleTimeZone:n,tr:o}=l,d=String(t.parsed?.kind??"unknown"),f=t.enabled?"pause":"resume",p=`${t.id}:${f}`,y=`${t.id}:run`;return(0,e.jsxs)(_,{kind:"schedule",className:"schedule-list-row","data-id":t.id,children:[(0,e.jsxs)(B,{children:[(0,e.jsxs)("div",{className:"schedule-row-head",children:[(0,e.jsx)("b",{children:t.name??t.id}),(0,e.jsx)("span",{className:`schedule-state ${t.enabled?"enabled":"paused"}`,children:t.enabled?o("schedules.enabled"):o("schedules.paused")})]}),(0,e.jsxs)("div",{className:"schedule-row-meta",children:[(0,e.jsx)("span",{children:t.botName??t.larkAppId??"-"}),(0,e.jsx)("span",{children:"\xB7"}),(0,e.jsx)("code",{children:t.parsed?.display??"?"})]}),(0,e.jsxs)("div",{className:"schedule-chip-strip",children:[(0,e.jsx)("span",{children:d}),(0,e.jsxs)("span",{children:[o("schedules.delivery"),": ",V(t,o)]}),t.silent?(0,e.jsxs)("span",{children:["\u{1F507} ",o("schedules.silent")]}):null,(0,e.jsxs)("span",{children:[o("schedules.next"),": ",J(t.nextRunAt,n)]}),(0,e.jsxs)("span",{children:[o("schedules.last"),": ",J(t.lastRunAt,n)]}),t.lastStatus==="error"?(0,e.jsxs)("span",{className:"schedule-error-chip",title:typeof t.lastError=="string"?t.lastError:void 0,children:["\u26A0 ",o("schedules.error"),": ",typeof t.lastError=="string"&&t.lastError.length>60?t.lastError.slice(0,60)+"\u2026":t.lastError??o("schedules.errorUnknown")]}):null,(0,e.jsxs)("span",{children:[o("schedules.repeat"),": ",W(t)]})]})]}),(0,e.jsx)(K,{children:(0,e.jsxs)("div",{className:"schedule-actions",children:[(0,e.jsx)(te,{op:"run",label:o("schedules.runNow"),pending:l.pending===y,feedback:l.feedback[y]??null,onClick:()=>l.onAction(t.id,"run")}),(0,e.jsx)(se,{checked:!!t.enabled,pending:l.pending===p,feedback:l.feedback[p]??null,tr:o,onClick:()=>l.onAction(t.id,f)}),(0,e.jsx)("button",{type:"button",className:"schedule-action-button schedule-edit-button",onClick:()=>l.onEdit(t),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:()=>l.onDelete(t),title:o("schedules.delete"),children:(0,e.jsx)("span",{className:"schedule-action-label",children:o("schedules.delete")})})]})})]})}function ee(){let l=F(),{scheduleRows:t,scheduleTimeZone:n}=j(s=>({scheduleRows:[...s.schedules.values()],scheduleTimeZone:s.scheduleTimeZone})),[o,d]=(0,i.useState)({q:"",kind:"",enabledOnly:!1}),[f,p]=(0,i.useState)(null),[y,I]=(0,i.useState)({}),w=(0,i.useRef)(new Map),[P,k]=(0,i.useState)(!1),[u,N]=(0,i.useState)(null),[T,S]=(0,i.useState)(null),[A,E]=(0,i.useState)([]);(0,i.useEffect)(()=>{fetch("/api/bots").then(s=>s.json()).then(s=>{Array.isArray(s?.bots)&&E(s.bots)}).catch(()=>{})},[]);let C=(0,i.useMemo)(()=>Q(t,o),[t,o]);(0,i.useEffect)(()=>()=>{w.current.forEach(s=>window.clearTimeout(s)),w.current.clear()},[]);function R(s,c){I(m=>({...m,[s]:c}));let r=w.current.get(s);r&&window.clearTimeout(r);let v=window.setTimeout(()=>{I(m=>{let h={...m};return delete h[s],h}),w.current.delete(s)},c==="success"?1600:2200);w.current.set(s,v)}async function b(s,c){let r=`${s}:${c}`,v=performance.now(),m="success";p(r);try{let h=await fetch(`/api/schedules/${encodeURIComponent(s)}/${c}`,{method:"POST"}),M=await h.json().catch(()=>({}));if(!h.ok||M.ok===!1)throw new Error(`Failed: ${h.status} ${M?.error??""}`.trim())}catch{m="error"}finally{if(c==="run"){let h=z-(performance.now()-v);h>0&&await X(h)}R(r,m),p(h=>h===r?null:h)}}function x(){N(null),S(null),k(!0)}function g(s){N(s),S(null),k(!0)}async function L(s){if(!window.confirm(l("schedules.deleteConfirm")))return;let c=`${s.id}:delete`;p(c);try{let r=await fetch(`/api/schedules/${encodeURIComponent(s.id)}`,{method:"DELETE"}),v=await r.json().catch(()=>({}));if(!r.ok||v.ok===!1)throw new Error(v?.error??`HTTP ${r.status}`);R(c,"success")}catch{R(c,"error")}finally{p(r=>r===c?null:r)}}async function a(s){S(null);try{let c=u?`/api/schedules/${encodeURIComponent(u.id)}`:"/api/schedules",r=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},m=await fetch(c,{method:r,headers:{"Content-Type":"application/json"},body:JSON.stringify(v)}),h=await m.json().catch(()=>({}));if(!m.ok||h.ok===!1)throw new Error(h?.error??`HTTP ${m.status}`);k(!1)}catch(c){S(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:l("nav.schedules")}),(0,e.jsx)("h1",{children:l("schedules.title")})]}),(0,e.jsx)(q,{onClick:x,disabled:A.length===0,children:l("schedules.create")})]}),(0,e.jsxs)("form",{id:"sched-filters",className:"filters dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",name:"q",placeholder:l("schedules.search"),value:o.q,onChange:s=>{let c=s.currentTarget.value;d(r=>({...r,q:c}))}}),(0,e.jsx)(U,{id:"sched-kind-menu",ariaLabel:l("schedules.anyKind"),label:o.kind||l("schedules.anyKind"),value:o.kind,options:[{value:"",label:l("schedules.anyKind")},{value:"cron",label:"cron"},{value:"interval",label:"interval"},{value:"once",label:"once"}],onChange:s=>d(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;d(r=>({...r,enabledOnly:c}))}}),(0,e.jsx)("span",{className:"filter-toggle-label",children:l("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:[C.length,"/",t.length]})]}),(0,e.jsx)("section",{className:"overview-block schedules-list-section",children:(0,e.jsx)("div",{className:"schedules-list-wrap",children:C.length===0?(0,e.jsx)("div",{id:"schedules-tbody",className:"empty schedules-list-empty",children:l("schedules.empty")}):(0,e.jsx)(Z,{id:"schedules-tbody",className:"schedules-list",children:C.map(s=>(0,e.jsx)(Y,{schedule:s,scheduleTimeZone:n,pending:f,feedback:y,tr:l,onAction:(c,r)=>{b(c,r)},onEdit:g,onDelete:c=>{L(c)}},s.id))})})}),P?(0,e.jsx)(ne,{editing:u,error:T,bots:A,tr:l,onClose:()=>k(!1),onSubmit:s=>{a(s)}}):null]})}function le(l,t,n,o,d){return n?d(l==="run"?"schedules.running":"schedules.saving"):o==="success"?d(l==="run"?"schedules.runDone":"schedules.saved"):o==="error"?d("schedules.failed"):t}function te(l){let t=F(),n=l.feedback?` is-${l.feedback}`:"";return(0,e.jsx)("button",{type:"button",className:`schedule-action-button${l.pending?" is-pending":""}${n}`,"data-op":l.op,disabled:l.pending,onClick:l.onClick,children:(0,e.jsx)("span",{className:"schedule-action-label",children:le(l.op,l.label,l.pending,l.feedback,t)})})}function se(l){let t=l.feedback==="error"?l.tr("schedules.failed"):l.checked?l.tr("schedules.enabled"):l.tr("schedules.paused");return(0,e.jsxs)("button",{type:"button",className:`schedule-enabled-switch${l.checked?" is-on":""}${l.pending?" is-pending":""}${l.feedback?` is-${l.feedback}`:""}`,"aria-pressed":l.checked,disabled:l.pending,onClick:l.onClick,children:[(0,e.jsx)("span",{className:"schedule-enabled-switch-label",children:t}),(0,e.jsx)("span",{className:"schedule-enabled-switch-track","aria-hidden":"true",children:(0,e.jsx)("span",{})})]})}function ie(l){return D(l,(0,e.jsx)(ee,{}))}function ne(l){let{editing:t,tr:n,bots:o}=l,[d,f]=(0,i.useState)(t?.name??""),[p,y]=(0,i.useState)(t?.schedule??""),[I,w]=(0,i.useState)(t?.prompt??""),[P,k]=(0,i.useState)(t?.silent===!0),[u,N]=(0,i.useState)(t&&O(t)==="thread"?"topic":t&&O(t)==="new-topic"?"new-topic":"top-level"),[T,S]=(0,i.useState)(t?.rootMessageId??""),[A,E]=(0,i.useState)(t?.topicTitle??""),[C,R]=(0,i.useState)(t?.chatId??""),[b,x]=(0,i.useState)(t?.larkAppId??o[0]?.larkAppId??""),g=t?.deliver==="local";(0,i.useEffect)(()=>{!t&&!b&&o.length>0&&x(o[0].larkAppId)},[t,b,o]);function L(a){a.preventDefault(),!(!t&&!b)&&(!g&&u==="topic"&&!T.trim()||l.onSubmit({name:d,schedule:p,prompt:I,silent:P,executionPosition:u,rootMessageId:T.trim(),topicTitle:A.trim(),updateExecutionPosition:!g,chatId:C,larkAppId:b}))}return(0,e.jsx)("div",{className:"schedule-form-overlay",onClick:l.onClose,children:(0,e.jsxs)("div",{className:"schedule-form-dialog",role:"dialog","aria-modal":"true",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h2",{children:n(t?"schedules.edit":"schedules.create")}),(0,e.jsxs)("form",{onSubmit:L,className:"schedule-form",children:[t?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:b,onChange:a=>x(a.target.value),required:!0,children:o.map(a=>(0,e.jsx)("option",{value:a.larkAppId,children:a.botName??a.larkAppId},a.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:d,onChange:a=>f(a.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:a=>y(a.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:I,onChange:a=>w(a.target.value),rows:4,required:!0}),(0,e.jsx)("small",{className:"schedule-form-help",children:n("schedules.form.promptHelp")})]}),t?null:(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:C,onChange:a=>R(a.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:()=>N("top-level")}),n("schedules.deliveryTopLevel")]}),(0,e.jsxs)("label",{children:[(0,e.jsx)("input",{type:"radio",name:"executionPosition",value:"topic",checked:u==="topic",onChange:()=>N("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:()=>{N("new-topic"),k(!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:T,onChange:a=>S(a.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:A,onChange:a=>E(a.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(A).length,"/200"]})]})]}):null,(0,e.jsxs)("label",{className:"schedule-form-field schedule-form-toggle",children:[(0,e.jsx)("input",{type:"checkbox",checked:P,onChange:a=>k(a.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,l.error?(0,e.jsx)("p",{className:"schedule-form-error",children:l.error}):null,(0,e.jsxs)("div",{className:"schedule-form-actions",children:[(0,e.jsx)("button",{type:"button",className:"schedule-form-cancel",onClick:l.onClose,children:n("schedules.form.cancel")}),(0,e.jsx)("button",{type:"submit",className:"schedule-form-submit",disabled:!t&&!b||!g&&u==="topic"&&!T.trim(),children:n(t?"schedules.form.save":"schedules.form.create")})]})]})]})})}export{Q as filterSchedules,J as fmtScheduleDate,ie as renderSchedulesPage,O as scheduleExecutionPlacement};
|