botmux 3.5.2 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +56 -396
- package/README.md +55 -396
- package/dist/.runtime-build-id +1 -0
- package/dist/adapters/cli/claude-code.d.ts +6 -0
- package/dist/adapters/cli/claude-code.d.ts.map +1 -1
- package/dist/adapters/cli/claude-code.js +197 -11
- package/dist/adapters/cli/claude-code.js.map +1 -1
- package/dist/adapters/cli/coco.js +4 -4
- package/dist/adapters/cli/coco.js.map +1 -1
- package/dist/adapters/cli/codex-app.d.ts.map +1 -1
- package/dist/adapters/cli/codex-app.js +9 -6
- package/dist/adapters/cli/codex-app.js.map +1 -1
- package/dist/adapters/cli/codex.js +5 -5
- package/dist/adapters/cli/codex.js.map +1 -1
- package/dist/adapters/cli/fs-policy.d.ts.map +1 -1
- package/dist/adapters/cli/fs-policy.js +5 -7
- package/dist/adapters/cli/fs-policy.js.map +1 -1
- package/dist/adapters/cli/grok.d.ts +2 -1
- package/dist/adapters/cli/grok.d.ts.map +1 -1
- package/dist/adapters/cli/grok.js +2 -1
- package/dist/adapters/cli/grok.js.map +1 -1
- package/dist/adapters/cli/hermes.d.ts.map +1 -1
- package/dist/adapters/cli/hermes.js +8 -4
- package/dist/adapters/cli/hermes.js.map +1 -1
- package/dist/adapters/cli/mtr.d.ts.map +1 -1
- package/dist/adapters/cli/mtr.js +3 -2
- package/dist/adapters/cli/mtr.js.map +1 -1
- package/dist/adapters/cli/opencode.d.ts.map +1 -1
- package/dist/adapters/cli/opencode.js +5 -4
- package/dist/adapters/cli/opencode.js.map +1 -1
- package/dist/adapters/cli/relay.js +2 -2
- package/dist/adapters/cli/relay.js.map +1 -1
- package/dist/adapters/cli/runner-input.d.ts +2 -2
- package/dist/adapters/cli/runner-input.d.ts.map +1 -1
- package/dist/adapters/cli/runner-input.js +9 -6
- package/dist/adapters/cli/runner-input.js.map +1 -1
- package/dist/adapters/cli/seed.d.ts.map +1 -1
- package/dist/adapters/cli/seed.js +2 -1
- package/dist/adapters/cli/seed.js.map +1 -1
- package/dist/adapters/cli/traex.d.ts.map +1 -1
- package/dist/adapters/cli/traex.js +3 -2
- package/dist/adapters/cli/traex.js.map +1 -1
- package/dist/adapters/cli/types.d.ts +25 -18
- package/dist/adapters/cli/types.d.ts.map +1 -1
- package/dist/bot-registry.d.ts +28 -0
- package/dist/bot-registry.d.ts.map +1 -1
- package/dist/bot-registry.js +75 -0
- package/dist/bot-registry.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +272 -86
- package/dist/cli.js.map +1 -1
- package/dist/codex-app-runner.js +85 -192
- package/dist/codex-app-runner.js.map +1 -1
- package/dist/config.d.ts +0 -16
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -30
- package/dist/config.js.map +1 -1
- package/dist/core/ask-broker.d.ts +12 -0
- package/dist/core/ask-broker.d.ts.map +1 -1
- package/dist/core/ask-broker.js +41 -0
- package/dist/core/ask-broker.js.map +1 -1
- package/dist/core/bot-turn-mutation-gate.d.ts +24 -0
- package/dist/core/bot-turn-mutation-gate.d.ts.map +1 -0
- package/dist/core/bot-turn-mutation-gate.js +369 -0
- package/dist/core/bot-turn-mutation-gate.js.map +1 -0
- package/dist/core/command-handler.d.ts +5 -0
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +38 -16
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
- package/dist/core/dashboard-ipc-server.js +330 -57
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/core/dashboard-rows.d.ts +8 -0
- package/dist/core/dashboard-rows.d.ts.map +1 -1
- package/dist/core/dashboard-rows.js.map +1 -1
- package/dist/core/host-overload-alert.d.ts +157 -0
- package/dist/core/host-overload-alert.d.ts.map +1 -0
- package/dist/core/host-overload-alert.js +251 -0
- package/dist/core/host-overload-alert.js.map +1 -0
- package/dist/core/passthrough-commands.d.ts +8 -0
- package/dist/core/passthrough-commands.d.ts.map +1 -1
- package/dist/core/passthrough-commands.js +19 -0
- package/dist/core/passthrough-commands.js.map +1 -1
- package/dist/core/restart-coordinator.d.ts +28 -0
- package/dist/core/restart-coordinator.d.ts.map +1 -0
- package/dist/core/restart-coordinator.js +82 -0
- package/dist/core/restart-coordinator.js.map +1 -0
- package/dist/core/restart-followup-policy.d.ts +112 -0
- package/dist/core/restart-followup-policy.d.ts.map +1 -0
- package/dist/core/restart-followup-policy.js +49 -0
- package/dist/core/restart-followup-policy.js.map +1 -0
- package/dist/core/role-library.d.ts +1 -1
- package/dist/core/role-library.js +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +8 -0
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-discovery.d.ts +14 -0
- package/dist/core/session-discovery.d.ts.map +1 -1
- package/dist/core/session-discovery.js +25 -0
- package/dist/core/session-discovery.js.map +1 -1
- package/dist/core/session-liveness.d.ts +15 -0
- package/dist/core/session-liveness.d.ts.map +1 -0
- package/dist/core/session-liveness.js +76 -0
- package/dist/core/session-liveness.js.map +1 -0
- package/dist/core/session-row-enrichment.d.ts +15 -0
- package/dist/core/session-row-enrichment.d.ts.map +1 -0
- package/dist/core/session-row-enrichment.js +93 -0
- package/dist/core/session-row-enrichment.js.map +1 -0
- package/dist/core/slash-inject.js +1 -1
- package/dist/core/slash-inject.js.map +1 -1
- package/dist/core/trigger-final-suppression.d.ts +24 -0
- package/dist/core/trigger-final-suppression.d.ts.map +1 -0
- package/dist/core/trigger-final-suppression.js +97 -0
- package/dist/core/trigger-final-suppression.js.map +1 -0
- package/dist/core/trigger-session.d.ts.map +1 -1
- package/dist/core/trigger-session.js +64 -4
- package/dist/core/trigger-session.js.map +1 -1
- package/dist/core/types.d.ts +6 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-pool.d.ts +20 -0
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +283 -32
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts +5 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +520 -35
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/aggregator.d.ts +1 -0
- package/dist/dashboard/aggregator.d.ts.map +1 -1
- package/dist/dashboard/aggregator.js +34 -6
- package/dist/dashboard/aggregator.js.map +1 -1
- package/dist/dashboard/bot-payload.d.ts +3 -0
- package/dist/dashboard/bot-payload.d.ts.map +1 -1
- package/dist/dashboard/bot-payload.js +3 -0
- package/dist/dashboard/bot-payload.js.map +1 -1
- package/dist/dashboard/compat.d.ts +102 -2
- package/dist/dashboard/compat.d.ts.map +1 -1
- package/dist/dashboard/compat.js +78 -14
- package/dist/dashboard/compat.js.map +1 -1
- package/dist/dashboard/connector-api.d.ts.map +1 -1
- package/dist/dashboard/connector-api.js +1 -0
- package/dist/dashboard/connector-api.js.map +1 -1
- package/dist/dashboard/desktop-asks.d.ts +21 -0
- package/dist/dashboard/desktop-asks.d.ts.map +1 -0
- package/dist/dashboard/desktop-asks.js +49 -0
- package/dist/dashboard/desktop-asks.js.map +1 -0
- package/dist/dashboard/public-redact.d.ts +7 -0
- package/dist/dashboard/public-redact.d.ts.map +1 -1
- package/dist/dashboard/public-redact.js +35 -3
- package/dist/dashboard/public-redact.js.map +1 -1
- package/dist/dashboard/session-presentation.d.ts +16 -0
- package/dist/dashboard/session-presentation.d.ts.map +1 -0
- package/dist/dashboard/session-presentation.js +62 -0
- package/dist/dashboard/session-presentation.js.map +1 -0
- package/dist/dashboard/settings-write-applier.d.ts +2 -1
- package/dist/dashboard/settings-write-applier.d.ts.map +1 -1
- package/dist/dashboard/settings-write-applier.js +19 -1
- package/dist/dashboard/settings-write-applier.js.map +1 -1
- package/dist/dashboard/trigger-api.d.ts.map +1 -1
- package/dist/dashboard/trigger-api.js +19 -1
- package/dist/dashboard/trigger-api.js.map +1 -1
- package/dist/dashboard/vc-consumer-profiles-api.d.ts +7 -2
- package/dist/dashboard/vc-consumer-profiles-api.d.ts.map +1 -1
- package/dist/dashboard/vc-consumer-profiles-api.js +13 -0
- package/dist/dashboard/vc-consumer-profiles-api.js.map +1 -1
- package/dist/dashboard/web/app.d.ts.map +1 -1
- package/dist/dashboard/web/app.js +18 -5
- package/dist/dashboard/web/app.js.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.d.ts +1 -1
- package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.js +97 -35
- 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/client-shell.d.ts +29 -0
- package/dist/dashboard/web/client-shell.d.ts.map +1 -0
- package/dist/dashboard/web/client-shell.js +89 -0
- package/dist/dashboard/web/client-shell.js.map +1 -0
- package/dist/dashboard/web/connectors-page.d.ts.map +1 -1
- package/dist/dashboard/web/connectors-page.js +5 -1
- package/dist/dashboard/web/connectors-page.js.map +1 -1
- package/dist/dashboard/web/i18n.d.ts.map +1 -1
- package/dist/dashboard/web/i18n.js +100 -8
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/preferences.d.ts +7 -0
- package/dist/dashboard/web/preferences.d.ts.map +1 -1
- package/dist/dashboard/web/preferences.js +32 -0
- package/dist/dashboard/web/preferences.js.map +1 -1
- package/dist/dashboard/web/sessions-kanban.d.ts +1 -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.map +1 -1
- package/dist/dashboard/web/sessions-page.js +77 -23
- package/dist/dashboard/web/sessions-page.js.map +1 -1
- package/dist/dashboard/web/sessions.d.ts +4 -0
- package/dist/dashboard/web/sessions.d.ts.map +1 -1
- package/dist/dashboard/web/sessions.js +14 -1
- package/dist/dashboard/web/sessions.js.map +1 -1
- package/dist/dashboard/web/settings-page.d.ts +6 -0
- package/dist/dashboard/web/settings-page.d.ts.map +1 -1
- package/dist/dashboard/web/settings-page.js +55 -30
- package/dist/dashboard/web/settings-page.js.map +1 -1
- package/dist/dashboard/web/store.d.ts +1 -2
- package/dist/dashboard/web/store.d.ts.map +1 -1
- package/dist/dashboard/web/store.js +69 -20
- package/dist/dashboard/web/store.js.map +1 -1
- package/dist/dashboard/web/vc-consumer-profiles-section.d.ts.map +1 -1
- package/dist/dashboard/web/vc-consumer-profiles-section.js +128 -42
- package/dist/dashboard/web/vc-consumer-profiles-section.js.map +1 -1
- package/dist/dashboard/webhook-routes.d.ts.map +1 -1
- package/dist/dashboard/webhook-routes.js +9 -2
- package/dist/dashboard/webhook-routes.js.map +1 -1
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/bot-defaults-page-VQMPUJ4Y.js +10 -0
- package/dist/dashboard-web/chunks/chunk-AGCPF6MT.js +1 -0
- package/dist/dashboard-web/chunks/{chunk-KPQAUX7V.js → chunk-JMRGZQDB.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-R7IAKAYX.js → chunk-NP4JUBGS.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-NRL6CVAS.js → chunk-P327LXOT.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-X2L65IOM.js → chunk-SNKATZWK.js} +15 -15
- package/dist/dashboard-web/chunks/connectors-page-DOY4J3ZL.js +1 -0
- package/dist/dashboard-web/chunks/{groups-page-6DKXBYOM.js → groups-page-74TS2DIH.js} +1 -1
- package/dist/dashboard-web/chunks/{insights-page-NWARTJ6J.js → insights-page-AYCO65JC.js} +1 -1
- package/dist/dashboard-web/chunks/{monitor-room-AGX3XRJX.js → monitor-room-YKYLTSAN.js} +1 -1
- package/dist/dashboard-web/chunks/{monitoring-page-GGGIWN4C.js → monitoring-page-QBIUNRBR.js} +1 -1
- package/dist/dashboard-web/chunks/{office-page-6SIVKSK3.js → office-page-4PH2A26P.js} +1 -1
- package/dist/dashboard-web/chunks/overview-page-H73D5UT4.js +1 -0
- package/dist/dashboard-web/chunks/{roles-page-WE2YB7KN.js → roles-page-U4BTOQ7F.js} +1 -1
- package/dist/dashboard-web/chunks/{schedules-page-TB3I24XN.js → schedules-page-RHRHX7R7.js} +1 -1
- package/dist/dashboard-web/chunks/sessions-page-VSC6AM5G.js +2 -0
- package/dist/dashboard-web/chunks/settings-page-LF3RKM5P.js +2 -0
- package/dist/dashboard-web/chunks/{skills-page-3QAT2IWD.js → skills-page-SYOIGGXH.js} +1 -1
- package/dist/dashboard-web/chunks/{team-federation-page-K4VVAVAK.js → team-federation-page-RMBLASTW.js} +1 -1
- package/dist/dashboard-web/chunks/{v3-page-V6IOJR2B.js → v3-page-XJXKKJRN.js} +1 -1
- package/dist/dashboard-web/chunks/{whiteboards-page-V6CGKRNX.js → whiteboards-page-K3YVSTHJ.js} +1 -1
- package/dist/dashboard-web/style.css +551 -0
- package/dist/dashboard.js +153 -9
- package/dist/dashboard.js.map +1 -1
- package/dist/global-config.d.ts +11 -0
- package/dist/global-config.d.ts.map +1 -1
- package/dist/global-config.js +23 -0
- package/dist/global-config.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +5 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +5 -0
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/card-builder.d.ts +1 -1
- package/dist/im/lark/card-builder.js +1 -1
- package/dist/im/lark/card-handler.d.ts +10 -0
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +163 -17
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/client.d.ts +11 -0
- package/dist/im/lark/client.d.ts.map +1 -1
- package/dist/im/lark/client.js +47 -18
- package/dist/im/lark/client.js.map +1 -1
- package/dist/im/lark/event-dispatcher.d.ts +13 -0
- package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
- package/dist/im/lark/event-dispatcher.js +20 -0
- package/dist/im/lark/event-dispatcher.js.map +1 -1
- package/dist/im/lark/identity-cache.d.ts +25 -1
- package/dist/im/lark/identity-cache.d.ts.map +1 -1
- package/dist/im/lark/identity-cache.js +47 -1
- package/dist/im/lark/identity-cache.js.map +1 -1
- package/dist/im/lark/overload-nonce.d.ts +19 -0
- package/dist/im/lark/overload-nonce.d.ts.map +1 -0
- package/dist/im/lark/overload-nonce.js +72 -0
- package/dist/im/lark/overload-nonce.js.map +1 -0
- package/dist/im/lark/v3-progress-card.d.ts.map +1 -1
- package/dist/im/lark/v3-progress-card.js +5 -0
- package/dist/im/lark/v3-progress-card.js.map +1 -1
- package/dist/services/async-trigger-state.d.ts +82 -0
- package/dist/services/async-trigger-state.d.ts.map +1 -0
- package/dist/services/async-trigger-state.js +95 -0
- package/dist/services/async-trigger-state.js.map +1 -0
- package/dist/services/async-trigger-store.d.ts +28 -0
- package/dist/services/async-trigger-store.d.ts.map +1 -0
- package/dist/services/async-trigger-store.js +120 -0
- package/dist/services/async-trigger-store.js.map +1 -0
- package/dist/services/bot-config-store.d.ts.map +1 -1
- package/dist/services/bot-config-store.js +34 -2
- package/dist/services/bot-config-store.js.map +1 -1
- package/dist/services/bridge-fallback-gate.d.ts +32 -0
- package/dist/services/bridge-fallback-gate.d.ts.map +1 -1
- package/dist/services/bridge-fallback-gate.js +39 -0
- package/dist/services/bridge-fallback-gate.js.map +1 -1
- package/dist/services/bridge-turn-queue.d.ts.map +1 -1
- package/dist/services/bridge-turn-queue.js +15 -1
- package/dist/services/bridge-turn-queue.js.map +1 -1
- package/dist/services/card-prefs-store.d.ts +4 -0
- package/dist/services/card-prefs-store.d.ts.map +1 -1
- package/dist/services/card-prefs-store.js +8 -0
- package/dist/services/card-prefs-store.js.map +1 -1
- package/dist/services/claude-transcript.d.ts +23 -0
- package/dist/services/claude-transcript.d.ts.map +1 -1
- package/dist/services/claude-transcript.js +33 -0
- package/dist/services/claude-transcript.js.map +1 -1
- package/dist/services/codex-app-runner-protocol.d.ts +61 -0
- package/dist/services/codex-app-runner-protocol.d.ts.map +1 -0
- package/dist/services/codex-app-runner-protocol.js +170 -0
- package/dist/services/codex-app-runner-protocol.js.map +1 -0
- package/dist/services/codex-app-turn-controller.d.ts +72 -0
- package/dist/services/codex-app-turn-controller.d.ts.map +1 -0
- package/dist/services/codex-app-turn-controller.js +524 -0
- package/dist/services/codex-app-turn-controller.js.map +1 -0
- package/dist/services/codex-runner-freshness.d.ts +39 -0
- package/dist/services/codex-runner-freshness.d.ts.map +1 -0
- package/dist/services/codex-runner-freshness.js +78 -0
- package/dist/services/codex-runner-freshness.js.map +1 -0
- package/dist/services/connector-store.d.ts +6 -0
- package/dist/services/connector-store.d.ts.map +1 -1
- package/dist/services/connector-store.js.map +1 -1
- package/dist/services/grant-store.d.ts.map +1 -1
- package/dist/services/grant-store.js +16 -0
- package/dist/services/grant-store.js.map +1 -1
- package/dist/services/hermes-transcript.d.ts +1 -0
- package/dist/services/hermes-transcript.d.ts.map +1 -1
- package/dist/services/hermes-transcript.js +49 -0
- package/dist/services/hermes-transcript.js.map +1 -1
- package/dist/services/schedule-split-migration.d.ts +2 -0
- package/dist/services/schedule-split-migration.d.ts.map +1 -0
- package/dist/services/schedule-split-migration.js +159 -0
- package/dist/services/schedule-split-migration.js.map +1 -0
- package/dist/services/schedule-store.d.ts +28 -4
- package/dist/services/schedule-store.d.ts.map +1 -1
- package/dist/services/schedule-store.js +118 -33
- package/dist/services/schedule-store.js.map +1 -1
- package/dist/services/trigger-types.d.ts +18 -1
- package/dist/services/trigger-types.d.ts.map +1 -1
- package/dist/services/trigger-types.js +3 -0
- package/dist/services/trigger-types.js.map +1 -1
- package/dist/services/vc-meeting-consumer-profile-store.d.ts.map +1 -1
- package/dist/services/vc-meeting-consumer-profile-store.js +1 -0
- package/dist/services/vc-meeting-consumer-profile-store.js.map +1 -1
- package/dist/services/vc-meeting-consumer-profile-templates.d.ts +32 -0
- package/dist/services/vc-meeting-consumer-profile-templates.d.ts.map +1 -0
- package/dist/services/vc-meeting-consumer-profile-templates.js +106 -0
- package/dist/services/vc-meeting-consumer-profile-templates.js.map +1 -0
- package/dist/services/vc-meeting-delivery-feed.d.ts +1 -1
- package/dist/services/vc-meeting-delivery-feed.d.ts.map +1 -1
- package/dist/services/vc-meeting-delivery-feed.js +2 -1
- package/dist/services/vc-meeting-delivery-feed.js.map +1 -1
- package/dist/services/vc-meeting-delivery-hub-store.d.ts +3 -1
- package/dist/services/vc-meeting-delivery-hub-store.d.ts.map +1 -1
- package/dist/services/vc-meeting-delivery-hub-store.js +11 -0
- package/dist/services/vc-meeting-delivery-hub-store.js.map +1 -1
- package/dist/services/vc-meeting-delivery-protocol.d.ts +9 -2
- package/dist/services/vc-meeting-delivery-protocol.d.ts.map +1 -1
- package/dist/services/vc-meeting-delivery-protocol.js +10 -1
- package/dist/services/vc-meeting-delivery-protocol.js.map +1 -1
- package/dist/services/vc-meeting-delivery-receiver.d.ts.map +1 -1
- package/dist/services/vc-meeting-delivery-receiver.js +10 -1
- package/dist/services/vc-meeting-delivery-receiver.js.map +1 -1
- package/dist/services/vc-meeting-delivery-store.d.ts +12 -2
- package/dist/services/vc-meeting-delivery-store.d.ts.map +1 -1
- package/dist/services/vc-meeting-delivery-store.js +14 -2
- package/dist/services/vc-meeting-delivery-store.js.map +1 -1
- package/dist/services/vc-meeting-im-reply.d.ts +2 -1
- package/dist/services/vc-meeting-im-reply.d.ts.map +1 -1
- package/dist/services/vc-meeting-im-reply.js +19 -3
- package/dist/services/vc-meeting-im-reply.js.map +1 -1
- package/dist/services/vc-meeting-listener-output-protocol.d.ts +27 -0
- package/dist/services/vc-meeting-listener-output-protocol.d.ts.map +1 -0
- package/dist/services/vc-meeting-listener-output-protocol.js +58 -0
- package/dist/services/vc-meeting-listener-output-protocol.js.map +1 -0
- package/dist/services/vc-meeting-listener-topic-store.d.ts +31 -0
- package/dist/services/vc-meeting-listener-topic-store.d.ts.map +1 -0
- package/dist/services/vc-meeting-listener-topic-store.js +120 -0
- package/dist/services/vc-meeting-listener-topic-store.js.map +1 -0
- package/dist/services/vc-meeting-runtime-store.d.ts +2 -1
- package/dist/services/vc-meeting-runtime-store.d.ts.map +1 -1
- package/dist/services/vc-meeting-runtime-store.js +8 -0
- package/dist/services/vc-meeting-runtime-store.js.map +1 -1
- package/dist/services/vc-meeting-send-policy.d.ts +8 -1
- package/dist/services/vc-meeting-send-policy.d.ts.map +1 -1
- package/dist/services/vc-meeting-send-policy.js +8 -0
- package/dist/services/vc-meeting-send-policy.js.map +1 -1
- package/dist/types.d.ts +40 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/allowed-users-apply.d.ts +76 -0
- package/dist/utils/allowed-users-apply.d.ts.map +1 -0
- package/dist/utils/allowed-users-apply.js +123 -0
- package/dist/utils/allowed-users-apply.js.map +1 -0
- package/dist/utils/allowed-users-cache.d.ts +29 -0
- package/dist/utils/allowed-users-cache.d.ts.map +1 -0
- package/dist/utils/allowed-users-cache.js +82 -0
- package/dist/utils/allowed-users-cache.js.map +1 -0
- package/dist/utils/child-env.d.ts +2 -1
- package/dist/utils/child-env.d.ts.map +1 -1
- package/dist/utils/child-env.js +2 -1
- package/dist/utils/child-env.js.map +1 -1
- package/dist/utils/cli-usage-limit.d.ts +27 -1
- package/dist/utils/cli-usage-limit.d.ts.map +1 -1
- package/dist/utils/cli-usage-limit.js +92 -20
- package/dist/utils/cli-usage-limit.js.map +1 -1
- package/dist/utils/input-gate.d.ts +2 -0
- package/dist/utils/input-gate.d.ts.map +1 -1
- package/dist/utils/input-gate.js +2 -0
- package/dist/utils/input-gate.js.map +1 -1
- package/dist/utils/runtime-build-id.d.ts +21 -0
- package/dist/utils/runtime-build-id.d.ts.map +1 -0
- package/dist/utils/runtime-build-id.js +83 -0
- package/dist/utils/runtime-build-id.js.map +1 -0
- package/dist/utils/terminal-renderer.d.ts +3 -3
- package/dist/utils/terminal-renderer.js +3 -3
- package/dist/vc-agent/cards.d.ts.map +1 -1
- package/dist/vc-agent/cards.js +21 -1
- package/dist/vc-agent/cards.js.map +1 -1
- package/dist/worker.js +601 -179
- package/dist/worker.js.map +1 -1
- package/dist/workflows/hostExecutors/botmux-schedule.d.ts.map +1 -1
- package/dist/workflows/hostExecutors/botmux-schedule.js +13 -1
- package/dist/workflows/hostExecutors/botmux-schedule.js.map +1 -1
- package/dist/workflows/migration/v2-run-archive-schema.d.ts +20 -20
- package/dist/workflows/migration/v2-to-v3.d.ts.map +1 -1
- package/dist/workflows/migration/v2-to-v3.js +5 -1
- package/dist/workflows/migration/v2-to-v3.js.map +1 -1
- package/dist/workflows/v3/architect.d.ts.map +1 -1
- package/dist/workflows/v3/architect.js +1 -0
- package/dist/workflows/v3/architect.js.map +1 -1
- package/dist/workflows/v3/cli-run.d.ts +9 -0
- package/dist/workflows/v3/cli-run.d.ts.map +1 -1
- package/dist/workflows/v3/cli-run.js +17 -2
- package/dist/workflows/v3/cli-run.js.map +1 -1
- package/dist/workflows/v3/goal-cli.d.ts +58 -0
- package/dist/workflows/v3/goal-cli.d.ts.map +1 -0
- package/dist/workflows/v3/goal-cli.js +430 -0
- package/dist/workflows/v3/goal-cli.js.map +1 -0
- package/dist/workflows/v3/library-materialize.d.ts.map +1 -1
- package/dist/workflows/v3/library-materialize.js +5 -1
- package/dist/workflows/v3/library-materialize.js.map +1 -1
- package/dist/workflows/v3/library-schema.d.ts +21 -0
- package/dist/workflows/v3/library-schema.d.ts.map +1 -1
- package/dist/workflows/v3/library-schema.js +95 -1
- package/dist/workflows/v3/library-schema.js.map +1 -1
- package/dist/workflows/v3/progress-projection.d.ts +3 -0
- package/dist/workflows/v3/progress-projection.d.ts.map +1 -1
- package/dist/workflows/v3/progress-projection.js +23 -1
- package/dist/workflows/v3/progress-projection.js.map +1 -1
- package/dist/workflows/v3/run-envelope.d.ts +46 -1
- package/dist/workflows/v3/run-envelope.d.ts.map +1 -1
- package/dist/workflows/v3/run-envelope.js +32 -1
- package/dist/workflows/v3/run-envelope.js.map +1 -1
- package/package.json +2 -2
- package/dist/dashboard-web/chunks/bot-defaults-page-AUKV7P4L.js +0 -10
- package/dist/dashboard-web/chunks/chunk-SZOB6VK2.js +0 -1
- package/dist/dashboard-web/chunks/connectors-page-HDQFEXZI.js +0 -1
- package/dist/dashboard-web/chunks/overview-page-FVR3NKAF.js +0 -1
- package/dist/dashboard-web/chunks/sessions-page-KOOOASIL.js +0 -2
- package/dist/dashboard-web/chunks/settings-page-IEBR7TGN.js +0 -2
- package/dist/utils/screen-analyzer.d.ts +0 -75
- package/dist/utils/screen-analyzer.d.ts.map +0 -1
- package/dist/utils/screen-analyzer.js +0 -333
- package/dist/utils/screen-analyzer.js.map +0 -1
package/dist/dashboard-web/chunks/{monitoring-page-GGGIWN4C.js → monitoring-page-QBIUNRBR.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as k}from"./chunk-KPQAUX7V.js";import{c as G,d as f,i as _,l as H,m as T,n as D,o as A}from"./chunk-QFMH6ITB.js";import"./chunk-X2L65IOM.js";import{a as U}from"./chunk-SYC6D5XU.js";import{a as Y,d as K}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var g=$(Y(),1);var e=$(K(),1);function b(n){let s=Number(n);return!Number.isFinite(s)||s<=0?"-":s>=1024**3?`${(s/1024**3).toFixed(1)} GiB`:s>=1024**2?`${(s/1024**2).toFixed(0)} MiB`:`${Math.max(1,Math.round(s/1024))} KiB`}function N(n){let s=Number(n);return Number.isFinite(s)?`${s.toFixed(1)}%`:"-"}function S(n,s){return s?N(n):"-"}function q(n){return n?.cpuReady!==!1}function d(n){let s=Number(n);return Number.isFinite(s)?String(s):"-"}function E(n){let s=Number(n);if(!Number.isFinite(s)||s<0)return"-";if(s===0)return"0s";if(s<6e4)return`${Math.max(1,Math.floor(s/1e3))}s`;let r=Math.floor(s/6e4);if(r<60)return`${Math.max(1,r)}m`;let t=Math.floor(r/60),o=r%60;return o?`${t}h ${o}m`:`${t}h`}function Z(n){return n==="fresh"||n==="stale"||n==="unsupported"?n:"unknown"}function j(n){return n?`${n.botName||"-"} \xB7 ${n.title||n.sessionId}`:"-"}function W(n,s){return s==="cpu"?Number(n.current?.cpu1mPct??n.current?.cpuPct??0):s==="rss"?Number(n.current?.rssBytes??0):s==="growth"?Number(n.current?.rssGrowth5mBytes??0):s==="bot"?n.botName??"":n.status??""}function ee(n,s){return[...n].sort((r,t)=>{let o=W(r,s),u=W(t,s);return typeof o=="number"&&typeof u=="number"?u-o||r.sessionId.localeCompare(t.sessionId):String(o).localeCompare(String(u))||r.sessionId.localeCompare(t.sessionId)})}function V(n,s){return s==="bytes"?b(n):N(n)}function F(n,s,r){let t=(n??[]).filter(Number.isFinite);if(t.length<2)return r("monitoring.chartNoData");let o=t[0],u=Number.isFinite(s)?Number(s):Date.now(),a=Math.max(0,u-o),m=Math.max(1,Math.round(a/6e4));if(m<60)return r("monitoring.chartMinutesAgo",{value:m});let p=Math.round(m/60);return p<48?r("monitoring.chartHoursAgo",{value:p}):r("monitoring.chartDaysAgo",{value:Math.round(p/24)})}function C(n){let s=(n??[]).filter(Number.isFinite);return s.length?s[s.length-1]:void 0}function R({values:n,timestamps:s,unit:r="pct",startLabel:t,endLabel:o,emptyLabel:u,className:a}){let m=(n??[]).filter(Number.isFinite),p=m.length?Math.min(...m):0,x=m.length?Math.max(...m):0,w=x-p,c=m.length>1?m.map((L,i)=>{let l=i/(m.length-1)*100,h=w>0?100-(L-p)/w*100:50;return`${l},${h}`}).join(" "):"",P=c?`0,100 ${c} 100,100`:"",B=c?c.split(" "):[],v=B.length?B[B.length-1].split(",").map(Number):null;return(0,e.jsxs)("div",{className:["resource-chart",a].filter(Boolean).join(" "),children:[(0,e.jsxs)("div",{className:"resource-chart-y","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length?V(x,r):"-"}),(0,e.jsx)("span",{children:m.length?V(p,r):"-"})]}),(0,e.jsxs)("div",{className:"resource-chart-plot",children:[(0,e.jsxs)("div",{className:"resource-spark-wrap",children:[(0,e.jsxs)("svg",{className:"resource-spark",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-label":m.length>1?void 0:u,children:[(0,e.jsx)("line",{x1:"0",y1:"12",x2:"100",y2:"12",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"50",x2:"100",y2:"50",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"88",x2:"100",y2:"88",className:"resource-grid-line"}),P?(0,e.jsx)("polygon",{className:"resource-spark-area",points:P}):null,c?(0,e.jsx)("polyline",{points:c}):null]}),v&&Number.isFinite(v[0])&&Number.isFinite(v[1])?(0,e.jsx)("span",{className:"resource-spark-dot","aria-hidden":"true",style:{left:`${v[0]}%`,top:`${v[1]}%`}}):null]}),(0,e.jsxs)("div",{className:"resource-chart-x","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length>1?t:u}),(0,e.jsx)("span",{children:m.length>1?o:""})]})]})]})}function I(n){let s=r=>r instanceof Element&&!!r.closest(".ui-info-tip");return(0,e.jsx)("section",{className:"metric-card","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:r=>{s(r.target)||n.onOpen()},onKeyDown:r=>{s(r.target)||r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),n.onOpen())},children:n.children})}function M(n){return(0,e.jsx)("article",{className:"resource-trend-cell","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:n.onOpen,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),n.onOpen())},children:n.children})}function te(n){let s=k(),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let t=r.current;if(t)if(n.detail){if(!t.open)try{t.showModal()}catch{}}else t.open&&t.close()},[n.detail]),(0,g.useEffect)(()=>()=>{let t=r.current;t?.open&&t.close()},[]),(0,e.jsx)("dialog",{ref:r,className:"resource-detail-modal",onCancel:t=>{t.preventDefault(),n.onClose()},onClose:n.onClose,onClick:t=>{t.target===t.currentTarget&&n.onClose()},children:n.detail?(0,e.jsxs)("article",{className:"resource-detail-modal-card",children:[(0,e.jsxs)("header",{className:"resource-detail-modal-head",children:[(0,e.jsx)("h3",{children:n.detail.title}),(0,e.jsx)("button",{type:"button",className:"resource-detail-modal-close","aria-label":s("monitoring.modalClose"),title:s("monitoring.modalClose"),onClick:n.onClose})]}),(0,e.jsxs)("div",{className:"resource-detail-modal-body",children:[(0,e.jsxs)("section",{className:"resource-detail-summary",children:[(0,e.jsx)("strong",{children:n.detail.value}),(0,e.jsx)("p",{children:n.detail.detail})]}),n.detail.chart?(0,e.jsx)(R,{className:"resource-detail-chart",values:n.detail.chart.values,timestamps:n.detail.chart.timestamps,unit:n.detail.chart.unit,startLabel:n.detail.chart.startLabel,endLabel:n.detail.chart.endLabel,emptyLabel:n.detail.chart.emptyLabel}):(0,e.jsx)("p",{className:"resource-detail-empty",children:n.detail.emptyText})]})]}):null})}function ne({reasons:n}){return(0,e.jsx)("span",{className:"resource-reasons",children:(n??[]).join(", ")||"-"})}function y({label:n,value:s,tone:r}){return(0,e.jsxs)("span",{className:`resource-pill${r?` ${r}`:""}`,children:[(0,e.jsx)("span",{children:n}),(0,e.jsx)("b",{children:s})]})}function se({bots:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list",children:n.length?n.map(t=>{let o=t.runtime?.sessions,u=t.runtime?.daemonStatus??t.daemonStatus??"unknown",a=u==="online"?"ok":u==="offline"?"off":"warn";return(0,e.jsxs)(T,{className:"resource-list-item resource-bot-item",children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.botName,children:t.botName}),(0,e.jsxs)("span",{children:[r("monitoring.sessionsCount")," ",d(o?.total??t.sessions?.count)]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.daemon"),value:u,tone:a}),(0,e.jsx)(y,{label:r("monitoring.working"),value:d(o?.working),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.starting"),value:d(o?.starting)}),(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.total?.cpuPct,s)}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.total?.rssBytes)})]})})]},t.larkAppId)}):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function re({sessions:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell resource-session-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list resource-session-list",children:n.length?n.map(t=>(0,e.jsxs)(T,{className:`resource-list-item resource-session-item${t.tracked?" is-tracked":""}`,children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.title||t.sessionId,children:t.title||t.sessionId}),(0,e.jsxs)("span",{title:t.sessionId,children:[t.botName," \xB7 ",t.sessionId]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.current?.cpu1mPct??t.current?.cpuPct,s),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.current?.rssBytes)}),(0,e.jsx)(y,{label:r("monitoring.growth"),value:b(t.current?.rssGrowth5mBytes)}),(0,e.jsx)(y,{label:r("monitoring.confidence"),value:t.confidence??"unknown",tone:t.tracked?"ok":void 0}),(0,e.jsxs)("span",{className:"resource-pill resource-rank-pill",children:[(0,e.jsx)("span",{children:r("monitoring.rank")}),(0,e.jsx)(ne,{reasons:t.rankReasons})]})]})})]},t.sessionId)):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function oe({current:n}){let s=k(),r=n.runtime,t=q(n),o=Z(r?.sampleHealth?.status),u=r?.daemons?.total,a=r?.daemons?.online,m=r?.daemons?.offline??(Number.isFinite(Number(u))&&Number.isFinite(Number(a))?Math.max(0,Number(u)-Number(a)):void 0),p=r?.sessions?.total,x=r?.sessions?.working,w=r?.sessions?.starting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.runtimeHealth")}),(0,e.jsx)("section",{className:"panel runtime-health-panel",children:(0,e.jsxs)("div",{className:"runtime-health-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sampleHealth")}),(0,e.jsx)("strong",{children:(0,e.jsx)("span",{className:`runtime-status-pill ${o}`,children:s(`monitoring.sample.${o}`)})}),(0,e.jsxs)("small",{children:[s("monitoring.sampleAge")," ",E(r?.sampleHealth?.ageMs)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.daemonHealth")}),(0,e.jsxs)("strong",{children:[d(a),"/",d(u)]}),(0,e.jsxs)("small",{children:[d(m)," ",s("monitoring.offline")]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sessionHealth")}),(0,e.jsx)("strong",{children:d(p)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(x)," \xB7 ",s("monitoring.starting")," ",d(w)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.resourcePressure")}),(0,e.jsx)("strong",{children:S(n.host?.cpuPct,t)}),(0,e.jsxs)("small",{children:[s("monitoring.hostMemory")," ",N(n.host?.memUsedPct)," \xB7 RSS ",b(n.botmux?.rssBytes)]})]})]})})]})}function ae({runtime:n}){let s=k(),r=n?.sessions,t=r?.longestRunning,o=r?.longestWaiting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.sessionPressure")}),(0,e.jsx)("section",{className:"panel runtime-session-pressure",children:(0,e.jsxs)("div",{className:"runtime-session-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.statusDistribution")}),(0,e.jsx)("strong",{children:d(r?.total)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(r?.working)," \xB7 ",s("monitoring.starting")," ",d(r?.starting)," \xB7 ",s("monitoring.waiting")," ",d(r?.waiting)," \xB7 ",s("monitoring.idle")," ",d(r?.idle)," \xB7 ",s("monitoring.unknown")," ",d(r?.unknown)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestRunning")}),(0,e.jsx)("strong",{children:j(t)}),(0,e.jsx)("small",{children:E(t?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestWaiting")}),(0,e.jsx)("strong",{children:j(o)}),(0,e.jsx)("small",{children:E(o?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.unattributedSessions")}),(0,e.jsx)("strong",{children:d(r?.unattributed)}),(0,e.jsx)("small",{children:s("monitoring.unattributedHint")})]})]})})]})}function ie({initialCurrent:n=null,initialHistory:s=null,poll:r=!0}={}){let t=k(),[o,u]=(0,g.useState)(n),[a,m]=(0,g.useState)(s),[p,x]=(0,g.useState)("cpu"),[w,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!r)return;let l=!1;async function h(){try{let[z,J]=await Promise.all([fetch("/api/resources/current",{cache:"no-store"}),fetch("/api/resources/history?range=3h",{cache:"no-store"})]),[Q,X]=await Promise.all([z.json(),J.json()]);l||(u(Q),m(X))}catch{l||(u({supported:!1,reason:"fetch_failed",bots:[],sessions:[]}),m({supported:!1,bots:[],sessions:[]}))}}h();let O=window.setInterval(()=>{h()},1e4);return()=>{l=!0,window.clearInterval(O)}},[r]);let P=o!==null&&a!==null,B=(0,g.useMemo)(()=>ee(o?.sessions??[],p),[o?.sessions,p]),v=o?.supported!==!1,L=q(o),i={hostStartLabel:F(a?.host?.timestamps,o?.sampledAt,t),botmuxStartLabel:F(a?.botmux?.timestamps,o?.sampledAt,t),endLabel:t("monitoring.chartNow"),emptyLabel:t("monitoring.chartNoData")};return(0,e.jsxs)("section",{className:"page resource-page",children:[(0,e.jsx)("div",{className:"page-heading",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("monitoring.eyebrow")}),(0,e.jsx)("h1",{children:t("monitoring.runtimeTitle")})]})}),P?null:(0,e.jsx)(G,{label:t("common.loading")}),P?(0,e.jsxs)(e.Fragment,{children:[o?(0,e.jsx)(oe,{current:o}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block resource-pressure-block",children:[(0,e.jsx)(f,{title:t("monitoring.resourcePressure")}),(0,e.jsx)("section",{className:"panel resource-pressure",children:(0,e.jsxs)("div",{className:"resource-metrics runtime-pressure-grid",children:[(0,e.jsxs)(I,{label:t("monitoring.hostCpu"),onOpen:()=>c({title:t("monitoring.hostCpu"),value:S(o?.host?.cpuPct,L),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostCpu")}),(0,e.jsx)("strong",{children:S(o?.host?.cpuPct,L)}),(0,e.jsxs)("small",{children:["load ",Number(o?.host?.load1??0).toFixed(2)]})]}),(0,e.jsxs)(I,{label:t("monitoring.hostMemory"),onOpen:()=>c({title:t("monitoring.hostMemory"),value:N(o?.host?.memUsedPct),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostMemory")}),(0,e.jsx)("strong",{children:N(o?.host?.memUsedPct)}),(0,e.jsx)("small",{children:t("monitoring.memoryOnly")})]}),(0,e.jsxs)(I,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(o?.botmux?.rssBytes),detail:o?.botmuxBreakdown?`${t("monitoring.botmuxSelf")} ${b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0))}
|
|
1
|
+
import{c as k}from"./chunk-JMRGZQDB.js";import{c as G,d as f,i as _,l as H,m as T,n as D,o as A}from"./chunk-QFMH6ITB.js";import"./chunk-SNKATZWK.js";import{a as U}from"./chunk-SYC6D5XU.js";import{a as Y,d as K}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var g=$(Y(),1);var e=$(K(),1);function b(n){let s=Number(n);return!Number.isFinite(s)||s<=0?"-":s>=1024**3?`${(s/1024**3).toFixed(1)} GiB`:s>=1024**2?`${(s/1024**2).toFixed(0)} MiB`:`${Math.max(1,Math.round(s/1024))} KiB`}function N(n){let s=Number(n);return Number.isFinite(s)?`${s.toFixed(1)}%`:"-"}function S(n,s){return s?N(n):"-"}function q(n){return n?.cpuReady!==!1}function d(n){let s=Number(n);return Number.isFinite(s)?String(s):"-"}function E(n){let s=Number(n);if(!Number.isFinite(s)||s<0)return"-";if(s===0)return"0s";if(s<6e4)return`${Math.max(1,Math.floor(s/1e3))}s`;let r=Math.floor(s/6e4);if(r<60)return`${Math.max(1,r)}m`;let t=Math.floor(r/60),o=r%60;return o?`${t}h ${o}m`:`${t}h`}function Z(n){return n==="fresh"||n==="stale"||n==="unsupported"?n:"unknown"}function j(n){return n?`${n.botName||"-"} \xB7 ${n.title||n.sessionId}`:"-"}function W(n,s){return s==="cpu"?Number(n.current?.cpu1mPct??n.current?.cpuPct??0):s==="rss"?Number(n.current?.rssBytes??0):s==="growth"?Number(n.current?.rssGrowth5mBytes??0):s==="bot"?n.botName??"":n.status??""}function ee(n,s){return[...n].sort((r,t)=>{let o=W(r,s),u=W(t,s);return typeof o=="number"&&typeof u=="number"?u-o||r.sessionId.localeCompare(t.sessionId):String(o).localeCompare(String(u))||r.sessionId.localeCompare(t.sessionId)})}function V(n,s){return s==="bytes"?b(n):N(n)}function F(n,s,r){let t=(n??[]).filter(Number.isFinite);if(t.length<2)return r("monitoring.chartNoData");let o=t[0],u=Number.isFinite(s)?Number(s):Date.now(),a=Math.max(0,u-o),m=Math.max(1,Math.round(a/6e4));if(m<60)return r("monitoring.chartMinutesAgo",{value:m});let p=Math.round(m/60);return p<48?r("monitoring.chartHoursAgo",{value:p}):r("monitoring.chartDaysAgo",{value:Math.round(p/24)})}function C(n){let s=(n??[]).filter(Number.isFinite);return s.length?s[s.length-1]:void 0}function R({values:n,timestamps:s,unit:r="pct",startLabel:t,endLabel:o,emptyLabel:u,className:a}){let m=(n??[]).filter(Number.isFinite),p=m.length?Math.min(...m):0,x=m.length?Math.max(...m):0,w=x-p,c=m.length>1?m.map((L,i)=>{let l=i/(m.length-1)*100,h=w>0?100-(L-p)/w*100:50;return`${l},${h}`}).join(" "):"",P=c?`0,100 ${c} 100,100`:"",B=c?c.split(" "):[],v=B.length?B[B.length-1].split(",").map(Number):null;return(0,e.jsxs)("div",{className:["resource-chart",a].filter(Boolean).join(" "),children:[(0,e.jsxs)("div",{className:"resource-chart-y","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length?V(x,r):"-"}),(0,e.jsx)("span",{children:m.length?V(p,r):"-"})]}),(0,e.jsxs)("div",{className:"resource-chart-plot",children:[(0,e.jsxs)("div",{className:"resource-spark-wrap",children:[(0,e.jsxs)("svg",{className:"resource-spark",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-label":m.length>1?void 0:u,children:[(0,e.jsx)("line",{x1:"0",y1:"12",x2:"100",y2:"12",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"50",x2:"100",y2:"50",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"88",x2:"100",y2:"88",className:"resource-grid-line"}),P?(0,e.jsx)("polygon",{className:"resource-spark-area",points:P}):null,c?(0,e.jsx)("polyline",{points:c}):null]}),v&&Number.isFinite(v[0])&&Number.isFinite(v[1])?(0,e.jsx)("span",{className:"resource-spark-dot","aria-hidden":"true",style:{left:`${v[0]}%`,top:`${v[1]}%`}}):null]}),(0,e.jsxs)("div",{className:"resource-chart-x","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length>1?t:u}),(0,e.jsx)("span",{children:m.length>1?o:""})]})]})]})}function I(n){let s=r=>r instanceof Element&&!!r.closest(".ui-info-tip");return(0,e.jsx)("section",{className:"metric-card","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:r=>{s(r.target)||n.onOpen()},onKeyDown:r=>{s(r.target)||r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),n.onOpen())},children:n.children})}function M(n){return(0,e.jsx)("article",{className:"resource-trend-cell","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:n.onOpen,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),n.onOpen())},children:n.children})}function te(n){let s=k(),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let t=r.current;if(t)if(n.detail){if(!t.open)try{t.showModal()}catch{}}else t.open&&t.close()},[n.detail]),(0,g.useEffect)(()=>()=>{let t=r.current;t?.open&&t.close()},[]),(0,e.jsx)("dialog",{ref:r,className:"resource-detail-modal",onCancel:t=>{t.preventDefault(),n.onClose()},onClose:n.onClose,onClick:t=>{t.target===t.currentTarget&&n.onClose()},children:n.detail?(0,e.jsxs)("article",{className:"resource-detail-modal-card",children:[(0,e.jsxs)("header",{className:"resource-detail-modal-head",children:[(0,e.jsx)("h3",{children:n.detail.title}),(0,e.jsx)("button",{type:"button",className:"resource-detail-modal-close","aria-label":s("monitoring.modalClose"),title:s("monitoring.modalClose"),onClick:n.onClose})]}),(0,e.jsxs)("div",{className:"resource-detail-modal-body",children:[(0,e.jsxs)("section",{className:"resource-detail-summary",children:[(0,e.jsx)("strong",{children:n.detail.value}),(0,e.jsx)("p",{children:n.detail.detail})]}),n.detail.chart?(0,e.jsx)(R,{className:"resource-detail-chart",values:n.detail.chart.values,timestamps:n.detail.chart.timestamps,unit:n.detail.chart.unit,startLabel:n.detail.chart.startLabel,endLabel:n.detail.chart.endLabel,emptyLabel:n.detail.chart.emptyLabel}):(0,e.jsx)("p",{className:"resource-detail-empty",children:n.detail.emptyText})]})]}):null})}function ne({reasons:n}){return(0,e.jsx)("span",{className:"resource-reasons",children:(n??[]).join(", ")||"-"})}function y({label:n,value:s,tone:r}){return(0,e.jsxs)("span",{className:`resource-pill${r?` ${r}`:""}`,children:[(0,e.jsx)("span",{children:n}),(0,e.jsx)("b",{children:s})]})}function se({bots:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list",children:n.length?n.map(t=>{let o=t.runtime?.sessions,u=t.runtime?.daemonStatus??t.daemonStatus??"unknown",a=u==="online"?"ok":u==="offline"?"off":"warn";return(0,e.jsxs)(T,{className:"resource-list-item resource-bot-item",children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.botName,children:t.botName}),(0,e.jsxs)("span",{children:[r("monitoring.sessionsCount")," ",d(o?.total??t.sessions?.count)]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.daemon"),value:u,tone:a}),(0,e.jsx)(y,{label:r("monitoring.working"),value:d(o?.working),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.starting"),value:d(o?.starting)}),(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.total?.cpuPct,s)}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.total?.rssBytes)})]})})]},t.larkAppId)}):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function re({sessions:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell resource-session-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list resource-session-list",children:n.length?n.map(t=>(0,e.jsxs)(T,{className:`resource-list-item resource-session-item${t.tracked?" is-tracked":""}`,children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.title||t.sessionId,children:t.title||t.sessionId}),(0,e.jsxs)("span",{title:t.sessionId,children:[t.botName," \xB7 ",t.sessionId]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.current?.cpu1mPct??t.current?.cpuPct,s),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.current?.rssBytes)}),(0,e.jsx)(y,{label:r("monitoring.growth"),value:b(t.current?.rssGrowth5mBytes)}),(0,e.jsx)(y,{label:r("monitoring.confidence"),value:t.confidence??"unknown",tone:t.tracked?"ok":void 0}),(0,e.jsxs)("span",{className:"resource-pill resource-rank-pill",children:[(0,e.jsx)("span",{children:r("monitoring.rank")}),(0,e.jsx)(ne,{reasons:t.rankReasons})]})]})})]},t.sessionId)):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function oe({current:n}){let s=k(),r=n.runtime,t=q(n),o=Z(r?.sampleHealth?.status),u=r?.daemons?.total,a=r?.daemons?.online,m=r?.daemons?.offline??(Number.isFinite(Number(u))&&Number.isFinite(Number(a))?Math.max(0,Number(u)-Number(a)):void 0),p=r?.sessions?.total,x=r?.sessions?.working,w=r?.sessions?.starting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.runtimeHealth")}),(0,e.jsx)("section",{className:"panel runtime-health-panel",children:(0,e.jsxs)("div",{className:"runtime-health-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sampleHealth")}),(0,e.jsx)("strong",{children:(0,e.jsx)("span",{className:`runtime-status-pill ${o}`,children:s(`monitoring.sample.${o}`)})}),(0,e.jsxs)("small",{children:[s("monitoring.sampleAge")," ",E(r?.sampleHealth?.ageMs)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.daemonHealth")}),(0,e.jsxs)("strong",{children:[d(a),"/",d(u)]}),(0,e.jsxs)("small",{children:[d(m)," ",s("monitoring.offline")]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sessionHealth")}),(0,e.jsx)("strong",{children:d(p)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(x)," \xB7 ",s("monitoring.starting")," ",d(w)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.resourcePressure")}),(0,e.jsx)("strong",{children:S(n.host?.cpuPct,t)}),(0,e.jsxs)("small",{children:[s("monitoring.hostMemory")," ",N(n.host?.memUsedPct)," \xB7 RSS ",b(n.botmux?.rssBytes)]})]})]})})]})}function ae({runtime:n}){let s=k(),r=n?.sessions,t=r?.longestRunning,o=r?.longestWaiting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.sessionPressure")}),(0,e.jsx)("section",{className:"panel runtime-session-pressure",children:(0,e.jsxs)("div",{className:"runtime-session-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.statusDistribution")}),(0,e.jsx)("strong",{children:d(r?.total)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(r?.working)," \xB7 ",s("monitoring.starting")," ",d(r?.starting)," \xB7 ",s("monitoring.waiting")," ",d(r?.waiting)," \xB7 ",s("monitoring.idle")," ",d(r?.idle)," \xB7 ",s("monitoring.unknown")," ",d(r?.unknown)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestRunning")}),(0,e.jsx)("strong",{children:j(t)}),(0,e.jsx)("small",{children:E(t?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestWaiting")}),(0,e.jsx)("strong",{children:j(o)}),(0,e.jsx)("small",{children:E(o?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.unattributedSessions")}),(0,e.jsx)("strong",{children:d(r?.unattributed)}),(0,e.jsx)("small",{children:s("monitoring.unattributedHint")})]})]})})]})}function ie({initialCurrent:n=null,initialHistory:s=null,poll:r=!0}={}){let t=k(),[o,u]=(0,g.useState)(n),[a,m]=(0,g.useState)(s),[p,x]=(0,g.useState)("cpu"),[w,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!r)return;let l=!1;async function h(){try{let[z,J]=await Promise.all([fetch("/api/resources/current",{cache:"no-store"}),fetch("/api/resources/history?range=3h",{cache:"no-store"})]),[Q,X]=await Promise.all([z.json(),J.json()]);l||(u(Q),m(X))}catch{l||(u({supported:!1,reason:"fetch_failed",bots:[],sessions:[]}),m({supported:!1,bots:[],sessions:[]}))}}h();let O=window.setInterval(()=>{h()},1e4);return()=>{l=!0,window.clearInterval(O)}},[r]);let P=o!==null&&a!==null,B=(0,g.useMemo)(()=>ee(o?.sessions??[],p),[o?.sessions,p]),v=o?.supported!==!1,L=q(o),i={hostStartLabel:F(a?.host?.timestamps,o?.sampledAt,t),botmuxStartLabel:F(a?.botmux?.timestamps,o?.sampledAt,t),endLabel:t("monitoring.chartNow"),emptyLabel:t("monitoring.chartNoData")};return(0,e.jsxs)("section",{className:"page resource-page",children:[(0,e.jsx)("div",{className:"page-heading",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("monitoring.eyebrow")}),(0,e.jsx)("h1",{children:t("monitoring.runtimeTitle")})]})}),P?null:(0,e.jsx)(G,{label:t("common.loading")}),P?(0,e.jsxs)(e.Fragment,{children:[o?(0,e.jsx)(oe,{current:o}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block resource-pressure-block",children:[(0,e.jsx)(f,{title:t("monitoring.resourcePressure")}),(0,e.jsx)("section",{className:"panel resource-pressure",children:(0,e.jsxs)("div",{className:"resource-metrics runtime-pressure-grid",children:[(0,e.jsxs)(I,{label:t("monitoring.hostCpu"),onOpen:()=>c({title:t("monitoring.hostCpu"),value:S(o?.host?.cpuPct,L),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostCpu")}),(0,e.jsx)("strong",{children:S(o?.host?.cpuPct,L)}),(0,e.jsxs)("small",{children:["load ",Number(o?.host?.load1??0).toFixed(2)]})]}),(0,e.jsxs)(I,{label:t("monitoring.hostMemory"),onOpen:()=>c({title:t("monitoring.hostMemory"),value:N(o?.host?.memUsedPct),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostMemory")}),(0,e.jsx)("strong",{children:N(o?.host?.memUsedPct)}),(0,e.jsx)("small",{children:t("monitoring.memoryOnly")})]}),(0,e.jsxs)(I,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(o?.botmux?.rssBytes),detail:o?.botmuxBreakdown?`${t("monitoring.botmuxSelf")} ${b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0))}
|
|
2
2
|
${t("monitoring.botmuxCli")} ${b(o.botmuxBreakdown.cli.rssBytes)}`:S(o?.botmux?.cpuPct,L),chart:{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsxs)("div",{className:"metric-label-with-help",children:[(0,e.jsx)("span",{children:t("monitoring.botmuxRss")}),(0,e.jsx)(_,{label:t("monitoring.rssHelpLabel"),children:t("monitoring.rssHelp")})]}),(0,e.jsx)("strong",{children:b(o?.botmux?.rssBytes)}),o?.botmuxBreakdown&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("small",{className:"metric-breakdown",children:[t("monitoring.botmuxSelf")," ",b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0)),(0,e.jsxs)("span",{className:"metric-breakdown-detail",children:[" (",t("monitoring.botmuxDaemon")," ",b(o.botmuxBreakdown.daemon.rssBytes)," \xB7 ",t("monitoring.botmuxWorker")," ",b(o.botmuxBreakdown.worker.rssBytes),")"]})]}),(0,e.jsxs)("small",{className:"metric-breakdown",children:[t("monitoring.botmuxCli")," ",b(o.botmuxBreakdown.cli.rssBytes)]})]})]}),(0,e.jsxs)(I,{label:t("monitoring.trackedSessions"),onOpen:()=>c({title:t("monitoring.trackedSessions"),value:d(o?.rankings?.tracked?.length),detail:`${t("monitoring.currentSessions")} ${(o?.sessions??[]).length}`,emptyText:t("monitoring.trackedSessionHint")}),children:[(0,e.jsx)("span",{children:t("monitoring.trackedSessions")}),(0,e.jsx)("strong",{children:o?.rankings?.tracked?.length??0}),(0,e.jsxs)("small",{children:[t("monitoring.currentSessions")," ",(o?.sessions??[]).length]})]})]})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.trends")}),(0,e.jsx)("section",{className:"panel resource-trends",children:(0,e.jsxs)("div",{className:"resource-trend-grid",children:[(0,e.jsxs)(M,{label:t("monitoring.trendHostCpu"),onOpen:()=>c({title:t("monitoring.trendHostCpu"),value:N(C(a?.host?.cpuPct)),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendHostCpu")}),(0,e.jsx)(R,{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.trendHostMemory"),onOpen:()=>c({title:t("monitoring.trendHostMemory"),value:N(C(a?.host?.memUsedPct)),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendHostMemory")}),(0,e.jsx)(R,{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.trendBotmuxCpu"),onOpen:()=>c({title:t("monitoring.trendBotmuxCpu"),value:N(C(a?.botmux?.cpuPct)),detail:t("monitoring.botRuntime"),chart:{values:a?.botmux?.cpuPct,timestamps:a?.botmux?.timestamps,unit:"pct",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendBotmuxCpu")}),(0,e.jsx)(R,{values:a?.botmux?.cpuPct,timestamps:a?.botmux?.timestamps,unit:"pct",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(C(a?.botmux?.rssBytes)),detail:t("monitoring.memoryOnly"),chart:{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.botmuxRss")}),(0,e.jsx)(R,{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]})]})})]})]}):(0,e.jsx)("section",{className:"panel resource-unavailable",children:(0,e.jsxs)("div",{className:"resource-unavailable-card",children:[(0,e.jsx)("span",{className:"resource-unavailable-status","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"resource-unavailable-copy",children:[(0,e.jsx)("span",{children:t("monitoring.unsupportedKicker")}),(0,e.jsx)("h2",{children:t("monitoring.unsupportedTitle")}),(0,e.jsx)("p",{children:t("monitoring.unsupportedHint")})]}),(0,e.jsxs)("div",{className:"resource-unavailable-tags","aria-label":t("monitoring.unsupported"),children:[(0,e.jsx)("span",{children:t("monitoring.unsupportedRuntimeOk")}),(0,e.jsx)("span",{children:t("monitoring.unsupportedResourceOnly")})]})]})}),o?(0,e.jsx)(ae,{runtime:o.runtime}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.botRuntime")}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsx)(se,{bots:o?.bots??[],cpuReady:L})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.sessions"),children:(0,e.jsx)("div",{className:"resource-sortbar resource-sortbar-inline dashboard-toolbar",role:"group","aria-label":t("monitoring.sort"),children:(0,e.jsx)("div",{className:"segmented resource-sort-switch",children:["cpu","rss","growth","bot","status"].map(l=>(0,e.jsx)("button",{type:"button",className:p===l?"active":void 0,"aria-pressed":p===l,onClick:()=>x(l),children:t(`monitoring.sort.${l}`)},l))})})}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsx)(re,{sessions:B,cpuReady:L})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.trackedSessionTrends")}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsxs)("div",{className:"resource-trend-grid",children:[(a?.sessions??[]).map(l=>{let h=`${l.botName} \xB7 ${l.title||l.sessionId}`,O=F(l.series?.timestamps,o?.sampledAt,t);return(0,e.jsxs)(M,{label:h,onOpen:()=>c({title:h,value:b(C(l.series?.rssBytes)),detail:l.sessionId,chart:{values:l.series?.rssBytes,timestamps:l.series?.timestamps,unit:"bytes",startLabel:O,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{title:h,children:h}),(0,e.jsx)(R,{values:l.series?.rssBytes,timestamps:l.series?.timestamps,unit:"bytes",startLabel:O,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]},l.sessionId)}),(a?.sessions??[]).length?null:(0,e.jsx)("div",{className:"empty",children:t("monitoring.noTrackedHistory")})]})})]})]}):null]}):null,(0,e.jsx)(te,{detail:w,onClose:()=>c(null)})]})}function ce(n){return U(n,(0,e.jsx)(ie,{}))}export{ie as MonitoringPage,re as SessionResourceTable,ce as renderMonitoringPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as w}from"./chunk-JMRGZQDB.js";import"./chunk-SNKATZWK.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Q,b as j}from"./chunk-NP4JUBGS.js";import{a as J,c as A}from"./chunk-JMRGZQDB.js";import{b as H,d as M,e as T,f as O,j as W,l as x,m as I,n as P,o as X,q as G}from"./chunk-QFMH6ITB.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-SNKATZWK.js";import{a as V}from"./chunk-SYC6D5XU.js";import{a as ae,d as K}from"./chunk-5THX4DI2.js";import{c as R}from"./chunk-7SZRL6FY.js";var r=R(ae(),1);var t=R(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 de(e){try{window.localStorage.setItem(ee,e?"1":"0")}catch{}}function me(e){return e==="attention"?"attention":"time"}function ue(){try{return me(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 m=f(i)?0:1,l=f(a)?0:1;if(m!==l)return m-l;if(m===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,m=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:m})}),(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,m]=(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,d=()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let w=Se(s.current);g(c=>c===w?c:w)})};d();let u=typeof ResizeObserver>"u"||!s.current?null:new ResizeObserver(d);return u&&s.current&&u.observe(s.current),window.addEventListener("resize",d),()=>{window.cancelAnimationFrame(n),u?.disconnect(),window.removeEventListener("resize",d)}},[]),(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]),E=(0,r.useMemo)(()=>B.filter(n=>n.nextRunAt).sort((n,d)=>Date.parse(n.nextRunAt)-Date.parse(d.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 d=0,u=()=>{window.cancelAnimationFrame(d),d=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(d),w?.disconnect(),window.removeEventListener("resize",u);for(let c of n)c.el.style.removeProperty(c.propertyName)}},[a,v,b.length,E.length]);let se=()=>{m(n=>(de(!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:E.length?E.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 Oe,b as He,c as Ve,d as _e}from"./chunk-R3FXBFQH.js";import{b as Ue}from"./chunk-KPQAUX7V.js";import{b as Fe,c as ne,h as le,p as se}from"./chunk-QFMH6ITB.js";import{A as $e,w as je}from"./chunk-X2L65IOM.js";import{a as re}from"./chunk-SYC6D5XU.js";import{a as Jt,d as De}from"./chunk-5THX4DI2.js";import{c as oe}from"./chunk-7SZRL6FY.js";var l=oe(Jt(),1);var w=32768,Je=Math.floor(w*.95),Kt=/^[A-Za-z0-9._-]{1,64}$/;function ae(n){return Kt.test(n)&&n!=="."&&n!==".."}function Ke(n=location.hash){let[,t=""]=n.split("?");return new URLSearchParams(t).get("chatId")?.trim()||null}function ie(n,t){return Ve(n,t)}function de(n){return new TextEncoder().encode(n).length}function ce(n){return n.memberBots.filter(t=>t.inChat&&t.hasRole).length}function We(n){return n.memberBots.filter(t=>t.inChat).length}function D(n,t){return t?n.find(o=>o.larkAppId===t):void 0}function qe(n,t){let o=t.toLowerCase();return o?n.filter(i=>{let d=i.chatId.toLowerCase().includes(o)||(i.name??"").toLowerCase().includes(o),y=i.memberBots.some(p=>p.larkAppId.toLowerCase().includes(o)||(p.botName??"").toLowerCase().includes(o));return d||y}):n}function Ye(n,t){let o=t.toLowerCase();return n.filter(i=>!o||i.profileId.toLowerCase().includes(o))}async function C(n){return n.json().catch(()=>({}))}async function ze(){let n=await fetch("/api/groups"),t=await C(n);return{bots:(t.bots??[]).map(o=>({larkAppId:o.larkAppId,botName:o.botName??o.larkAppId,botAvatarUrl:o.botAvatarUrl})),groups:(t.chats??[]).map(o=>({chatId:o.chatId,name:o.name??o.chatId,memberBots:(o.memberBots??[]).map(i=>({larkAppId:i.larkAppId,botName:i.botName??i.larkAppId,inChat:i.inChat??!1,hasRole:i.hasRole??!1,oncallChat:i.oncallChat??null}))}))}}async function Xe(){let n=await fetch("/api/role-profiles");return(await C(n)).profiles??[]}async function x(n){let t=await fetch(`/api/role-profiles/${encodeURIComponent(n)}`);return(await C(t)).entries??[]}async function pe(n,t){let o=await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`);return C(o)}async function Ze(n,t,o,i){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:o,injectMode:i})})).ok}async function Qe(n,t,o){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({injectMode:o})})).ok}async function et(n,t){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"DELETE"})).ok}async function tt(n,t){let o=await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`);return C(o)}async function ot(n,t,o){return(await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:o,allowEmpty:!0})})).ok}async function rt(n,t){return(await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"DELETE"})).ok}async function nt(n,t){let o=await Promise.all(t.map(async p=>{try{let c=await fetch(`/api/role-profiles/${encodeURIComponent(p.profileId)}`),f=await C(c);return[p.profileId,Array.isArray(f.entries)?f.entries:[]]}catch{return[p.profileId,[]]}})),i=new Set,d=[];for(let p of n)for(let c of p.memberBots){if(!c.inChat||!c.hasRole)continue;let f=ie(c.larkAppId,p.chatId);i.has(f)||(i.add(f),d.push({larkAppId:c.larkAppId,chatId:p.chatId}))}let y=await _e(d);return{entriesByProfile:new Map(o),effectiveRolesByBot:y}}async function lt(n){let t=await fetch(`/api/role-profiles/${encodeURIComponent(n.profileId)}/apply`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({chatId:n.chatId,larkAppId:n.larkAppId,force:n.force,preview:n.preview})}),o=await C(t);return{larkAppId:n.larkAppId,ok:t.ok&&o.ok!==!1,status:t.status,error:o.error,wouldRefuse:o.wouldRefuse}}var e=oe(De(),1);function Wt(){let n=(0,l.useRef)(!0);return(0,l.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]),n}function qt(){let n=(0,l.useRef)(new Set);return(0,l.useEffect)(()=>()=>{for(let t of n.current)window.clearTimeout(t);n.current.clear()},[]),(0,l.useCallback)((t,o)=>{let i=window.setTimeout(()=>{n.current.delete(i),t()},o);return n.current.add(i),i},[])}function it(n){return(0,e.jsx)(Fe,{html:je({name:n.bot.botName,larkAppId:n.bot.larkAppId,avatarUrl:n.bot.botAvatarUrl,size:"sm"})})}function dt(n){let t=Ue(),o=Wt(),i=qt(),[d,y]=(0,l.useState)([]),[p,c]=(0,l.useState)([]),[f,P]=(0,l.useState)([]),[ct,ue]=(0,l.useState)({entriesByProfile:new Map,effectiveRolesByBot:new Map}),[pt,F]=(0,l.useState)(!1),[ft,J]=(0,l.useState)(!0),[ut,K]=(0,l.useState)(!0),[W,mt]=(0,l.useState)(""),[q,vt]=(0,l.useState)(""),[ht,me]=(0,l.useState)(()=>new Set),[v,ve]=(0,l.useState)(null),[h,he]=(0,l.useState)(null),[yt,U]=(0,l.useState)(null),[R,O]=(0,l.useState)(""),[S,E]=(0,l.useState)("every"),[ye,ge]=(0,l.useState)(!1),[Ie,be]=(0,l.useState)(!1),[gt,Pe]=(0,l.useState)(!1),[It,Y]=(0,l.useState)(null),[bt,Re]=(0,l.useState)(null),[m,Pt]=(0,l.useState)(null),[I,ke]=(0,l.useState)(null),[B,M]=(0,l.useState)([]),[L,H]=(0,l.useState)(""),[k,G]=(0,l.useState)(null),[Ne,Rt]=(0,l.useState)(!1),[we,Ce]=(0,l.useState)(()=>new Set),[Ae,xe]=(0,l.useState)(!1),[Se,Ee]=(0,l.useState)(!1),[kt,z]=(0,l.useState)(null),[Nt,T]=(0,l.useState)({kind:"idle"}),Be=(0,l.useRef)(0),j=(0,l.useRef)(0),Me=(0,l.useRef)(null),X=v?d.find(r=>r.chatId===v):void 0,wt=X&&h?X.memberBots.find(r=>r.larkAppId===h):void 0,Z=I?p.find(r=>r.larkAppId===I):void 0,Ct=D(B,I),Q=k?d.find(r=>r.chatId===k):void 0,V=Q?.memberBots.filter(r=>r.inChat)??[],At=V.map(r=>r.larkAppId).join("\0"),xt=B.map(r=>r.larkAppId).sort().join("\0"),St=(0,l.useMemo)(()=>qe(d,W),[d,W]),Et=(0,l.useMemo)(()=>Ye(f,q),[f,q]),ee=de(R),te=de(L),_=(0,l.useCallback)((r,s,a=!1)=>{let u=Date.now()+Math.random();r({text:s,isError:a,id:u}),i(()=>{r(g=>g?.id===u?null:g)},a?3e3:2e3)},[i]),b=(0,l.useCallback)(async(r,s)=>{try{let a=await nt(r,s);if(!o.current)return;ue(a),F(!0)}catch{if(!o.current)return;ue({entriesByProfile:new Map,effectiveRolesByBot:new Map}),F(!0)}},[o]),N=(0,l.useCallback)(async()=>{let r=await ze();return o.current&&(y(r.groups),c(r.bots)),r},[o]),$=(0,l.useCallback)(async()=>{let r=await Xe();return o.current&&P(r),r},[o]),Le=(0,l.useCallback)(async()=>{J(!0),K(!0),F(!1);try{let r=await N();if(!o.current)return;let s=await $();if(!o.current||(await $e(),!o.current))return;if(me(new Set(r.groups.filter(a=>ce(a)>0).map(a=>a.chatId))),n.tab==="profiles"){let a=Ke();G(u=>u||(a&&r.groups.some(g=>g.chatId===a)?a:r.groups[0]?.chatId??null))}else G(a=>a??r.groups[0]?.chatId??null);J(!1),K(!1),b(r.groups,s)}catch{if(!o.current)return;J(!1),K(!1),F(!0)}},[o,n.tab,N,$,b]);(0,l.useEffect)(()=>{Le()},[Le]),(0,l.useEffect)(()=>{k||d.length===0||G(d[0].chatId)},[d,k]),(0,l.useEffect)(()=>{let r=new Set(V.filter(s=>!!D(B,s.larkAppId)).map(s=>s.larkAppId));Ce(r),T({kind:"idle"})},[xt,At]);async function Bt(r,s){let a=++Be.current;ve(r),he(s);let u=await pe(s,r);!o.current||a!==Be.current||(U(u),O(u.content??""),E(u.injectMode==="once"?"once":"every"),Y(null),Re(null))}async function Mt(){let r=await N();if(o.current&&(b(r.groups,f),v&&h)){let s=await pe(h,v);if(!o.current)return;U(s),O(s.content??""),E(s.injectMode==="once"?"once":"every")}}async function Lt(){if(!(!v||!h)){ge(!0);try{let r=await Ze(h,v,R,S);if(!o.current)return;if(r){let s=await N();if(!o.current)return;U(a=>a&&{...a,content:R,hasRole:!0,injectMode:S}),b(s.groups,f),_(Y,t("roles.saved"))}else _(Y,R.trim().length===0?t("roles.emptyError"):t("roles.saveFailed"),!0)}finally{o.current&&ge(!1)}}}async function Gt(){if(!(!v||!h)&&confirm(t("roles.confirmDelete"))){be(!0);try{let r=await et(h,v);if(!o.current)return;if(r){let s=await N();if(!o.current)return;ve(null),he(null),U(null),O(""),E("every"),b(s.groups,f)}}finally{o.current&&be(!1)}}}async function Tt(r){if(!v||!h)return;let s=S;E(r),Pe(!0);try{let a=await Qe(h,v,r);if(!o.current)return;a||E(s),_(Re,t(a?"roles.saved":"roles.saveFailed"),!a)}finally{o.current&&Pe(!1)}}async function Ge(r){let s=r.trim();if(!ae(s))return;let a=++j.current;Pt(s),ke(null),H(""),T({kind:"idle"}),G(g=>g??d[0]?.chatId??null);let u=await x(s);!o.current||a!==j.current||(M(u),z(null))}async function jt(r){if(!m)return;let s=++j.current;ke(r);let a=await tt(m,r);if(!o.current||s!==j.current)return;H(a.content??"");let u=await x(m);!o.current||s!==j.current||(M(u),z(null))}async function $t(){let r=await N();if(!o.current)return;let s=await $();if(o.current){if(m){let a=await x(m);if(!o.current)return;M(a)}b(r.groups,s)}}async function Dt(){let r=Me.current,s=r?.value.trim()??"";if(s){if(!ae(s)){r?.setCustomValidity(t("roles.profileIdInvalid")),r?.reportValidity();return}r?.setCustomValidity(""),await Ge(s),o.current&&(location.hash.startsWith("#/roles/profile")||(location.hash="#/roles/profile"))}}async function Ft(){if(!(!m||!I)){xe(!0);try{let r=await ot(m,I,L);if(!o.current)return;let s=await $();if(!o.current)return;let a=await x(m);if(!o.current)return;M(a),b(d,s),_(z,t(r?"roles.saved":"roles.saveFailed"),!r)}finally{o.current&&xe(!1)}}}async function Ut(){if(!(!m||!I)&&confirm(t("roles.confirmDeleteProfileEntry"))){Ee(!0);try{if(await rt(m,I),!o.current)return;H("");let r=await $();if(!o.current)return;let s=await x(m);if(!o.current)return;M(s),b(d,r)}finally{o.current&&Ee(!1)}}}function Ot(r,s){Ce(a=>{let u=new Set(a);return s?u.add(r):u.delete(r),u})}async function Te(r){if(!m)return;let s=k??d[0]?.chatId;if(!s)return;let a=[...we];if(a.length===0){T({kind:"text",text:t("roles.applyPickBots")});return}T({kind:"text",text:"..."});let u=await Promise.all(a.map(g=>lt({profileId:m,chatId:s,larkAppId:g,force:Ne,preview:r})));if(o.current&&(T({kind:"results",preview:r,results:u}),!r)){let g=await N();if(!o.current)return;b(g.groups,f)}}let Ht=ye||ee>w||R.trim().length===0,Vt=Ae||te>w||L.trim().length===0,A=n.tab==="profiles",_t=(0,e.jsxs)("nav",{className:"roles-subnav insight-tabs",role:"tablist","aria-label":t("roles.title"),children:[(0,e.jsx)("a",{href:"#/roles",className:`itab${A?"":" on"}`,role:"tab","aria-selected":!A,children:t("roles.tabGroups")}),(0,e.jsx)("a",{href:"#/roles/profile",className:`itab${A?" on":""}`,role:"tab","aria-selected":A,children:t("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:t("nav.roles")}),(0,e.jsx)("h1",{children:t("roles.title")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:_t})]}),(0,e.jsxs)("div",{id:"roles-by-group-view",className:"roles-layout",hidden:A,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:t("roles.search"),value:W,onChange:r=>mt(r.target.value)}),(0,e.jsx)(le,{id:"roles-refresh",label:t("roles.refresh"),onClick:()=>{Mt()}})]}),(0,e.jsx)("div",{id:"roles-tree",className:"roles-tree",children:ft?(0,e.jsx)(ne,{label:t("common.loading")}):(0,e.jsx)(zt,{groups:St,profiles:f,context:ct,contextLoaded:pt,expandedGroups:ht,selectedGroupId:v,selectedBotId:h,tr:t,onToggleGroup:r=>me(s=>Yt(s,r)),onSelectBot:(r,s)=>{Bt(r,s)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:!v||!h?(0,e.jsx)("div",{id:"roles-editor-empty",className:"roles-editor-empty",children:t("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:X?.name??v}),(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{id:"roles-editor-bot-name",children:wt?.botName??h})]}),(0,e.jsx)("div",{className:"roles-editor-meta",children:(0,e.jsxs)("span",{id:"roles-editor-chat-id",className:"roles-editor-meta-line",children:[v," \xB7 ",h]})})]}),(0,e.jsxs)("div",{className:"roles-editor-actions roles-editor-head-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-delete",className:"danger",style:{display:yt?.hasRole?"":"none"},disabled:Ie,onClick:()=>{Gt()},children:Ie?"...":t("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-save",className:"primary",disabled:Ht,onClick:()=>{Lt()},children:ye?"...":t("roles.save")})]})]}),(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:t("roles.injectModeLabel")}),(0,e.jsx)(se,{id:"roles-editor-inject-mode",className:"roles-inline-menu",ariaLabel:t("roles.injectModeLabel"),disabled:gt,label:t(S==="once"?"roles.injectModeOnce":"roles.injectModeEvery"),value:S,options:[{value:"every",label:t("roles.injectModeEvery")},{value:"once",label:t("roles.injectModeOnce")}],onChange:r=>{Tt(r==="once"?"once":"every")}}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:t("roles.injectModeHint")}),(0,e.jsx)(fe,{flash:bt})]}),(0,e.jsx)("textarea",{id:"roles-editor-textarea",placeholder:t("roles.editorPlaceholder"),rows:14,value:R,onChange:r=>O(r.target.value)}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-editor-bytecount",className:st(ee),children:[ee," / ",w," bytes"]}),(0,e.jsx)(fe,{flash:It})]}),(0,e.jsx)(at,{content:R,tr:t,id:"roles-preview"})]})})]}),(0,e.jsxs)("div",{id:"roles-profiles-view",className:"roles-layout roles-profiles-layout",hidden:!A,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:t("roles.profileIdPlaceholder"),maxLength:64,ref:Me,onChange:r=>r.currentTarget.setCustomValidity("")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-select",onClick:()=>{Dt()},children:t("roles.openProfile")})]}),(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-profile-search",placeholder:t("roles.profileSearch"),value:q,onChange:r=>vt(r.target.value)}),(0,e.jsx)(le,{id:"roles-profile-refresh",label:t("roles.refresh"),onClick:()=>{$t()}})]}),(0,e.jsx)("div",{id:"roles-profile-list",className:"roles-tree",children:ut?(0,e.jsx)(ne,{label:t("common.loading")}):(0,e.jsx)(Zt,{profiles:Et,selectedProfileId:m,tr:t,onSelect:r=>{Ge(r)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:m?(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:m}),Z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{children:Z.botName??Z.larkAppId})]}):null]}),(0,e.jsx)("div",{className:"roles-editor-meta-line",children:t("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:t("roles.profileBots")}),(0,e.jsx)("div",{className:"roles-profile-bot-list",children:p.map(r=>{let s=!!D(B,r.larkAppId),a=I===r.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row roles-profile-bot-row ${a?"selected":""}`,"data-profile-bot-id":r.larkAppId,onClick:()=>{jt(r.larkAppId)},children:[(0,e.jsx)(it,{bot:r}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:r.botName??r.larkAppId}),(0,e.jsx)("div",{className:"roles-bot-id",children:r.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${s?"has-role":"no-role"}`,children:t(s?"roles.configured":"roles.unconfigured")})]},r.larkAppId)})})]}),(0,e.jsx)("div",{className:"roles-profile-editor",children:I?(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:st(te),children:[te," / ",w," 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:Ct?"":"none"},disabled:Se,onClick:()=>{Ut()},children:Se?"...":t("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-save",className:"primary",disabled:Vt,onClick:()=>{Ft()},children:Ae?"...":t("roles.saveEntry")})]})]}),(0,e.jsx)("textarea",{id:"roles-profile-textarea",placeholder:t("roles.profileEditorPlaceholder"),rows:12,value:L,onChange:r=>H(r.target.value)}),(0,e.jsx)("div",{className:"roles-editor-footer",children:(0,e.jsx)(fe,{flash:kt})}),(0,e.jsx)(at,{content:L,tr:t,id:"roles-profile-preview"})]}):(0,e.jsx)("div",{className:"roles-editor-empty roles-profile-inline-empty",children:t("roles.profileBotSelectHint")})})]}),(0,e.jsxs)("div",{className:"roles-profile-apply",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:t("roles.applyToGroup")}),(0,e.jsxs)("div",{className:"roles-profile-apply-controls",children:[(0,e.jsx)(se,{id:"roles-profile-apply-group",className:"roles-apply-group-menu",ariaLabel:t("roles.applyToGroup"),disabled:d.length===0,label:Q?.name??k??t("roles.noChats"),value:k??"",options:d.map(r=>({value:r.chatId,label:r.name??r.chatId})),onChange:r=>G(r)}),(0,e.jsxs)("label",{className:"roles-profile-force",children:[(0,e.jsx)("input",{type:"checkbox",id:"roles-profile-apply-force",checked:Ne,onChange:r=>Rt(r.target.checked)})," ",t("roles.applyForce")]})]}),(0,e.jsx)("div",{id:"roles-profile-apply-bots",children:!Q||V.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.noChats")}):V.map(r=>{let s=!!D(B,r.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:r.larkAppId,checked:we.has(r.larkAppId),onChange:a=>Ot(r.larkAppId,a.target.checked)}),(0,e.jsx)("span",{children:r.botName??r.larkAppId}),(0,e.jsx)("small",{children:t(s?"roles.configured":"roles.profileMissing")})]},r.larkAppId)})}),(0,e.jsxs)("div",{className:"roles-editor-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-preview-apply",onClick:()=>{Te(!0)},children:t("roles.previewApply")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-apply",className:"primary",onClick:()=>{Te(!1)},children:t("roles.applyProfile")})]}),(0,e.jsx)("div",{id:"roles-profile-apply-status",className:"roles-profile-status",children:(0,e.jsx)(Qt,{status:Nt,bots:p,tr:t})})]})]}):(0,e.jsx)("div",{id:"roles-profile-empty",className:"roles-editor-empty",children:t("roles.profileSelectHint")})})]})]})}function Yt(n,t){let o=new Set(n);return o.has(t)?o.delete(t):o.add(t),o}function st(n){return`roles-bytecount ${n>Je?"warn":""} ${n>w?"over":""}`}function fe(n){return n.flash?(0,e.jsxs)("span",{className:`roles-saved-flash ${n.flash.isError?"roles-save-error":""}`,children:[" ",n.flash.text]}):null}function zt(n){let{tr:t}=n;return n.groups.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.noChats")}):(0,e.jsx)(e.Fragment,{children:n.groups.map(o=>{let i=n.expandedGroups.has(o.chatId),d=o.memberBots.filter(c=>c.inChat),y=ce(o),p=We(o);return(0,e.jsxs)("div",{className:"roles-group-section",children:[(0,e.jsxs)("div",{className:`roles-group-row ${i?"expanded":""} ${n.selectedGroupId===o.chatId&&!n.selectedBotId?"selected":""}`,"data-group-id":o.chatId,onClick:()=>n.onToggleGroup(o.chatId),children:[(0,e.jsx)("span",{className:"roles-group-arrow",children:i?"\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:o.name??o.chatId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[y,"/",p," ",t("roles.botsWithRoles")]}),(0,e.jsx)(Xt,{group:o,profiles:n.profiles,context:n.context,loaded:n.contextLoaded,tr:t})]}),(0,e.jsx)("span",{className:"roles-group-chevron"})]}),(0,e.jsx)("div",{className:"roles-bot-list",children:i?d.map(c=>{let f=n.selectedGroupId===o.chatId&&n.selectedBotId===c.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row ${f?"selected":""}`,"data-group-id":o.chatId,"data-bot-id":c.larkAppId,onClick:P=>{P.stopPropagation(),n.onSelectBot(o.chatId,c.larkAppId)},children:[(0,e.jsx)("span",{className:"roles-bot-indent"}),(0,e.jsx)(it,{bot:c}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:c.botName}),(0,e.jsx)("div",{className:"roles-bot-id",children:c.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${c.hasRole?"has-role":"no-role"}`,children:c.hasRole?t("roles.configured"):t("roles.unconfigured")})]},c.larkAppId)}):null})]},o.chatId)})})}function Xt(n){let{group:t,profiles:o,context:i,loaded:d,tr:y}=n;if(!o.length||!d)return null;let p=new Map;for(let P of t.memberBots)P.inChat&&p.set(P.larkAppId,i.effectiveRolesByBot.get(ie(P.larkAppId,t.chatId))??null);if(!Oe(p))return null;let c=He(t.memberBots,o,i.entriesByProfile,p)[0];if(!c)return(0,e.jsx)("div",{className:"roles-profile-match muted",children:y("groups.profileStatusUnmatched")});let f=c.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`roles-profile-match ${c.kind}`,children:y(f,{name:c.profileId,matched:c.matched,total:c.total,chat:c.chatMatched})})}function at(n){return(0,e.jsx)("div",{id:n.id,className:"roles-preview",children:n.content.trim()?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("strong",{children:n.tr("roles.preview")}),(0,e.jsx)("pre",{children:n.content})]}):(0,e.jsx)("small",{children:n.tr("roles.previewEmpty")})})}function Zt(n){let{tr:t}=n;return n.profiles.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.profileEmpty")}):(0,e.jsx)(e.Fragment,{children:n.profiles.map(o=>{let i=n.selectedProfileId===o.profileId,d=(o.botEntries??[]).some(y=>y.hasEntry);return(0,e.jsxs)("div",{className:`roles-profile-row ${i?"selected":""}`,"data-profile-id":o.profileId,onClick:()=>n.onSelect(o.profileId),children:[(0,e.jsxs)("div",{className:"roles-profile-row-main",children:[(0,e.jsx)("div",{className:"roles-profile-name",children:o.profileId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[o.entryCount," ",t("roles.profileEntries")]})]}),(0,e.jsx)("span",{className:`roles-badge ${d?"has-role":"no-role"}`,children:t(d?"roles.configured":"roles.profileMissing")})]},o.profileId)})})}function Qt(n){let{status:t,bots:o,tr:i}=n;return t.kind==="idle"?null:t.kind==="text"?(0,e.jsx)(e.Fragment,{children:t.text}):(0,e.jsx)(e.Fragment,{children:t.results.map(d=>{let p=o.find(f=>f.larkAppId===d.larkAppId)?.botName??d.larkAppId,c=d.ok?t.preview?d.wouldRefuse?i("roles.applyWouldRefuse"):i("roles.applyPreviewOk"):i("roles.applyOk"):`${i("roles.applyFailed")}: ${String(d.error??`HTTP ${d.status}`)}`;return(0,e.jsxs)("div",{children:[p,": ",c]},d.larkAppId)})})}function io(n){return re(n,(0,e.jsx)(dt,{tab:"groups"}))}function co(n){return re(n,(0,e.jsx)(dt,{tab:"profiles"}))}export{co as renderRoleProfilesPage,io as renderRolesPage};
|
|
1
|
+
import{a as Oe,b as He,c as Ve,d as _e}from"./chunk-R3FXBFQH.js";import{c as Ue}from"./chunk-JMRGZQDB.js";import{b as Fe,c as ne,h as le,p as se}from"./chunk-QFMH6ITB.js";import{C as $e,y as je}from"./chunk-SNKATZWK.js";import{a as re}from"./chunk-SYC6D5XU.js";import{a as Jt,d as De}from"./chunk-5THX4DI2.js";import{c as oe}from"./chunk-7SZRL6FY.js";var l=oe(Jt(),1);var w=32768,Je=Math.floor(w*.95),Kt=/^[A-Za-z0-9._-]{1,64}$/;function ae(n){return Kt.test(n)&&n!=="."&&n!==".."}function Ke(n=location.hash){let[,t=""]=n.split("?");return new URLSearchParams(t).get("chatId")?.trim()||null}function ie(n,t){return Ve(n,t)}function de(n){return new TextEncoder().encode(n).length}function ce(n){return n.memberBots.filter(t=>t.inChat&&t.hasRole).length}function We(n){return n.memberBots.filter(t=>t.inChat).length}function D(n,t){return t?n.find(o=>o.larkAppId===t):void 0}function qe(n,t){let o=t.toLowerCase();return o?n.filter(i=>{let d=i.chatId.toLowerCase().includes(o)||(i.name??"").toLowerCase().includes(o),y=i.memberBots.some(p=>p.larkAppId.toLowerCase().includes(o)||(p.botName??"").toLowerCase().includes(o));return d||y}):n}function Ye(n,t){let o=t.toLowerCase();return n.filter(i=>!o||i.profileId.toLowerCase().includes(o))}async function C(n){return n.json().catch(()=>({}))}async function ze(){let n=await fetch("/api/groups"),t=await C(n);return{bots:(t.bots??[]).map(o=>({larkAppId:o.larkAppId,botName:o.botName??o.larkAppId,botAvatarUrl:o.botAvatarUrl})),groups:(t.chats??[]).map(o=>({chatId:o.chatId,name:o.name??o.chatId,memberBots:(o.memberBots??[]).map(i=>({larkAppId:i.larkAppId,botName:i.botName??i.larkAppId,inChat:i.inChat??!1,hasRole:i.hasRole??!1,oncallChat:i.oncallChat??null}))}))}}async function Xe(){let n=await fetch("/api/role-profiles");return(await C(n)).profiles??[]}async function x(n){let t=await fetch(`/api/role-profiles/${encodeURIComponent(n)}`);return(await C(t)).entries??[]}async function pe(n,t){let o=await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`);return C(o)}async function Ze(n,t,o,i){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:o,injectMode:i})})).ok}async function Qe(n,t,o){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({injectMode:o})})).ok}async function et(n,t){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"DELETE"})).ok}async function tt(n,t){let o=await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`);return C(o)}async function ot(n,t,o){return(await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:o,allowEmpty:!0})})).ok}async function rt(n,t){return(await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"DELETE"})).ok}async function nt(n,t){let o=await Promise.all(t.map(async p=>{try{let c=await fetch(`/api/role-profiles/${encodeURIComponent(p.profileId)}`),f=await C(c);return[p.profileId,Array.isArray(f.entries)?f.entries:[]]}catch{return[p.profileId,[]]}})),i=new Set,d=[];for(let p of n)for(let c of p.memberBots){if(!c.inChat||!c.hasRole)continue;let f=ie(c.larkAppId,p.chatId);i.has(f)||(i.add(f),d.push({larkAppId:c.larkAppId,chatId:p.chatId}))}let y=await _e(d);return{entriesByProfile:new Map(o),effectiveRolesByBot:y}}async function lt(n){let t=await fetch(`/api/role-profiles/${encodeURIComponent(n.profileId)}/apply`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({chatId:n.chatId,larkAppId:n.larkAppId,force:n.force,preview:n.preview})}),o=await C(t);return{larkAppId:n.larkAppId,ok:t.ok&&o.ok!==!1,status:t.status,error:o.error,wouldRefuse:o.wouldRefuse}}var e=oe(De(),1);function Wt(){let n=(0,l.useRef)(!0);return(0,l.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]),n}function qt(){let n=(0,l.useRef)(new Set);return(0,l.useEffect)(()=>()=>{for(let t of n.current)window.clearTimeout(t);n.current.clear()},[]),(0,l.useCallback)((t,o)=>{let i=window.setTimeout(()=>{n.current.delete(i),t()},o);return n.current.add(i),i},[])}function it(n){return(0,e.jsx)(Fe,{html:je({name:n.bot.botName,larkAppId:n.bot.larkAppId,avatarUrl:n.bot.botAvatarUrl,size:"sm"})})}function dt(n){let t=Ue(),o=Wt(),i=qt(),[d,y]=(0,l.useState)([]),[p,c]=(0,l.useState)([]),[f,P]=(0,l.useState)([]),[ct,ue]=(0,l.useState)({entriesByProfile:new Map,effectiveRolesByBot:new Map}),[pt,F]=(0,l.useState)(!1),[ft,J]=(0,l.useState)(!0),[ut,K]=(0,l.useState)(!0),[W,mt]=(0,l.useState)(""),[q,vt]=(0,l.useState)(""),[ht,me]=(0,l.useState)(()=>new Set),[v,ve]=(0,l.useState)(null),[h,he]=(0,l.useState)(null),[yt,U]=(0,l.useState)(null),[R,O]=(0,l.useState)(""),[S,E]=(0,l.useState)("every"),[ye,ge]=(0,l.useState)(!1),[Ie,be]=(0,l.useState)(!1),[gt,Pe]=(0,l.useState)(!1),[It,Y]=(0,l.useState)(null),[bt,Re]=(0,l.useState)(null),[m,Pt]=(0,l.useState)(null),[I,ke]=(0,l.useState)(null),[B,M]=(0,l.useState)([]),[L,H]=(0,l.useState)(""),[k,G]=(0,l.useState)(null),[Ne,Rt]=(0,l.useState)(!1),[we,Ce]=(0,l.useState)(()=>new Set),[Ae,xe]=(0,l.useState)(!1),[Se,Ee]=(0,l.useState)(!1),[kt,z]=(0,l.useState)(null),[Nt,T]=(0,l.useState)({kind:"idle"}),Be=(0,l.useRef)(0),j=(0,l.useRef)(0),Me=(0,l.useRef)(null),X=v?d.find(r=>r.chatId===v):void 0,wt=X&&h?X.memberBots.find(r=>r.larkAppId===h):void 0,Z=I?p.find(r=>r.larkAppId===I):void 0,Ct=D(B,I),Q=k?d.find(r=>r.chatId===k):void 0,V=Q?.memberBots.filter(r=>r.inChat)??[],At=V.map(r=>r.larkAppId).join("\0"),xt=B.map(r=>r.larkAppId).sort().join("\0"),St=(0,l.useMemo)(()=>qe(d,W),[d,W]),Et=(0,l.useMemo)(()=>Ye(f,q),[f,q]),ee=de(R),te=de(L),_=(0,l.useCallback)((r,s,a=!1)=>{let u=Date.now()+Math.random();r({text:s,isError:a,id:u}),i(()=>{r(g=>g?.id===u?null:g)},a?3e3:2e3)},[i]),b=(0,l.useCallback)(async(r,s)=>{try{let a=await nt(r,s);if(!o.current)return;ue(a),F(!0)}catch{if(!o.current)return;ue({entriesByProfile:new Map,effectiveRolesByBot:new Map}),F(!0)}},[o]),N=(0,l.useCallback)(async()=>{let r=await ze();return o.current&&(y(r.groups),c(r.bots)),r},[o]),$=(0,l.useCallback)(async()=>{let r=await Xe();return o.current&&P(r),r},[o]),Le=(0,l.useCallback)(async()=>{J(!0),K(!0),F(!1);try{let r=await N();if(!o.current)return;let s=await $();if(!o.current||(await $e(),!o.current))return;if(me(new Set(r.groups.filter(a=>ce(a)>0).map(a=>a.chatId))),n.tab==="profiles"){let a=Ke();G(u=>u||(a&&r.groups.some(g=>g.chatId===a)?a:r.groups[0]?.chatId??null))}else G(a=>a??r.groups[0]?.chatId??null);J(!1),K(!1),b(r.groups,s)}catch{if(!o.current)return;J(!1),K(!1),F(!0)}},[o,n.tab,N,$,b]);(0,l.useEffect)(()=>{Le()},[Le]),(0,l.useEffect)(()=>{k||d.length===0||G(d[0].chatId)},[d,k]),(0,l.useEffect)(()=>{let r=new Set(V.filter(s=>!!D(B,s.larkAppId)).map(s=>s.larkAppId));Ce(r),T({kind:"idle"})},[xt,At]);async function Bt(r,s){let a=++Be.current;ve(r),he(s);let u=await pe(s,r);!o.current||a!==Be.current||(U(u),O(u.content??""),E(u.injectMode==="once"?"once":"every"),Y(null),Re(null))}async function Mt(){let r=await N();if(o.current&&(b(r.groups,f),v&&h)){let s=await pe(h,v);if(!o.current)return;U(s),O(s.content??""),E(s.injectMode==="once"?"once":"every")}}async function Lt(){if(!(!v||!h)){ge(!0);try{let r=await Ze(h,v,R,S);if(!o.current)return;if(r){let s=await N();if(!o.current)return;U(a=>a&&{...a,content:R,hasRole:!0,injectMode:S}),b(s.groups,f),_(Y,t("roles.saved"))}else _(Y,R.trim().length===0?t("roles.emptyError"):t("roles.saveFailed"),!0)}finally{o.current&&ge(!1)}}}async function Gt(){if(!(!v||!h)&&confirm(t("roles.confirmDelete"))){be(!0);try{let r=await et(h,v);if(!o.current)return;if(r){let s=await N();if(!o.current)return;ve(null),he(null),U(null),O(""),E("every"),b(s.groups,f)}}finally{o.current&&be(!1)}}}async function Tt(r){if(!v||!h)return;let s=S;E(r),Pe(!0);try{let a=await Qe(h,v,r);if(!o.current)return;a||E(s),_(Re,t(a?"roles.saved":"roles.saveFailed"),!a)}finally{o.current&&Pe(!1)}}async function Ge(r){let s=r.trim();if(!ae(s))return;let a=++j.current;Pt(s),ke(null),H(""),T({kind:"idle"}),G(g=>g??d[0]?.chatId??null);let u=await x(s);!o.current||a!==j.current||(M(u),z(null))}async function jt(r){if(!m)return;let s=++j.current;ke(r);let a=await tt(m,r);if(!o.current||s!==j.current)return;H(a.content??"");let u=await x(m);!o.current||s!==j.current||(M(u),z(null))}async function $t(){let r=await N();if(!o.current)return;let s=await $();if(o.current){if(m){let a=await x(m);if(!o.current)return;M(a)}b(r.groups,s)}}async function Dt(){let r=Me.current,s=r?.value.trim()??"";if(s){if(!ae(s)){r?.setCustomValidity(t("roles.profileIdInvalid")),r?.reportValidity();return}r?.setCustomValidity(""),await Ge(s),o.current&&(location.hash.startsWith("#/roles/profile")||(location.hash="#/roles/profile"))}}async function Ft(){if(!(!m||!I)){xe(!0);try{let r=await ot(m,I,L);if(!o.current)return;let s=await $();if(!o.current)return;let a=await x(m);if(!o.current)return;M(a),b(d,s),_(z,t(r?"roles.saved":"roles.saveFailed"),!r)}finally{o.current&&xe(!1)}}}async function Ut(){if(!(!m||!I)&&confirm(t("roles.confirmDeleteProfileEntry"))){Ee(!0);try{if(await rt(m,I),!o.current)return;H("");let r=await $();if(!o.current)return;let s=await x(m);if(!o.current)return;M(s),b(d,r)}finally{o.current&&Ee(!1)}}}function Ot(r,s){Ce(a=>{let u=new Set(a);return s?u.add(r):u.delete(r),u})}async function Te(r){if(!m)return;let s=k??d[0]?.chatId;if(!s)return;let a=[...we];if(a.length===0){T({kind:"text",text:t("roles.applyPickBots")});return}T({kind:"text",text:"..."});let u=await Promise.all(a.map(g=>lt({profileId:m,chatId:s,larkAppId:g,force:Ne,preview:r})));if(o.current&&(T({kind:"results",preview:r,results:u}),!r)){let g=await N();if(!o.current)return;b(g.groups,f)}}let Ht=ye||ee>w||R.trim().length===0,Vt=Ae||te>w||L.trim().length===0,A=n.tab==="profiles",_t=(0,e.jsxs)("nav",{className:"roles-subnav insight-tabs",role:"tablist","aria-label":t("roles.title"),children:[(0,e.jsx)("a",{href:"#/roles",className:`itab${A?"":" on"}`,role:"tab","aria-selected":!A,children:t("roles.tabGroups")}),(0,e.jsx)("a",{href:"#/roles/profile",className:`itab${A?" on":""}`,role:"tab","aria-selected":A,children:t("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:t("nav.roles")}),(0,e.jsx)("h1",{children:t("roles.title")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:_t})]}),(0,e.jsxs)("div",{id:"roles-by-group-view",className:"roles-layout",hidden:A,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:t("roles.search"),value:W,onChange:r=>mt(r.target.value)}),(0,e.jsx)(le,{id:"roles-refresh",label:t("roles.refresh"),onClick:()=>{Mt()}})]}),(0,e.jsx)("div",{id:"roles-tree",className:"roles-tree",children:ft?(0,e.jsx)(ne,{label:t("common.loading")}):(0,e.jsx)(zt,{groups:St,profiles:f,context:ct,contextLoaded:pt,expandedGroups:ht,selectedGroupId:v,selectedBotId:h,tr:t,onToggleGroup:r=>me(s=>Yt(s,r)),onSelectBot:(r,s)=>{Bt(r,s)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:!v||!h?(0,e.jsx)("div",{id:"roles-editor-empty",className:"roles-editor-empty",children:t("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:X?.name??v}),(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{id:"roles-editor-bot-name",children:wt?.botName??h})]}),(0,e.jsx)("div",{className:"roles-editor-meta",children:(0,e.jsxs)("span",{id:"roles-editor-chat-id",className:"roles-editor-meta-line",children:[v," \xB7 ",h]})})]}),(0,e.jsxs)("div",{className:"roles-editor-actions roles-editor-head-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-delete",className:"danger",style:{display:yt?.hasRole?"":"none"},disabled:Ie,onClick:()=>{Gt()},children:Ie?"...":t("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-save",className:"primary",disabled:Ht,onClick:()=>{Lt()},children:ye?"...":t("roles.save")})]})]}),(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:t("roles.injectModeLabel")}),(0,e.jsx)(se,{id:"roles-editor-inject-mode",className:"roles-inline-menu",ariaLabel:t("roles.injectModeLabel"),disabled:gt,label:t(S==="once"?"roles.injectModeOnce":"roles.injectModeEvery"),value:S,options:[{value:"every",label:t("roles.injectModeEvery")},{value:"once",label:t("roles.injectModeOnce")}],onChange:r=>{Tt(r==="once"?"once":"every")}}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:t("roles.injectModeHint")}),(0,e.jsx)(fe,{flash:bt})]}),(0,e.jsx)("textarea",{id:"roles-editor-textarea",placeholder:t("roles.editorPlaceholder"),rows:14,value:R,onChange:r=>O(r.target.value)}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-editor-bytecount",className:st(ee),children:[ee," / ",w," bytes"]}),(0,e.jsx)(fe,{flash:It})]}),(0,e.jsx)(at,{content:R,tr:t,id:"roles-preview"})]})})]}),(0,e.jsxs)("div",{id:"roles-profiles-view",className:"roles-layout roles-profiles-layout",hidden:!A,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:t("roles.profileIdPlaceholder"),maxLength:64,ref:Me,onChange:r=>r.currentTarget.setCustomValidity("")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-select",onClick:()=>{Dt()},children:t("roles.openProfile")})]}),(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-profile-search",placeholder:t("roles.profileSearch"),value:q,onChange:r=>vt(r.target.value)}),(0,e.jsx)(le,{id:"roles-profile-refresh",label:t("roles.refresh"),onClick:()=>{$t()}})]}),(0,e.jsx)("div",{id:"roles-profile-list",className:"roles-tree",children:ut?(0,e.jsx)(ne,{label:t("common.loading")}):(0,e.jsx)(Zt,{profiles:Et,selectedProfileId:m,tr:t,onSelect:r=>{Ge(r)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:m?(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:m}),Z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{children:Z.botName??Z.larkAppId})]}):null]}),(0,e.jsx)("div",{className:"roles-editor-meta-line",children:t("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:t("roles.profileBots")}),(0,e.jsx)("div",{className:"roles-profile-bot-list",children:p.map(r=>{let s=!!D(B,r.larkAppId),a=I===r.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row roles-profile-bot-row ${a?"selected":""}`,"data-profile-bot-id":r.larkAppId,onClick:()=>{jt(r.larkAppId)},children:[(0,e.jsx)(it,{bot:r}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:r.botName??r.larkAppId}),(0,e.jsx)("div",{className:"roles-bot-id",children:r.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${s?"has-role":"no-role"}`,children:t(s?"roles.configured":"roles.unconfigured")})]},r.larkAppId)})})]}),(0,e.jsx)("div",{className:"roles-profile-editor",children:I?(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:st(te),children:[te," / ",w," 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:Ct?"":"none"},disabled:Se,onClick:()=>{Ut()},children:Se?"...":t("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-save",className:"primary",disabled:Vt,onClick:()=>{Ft()},children:Ae?"...":t("roles.saveEntry")})]})]}),(0,e.jsx)("textarea",{id:"roles-profile-textarea",placeholder:t("roles.profileEditorPlaceholder"),rows:12,value:L,onChange:r=>H(r.target.value)}),(0,e.jsx)("div",{className:"roles-editor-footer",children:(0,e.jsx)(fe,{flash:kt})}),(0,e.jsx)(at,{content:L,tr:t,id:"roles-profile-preview"})]}):(0,e.jsx)("div",{className:"roles-editor-empty roles-profile-inline-empty",children:t("roles.profileBotSelectHint")})})]}),(0,e.jsxs)("div",{className:"roles-profile-apply",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:t("roles.applyToGroup")}),(0,e.jsxs)("div",{className:"roles-profile-apply-controls",children:[(0,e.jsx)(se,{id:"roles-profile-apply-group",className:"roles-apply-group-menu",ariaLabel:t("roles.applyToGroup"),disabled:d.length===0,label:Q?.name??k??t("roles.noChats"),value:k??"",options:d.map(r=>({value:r.chatId,label:r.name??r.chatId})),onChange:r=>G(r)}),(0,e.jsxs)("label",{className:"roles-profile-force",children:[(0,e.jsx)("input",{type:"checkbox",id:"roles-profile-apply-force",checked:Ne,onChange:r=>Rt(r.target.checked)})," ",t("roles.applyForce")]})]}),(0,e.jsx)("div",{id:"roles-profile-apply-bots",children:!Q||V.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.noChats")}):V.map(r=>{let s=!!D(B,r.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:r.larkAppId,checked:we.has(r.larkAppId),onChange:a=>Ot(r.larkAppId,a.target.checked)}),(0,e.jsx)("span",{children:r.botName??r.larkAppId}),(0,e.jsx)("small",{children:t(s?"roles.configured":"roles.profileMissing")})]},r.larkAppId)})}),(0,e.jsxs)("div",{className:"roles-editor-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-preview-apply",onClick:()=>{Te(!0)},children:t("roles.previewApply")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-apply",className:"primary",onClick:()=>{Te(!1)},children:t("roles.applyProfile")})]}),(0,e.jsx)("div",{id:"roles-profile-apply-status",className:"roles-profile-status",children:(0,e.jsx)(Qt,{status:Nt,bots:p,tr:t})})]})]}):(0,e.jsx)("div",{id:"roles-profile-empty",className:"roles-editor-empty",children:t("roles.profileSelectHint")})})]})]})}function Yt(n,t){let o=new Set(n);return o.has(t)?o.delete(t):o.add(t),o}function st(n){return`roles-bytecount ${n>Je?"warn":""} ${n>w?"over":""}`}function fe(n){return n.flash?(0,e.jsxs)("span",{className:`roles-saved-flash ${n.flash.isError?"roles-save-error":""}`,children:[" ",n.flash.text]}):null}function zt(n){let{tr:t}=n;return n.groups.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.noChats")}):(0,e.jsx)(e.Fragment,{children:n.groups.map(o=>{let i=n.expandedGroups.has(o.chatId),d=o.memberBots.filter(c=>c.inChat),y=ce(o),p=We(o);return(0,e.jsxs)("div",{className:"roles-group-section",children:[(0,e.jsxs)("div",{className:`roles-group-row ${i?"expanded":""} ${n.selectedGroupId===o.chatId&&!n.selectedBotId?"selected":""}`,"data-group-id":o.chatId,onClick:()=>n.onToggleGroup(o.chatId),children:[(0,e.jsx)("span",{className:"roles-group-arrow",children:i?"\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:o.name??o.chatId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[y,"/",p," ",t("roles.botsWithRoles")]}),(0,e.jsx)(Xt,{group:o,profiles:n.profiles,context:n.context,loaded:n.contextLoaded,tr:t})]}),(0,e.jsx)("span",{className:"roles-group-chevron"})]}),(0,e.jsx)("div",{className:"roles-bot-list",children:i?d.map(c=>{let f=n.selectedGroupId===o.chatId&&n.selectedBotId===c.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row ${f?"selected":""}`,"data-group-id":o.chatId,"data-bot-id":c.larkAppId,onClick:P=>{P.stopPropagation(),n.onSelectBot(o.chatId,c.larkAppId)},children:[(0,e.jsx)("span",{className:"roles-bot-indent"}),(0,e.jsx)(it,{bot:c}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:c.botName}),(0,e.jsx)("div",{className:"roles-bot-id",children:c.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${c.hasRole?"has-role":"no-role"}`,children:c.hasRole?t("roles.configured"):t("roles.unconfigured")})]},c.larkAppId)}):null})]},o.chatId)})})}function Xt(n){let{group:t,profiles:o,context:i,loaded:d,tr:y}=n;if(!o.length||!d)return null;let p=new Map;for(let P of t.memberBots)P.inChat&&p.set(P.larkAppId,i.effectiveRolesByBot.get(ie(P.larkAppId,t.chatId))??null);if(!Oe(p))return null;let c=He(t.memberBots,o,i.entriesByProfile,p)[0];if(!c)return(0,e.jsx)("div",{className:"roles-profile-match muted",children:y("groups.profileStatusUnmatched")});let f=c.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`roles-profile-match ${c.kind}`,children:y(f,{name:c.profileId,matched:c.matched,total:c.total,chat:c.chatMatched})})}function at(n){return(0,e.jsx)("div",{id:n.id,className:"roles-preview",children:n.content.trim()?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("strong",{children:n.tr("roles.preview")}),(0,e.jsx)("pre",{children:n.content})]}):(0,e.jsx)("small",{children:n.tr("roles.previewEmpty")})})}function Zt(n){let{tr:t}=n;return n.profiles.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.profileEmpty")}):(0,e.jsx)(e.Fragment,{children:n.profiles.map(o=>{let i=n.selectedProfileId===o.profileId,d=(o.botEntries??[]).some(y=>y.hasEntry);return(0,e.jsxs)("div",{className:`roles-profile-row ${i?"selected":""}`,"data-profile-id":o.profileId,onClick:()=>n.onSelect(o.profileId),children:[(0,e.jsxs)("div",{className:"roles-profile-row-main",children:[(0,e.jsx)("div",{className:"roles-profile-name",children:o.profileId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[o.entryCount," ",t("roles.profileEntries")]})]}),(0,e.jsx)("span",{className:`roles-badge ${d?"has-role":"no-role"}`,children:t(d?"roles.configured":"roles.profileMissing")})]},o.profileId)})})}function Qt(n){let{status:t,bots:o,tr:i}=n;return t.kind==="idle"?null:t.kind==="text"?(0,e.jsx)(e.Fragment,{children:t.text}):(0,e.jsx)(e.Fragment,{children:t.results.map(d=>{let p=o.find(f=>f.larkAppId===d.larkAppId)?.botName??d.larkAppId,c=d.ok?t.preview?d.wouldRefuse?i("roles.applyWouldRefuse"):i("roles.applyPreviewOk"):i("roles.applyOk"):`${i("roles.applyFailed")}: ${String(d.error??`HTTP ${d.status}`)}`;return(0,e.jsxs)("div",{children:[p,": ",c]},d.larkAppId)})})}function io(n){return re(n,(0,e.jsx)(dt,{tab:"groups"}))}function co(n){return re(n,(0,e.jsx)(dt,{tab:"profiles"}))}export{co as renderRoleProfilesPage,io as renderRolesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as j,b as F}from"./chunk-KPQAUX7V.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-X2L65IOM.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-JMRGZQDB.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-SNKATZWK.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};
|