pi-web-ui 0.116.0 → 0.118.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/CHANGELOG.md +83 -3
- package/README.md +69 -138
- package/README.zh-CN.md +70 -179
- package/README.zh-TW.md +3 -1
- package/bin/device-hub-cli.mjs +163 -36
- package/bin/frp-manager.mjs +4 -80
- package/bin/hub-upgrade.mjs +561 -0
- package/bin/pi-device-hub.mjs +0 -1
- package/bin/pi-web-ui.mjs +184 -504
- package/deploy/nginx-subpath.conf +0 -33
- package/deploy/pi-web-ui.service +0 -20
- package/dist/server/agent-formatters.js +4 -38
- package/dist/server/agent-service-daemon.js +203 -371
- package/dist/server/agent-service.js +1281 -3030
- package/dist/server/approval-audit.js +2 -23
- package/dist/server/approval-default-rules.js +0 -6
- package/dist/server/approval-rules.js +7 -105
- package/dist/server/ask-user-question-tool.js +1 -12
- package/dist/server/atomic-file.js +33 -5
- package/dist/server/attachment-store.js +0 -36
- package/dist/server/attachments.js +3 -112
- package/dist/server/auth-cookie.js +0 -21
- package/dist/server/bash-tool.js +1 -32
- package/dist/server/bg-servers.js +0 -96
- package/dist/server/browser-page-tool.js +11 -62
- package/dist/server/builtin-modules.js +7 -0
- package/dist/server/canvas/canvas-agent-tool.js +58 -47
- package/dist/server/canvas/canvas-cards.js +0 -14
- package/dist/server/canvas/canvas-dispatch.js +7 -4
- package/dist/server/canvas/canvas-orchestrator.js +167 -181
- package/dist/server/canvas/canvas-runtime-messages.js +30 -0
- package/dist/server/canvas/canvas-scheduled-task.js +0 -3
- package/dist/server/canvas/canvas-scheduler.js +5 -7
- package/dist/server/canvas/canvas-store.js +24 -35
- package/dist/server/canvas/canvas-validation.js +17 -14
- package/dist/server/canvas/canvas-workspace.js +42 -114
- package/dist/server/canvas/pstack-skills-data.js +0 -5
- package/dist/server/claim-files-tool.js +1 -15
- package/dist/server/claim-store.js +5 -49
- package/dist/server/client-id-utils.js +0 -16
- package/dist/server/client-state.js +36 -214
- package/dist/server/communicate-tool.js +0 -3
- package/dist/server/compact-context-tool.js +0 -30
- package/dist/server/compacted-history.js +0 -35
- package/dist/server/compaction-instructions.js +0 -13
- package/dist/server/compaction-markers.js +38 -92
- package/dist/server/compaction-state.js +0 -21
- package/dist/server/composer-drafts.js +0 -34
- package/dist/server/context-budget-runner.js +0 -11
- package/dist/server/context-budget.js +1 -70
- package/dist/server/context-evidence.js +0 -14
- package/dist/server/context-usage.js +0 -12
- package/dist/server/control-socket.js +4 -48
- package/dist/server/conversation-communication.js +0 -10
- package/dist/server/conversation-identity.js +0 -1
- package/dist/server/conversation-read-tool.js +0 -58
- package/dist/server/conversation-tool-names.js +0 -1
- package/dist/server/conversation-tool.js +0 -1
- package/dist/server/conversation-touches.js +4 -75
- package/dist/server/dangling-tools.js +142 -68
- package/dist/server/delegate-mode.js +0 -36
- package/dist/server/delegate-task.js +2 -28
- package/dist/server/device-center/approval-summary.js +0 -1
- package/dist/server/device-center/bot-catalog.js +0 -3
- package/dist/server/device-center/bot-execution.js +48 -9
- package/dist/server/device-center/bot-presets.js +0 -1
- package/dist/server/device-center/bots.js +0 -1
- package/dist/server/device-center/collab-service.js +27 -11
- package/dist/server/device-center/collab-tool.js +393 -27
- package/dist/server/device-center/connector.js +128 -48
- package/dist/server/device-center/delivery-authority.js +95 -0
- package/dist/server/device-center/delivery-subject.js +29 -0
- package/dist/server/device-center/desktop-linux.js +3 -15
- package/dist/server/device-center/desktop-native.js +1 -10
- package/dist/server/device-center/desktop-page.js +2 -3
- package/dist/server/device-center/desktop-setup.js +1 -3
- package/dist/server/device-center/desktop.js +1 -7
- package/dist/server/device-center/device-integration.js +452 -208
- package/dist/server/device-center/device-lan-access.js +403 -0
- package/dist/server/device-center/device-lan.js +484 -0
- package/dist/server/device-center/device-portals.js +0 -3
- package/dist/server/device-center/execution-failure.js +0 -2
- package/dist/server/device-center/execution-guides.js +15 -6
- package/dist/server/device-center/execution-instructions.js +0 -1
- package/dist/server/device-center/execution-settings.js +0 -1
- package/dist/server/device-center/execution-system-prompt.js +0 -3
- package/dist/server/device-center/execution-workspace.js +1 -4
- package/dist/server/device-center/executor.js +46 -31
- package/dist/server/device-center/file-sync-paths.js +0 -5
- package/dist/server/device-center/file-sync.js +0 -10
- package/dist/server/device-center/group-context-delta.js +0 -8
- package/dist/server/device-center/group-context-message.js +0 -14
- package/dist/server/device-center/group-context.js +0 -19
- package/dist/server/device-center/group-events.js +0 -2
- package/dist/server/device-center/group-plan-guard.js +1 -35
- package/dist/server/device-center/group-router-runtime.js +182 -0
- package/dist/server/device-center/group-router-worker.js +178 -0
- package/dist/server/device-center/group-router.js +359 -0
- package/dist/server/device-center/hub-auth.js +24 -2
- package/dist/server/device-center/hub-conversations.js +13 -15
- package/dist/server/device-center/hub-deliveries.js +119 -15
- package/dist/server/device-center/hub-integration.js +647 -334
- package/dist/server/device-center/hub-locks.js +1 -5
- package/dist/server/device-center/hub-mobile.js +147 -0
- package/dist/server/device-center/hub-orchestration.js +400 -0
- package/dist/server/device-center/hub-page.js +28 -9
- package/dist/server/device-center/hub-setup.js +23 -7
- package/dist/server/device-center/hub-transaction-log.js +175 -0
- package/dist/server/device-center/hub-upgrade.js +162 -0
- package/dist/server/device-center/hub-webhooks.js +1 -3
- package/dist/server/device-center/hub.js +946 -404
- package/dist/server/device-center/human-interaction.js +1 -4
- package/dist/server/device-center/integration-errors.js +0 -2
- package/dist/server/device-center/integration-verification.js +111 -0
- package/dist/server/device-center/local-hub.js +6 -4
- package/dist/server/device-center/local-publication.js +416 -0
- package/dist/server/device-center/local-verification-job.js +95 -0
- package/dist/server/device-center/local-verification.js +273 -0
- package/dist/server/device-center/local.js +341 -18
- package/dist/server/device-center/main.js +18 -2
- package/dist/server/device-center/mobile-notification-forwarder.js +292 -0
- package/dist/server/device-center/native-desktop/macos.js +0 -1
- package/dist/server/device-center/native-desktop/windows.js +0 -1
- package/dist/server/device-center/partition-log.js +52 -46
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +305 -0
- package/dist/server/device-center/publish-intent.js +374 -0
- package/dist/server/device-center/relay.js +217 -52
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +419 -52
- package/dist/server/device-center/store.js +223 -65
- package/dist/server/device-center/task-context-budget.js +0 -3
- package/dist/server/device-center/task-error.js +0 -1
- package/dist/server/device-center/task-journal.js +6 -23
- package/dist/server/device-center/task-outcome.js +68 -0
- package/dist/server/device-center/task-plan.js +0 -1
- package/dist/server/device-center/task-progress.js +0 -16
- package/dist/server/device-center/task-recovery.js +569 -227
- package/dist/server/device-center/task-report-outbox.js +0 -4
- package/dist/server/device-center/task-report.js +2 -10
- package/dist/server/device-center/task-scheduler.js +1 -35
- package/dist/server/device-center/task-settlement.js +335 -0
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +393 -0
- package/dist/server/device-center/transfer-stream.js +5 -45
- package/dist/server/device-center/transfers.js +2 -10
- package/dist/server/device-center/verification-limits.js +9 -0
- package/dist/server/device-center/work-contract.js +923 -0
- package/dist/server/device-center/work-items.js +317 -0
- package/dist/server/device-center/workspaces.js +0 -1
- package/dist/server/dispatch-domain-handlers.js +202 -29
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +78 -601
- package/dist/server/dsh/dsh-client.js +7 -111
- package/dist/server/dsh/dsh-market-service.js +4 -25
- package/dist/server/dsh/dsh-serialize.js +0 -49
- package/dist/server/dsh/dsh-sessions.js +0 -37
- package/dist/server/dsh/dsh-usage.js +0 -37
- package/dist/server/dsh/preset-clones.js +1 -65
- package/dist/server/dsh/runtime/custom-prompt.mjs +0 -14
- package/dist/server/dsh/runtime/goal-rpc.mjs +7 -176
- package/dist/server/dsh/runtime/launcher.mjs +2 -53
- package/dist/server/dsh/runtime/override.patch.yml +0 -29
- package/dist/server/dsh/runtime/runtime-root.mjs +0 -54
- package/dist/server/durable/durable-agent-service.js +5 -23
- package/dist/server/durable/durable-driver.js +12 -73
- package/dist/server/durable/durable-event-projector.js +1 -50
- package/dist/server/durable/durable-loader.js +0 -12
- package/dist/server/durable/durable-models.js +11 -80
- package/dist/server/durable/durable-storage.js +1 -17
- package/dist/server/durable/durable-tools.js +2 -20
- package/dist/server/durable/index.js +0 -3
- package/dist/server/edit-soft-tool.js +2 -81
- package/dist/server/engine-capabilities.js +0 -13
- package/dist/server/engine-catalog.js +74 -0
- package/dist/server/engine-cli.js +89 -0
- package/dist/server/engine-probe.js +35 -217
- package/dist/server/ensure-bash.js +2 -28
- package/dist/server/eval-tool.js +1 -50
- package/dist/server/evidence-tool-hooks.js +0 -2
- package/dist/server/file-archives.js +0 -10
- package/dist/server/file-save.js +1 -12
- package/dist/server/file-transfer-routes.js +0 -11
- package/dist/server/files-service.js +18 -271
- package/dist/server/global-loader.js +9 -89
- package/dist/server/goal-evidence.js +1 -35
- package/dist/server/goal-review-gate.js +0 -58
- package/dist/server/goal-service.js +19 -422
- package/dist/server/hashline-engine.js +8 -112
- package/dist/server/host-guard.js +0 -24
- package/dist/server/host-metrics.js +0 -6
- package/dist/server/http-proxy.js +1 -7
- package/dist/server/i18n.js +5 -72
- package/dist/server/icon-svg.js +0 -15
- package/dist/server/index.js +199 -677
- package/dist/server/json-utils.js +0 -12
- package/dist/server/launch-origin.js +0 -44
- package/dist/server/left-panel-running.js +0 -9
- package/dist/server/load-timing.js +1 -4
- package/dist/server/load-tools-tool.js +0 -20
- package/dist/server/locales.js +1 -46
- package/dist/server/lsp-tool.js +13 -126
- package/dist/server/managed.js +0 -48
- package/dist/server/marker-service.js +1 -22
- package/dist/server/markers/builtins/action.js +0 -19
- package/dist/server/markers/builtins/notify.js +1 -9
- package/dist/server/markers/builtins/rename.js +0 -13
- package/dist/server/markers/index.js +0 -3
- package/dist/server/markers/marker.js +0 -13
- package/dist/server/markers/registry.js +0 -3
- package/dist/server/markers/store.js +1 -12
- package/dist/server/market-service.js +7 -43
- package/dist/server/mcp-agent-tool.js +0 -10
- package/dist/server/mcp-bridge.js +6 -138
- package/dist/server/mcp-hot-reload.js +0 -25
- package/dist/server/mcp-manager.js +2 -44
- package/dist/server/mcp-oauth-login.js +0 -2
- package/dist/server/mcp-oauth-ui.js +1 -4
- package/dist/server/mcp-oauth.js +5 -79
- package/dist/server/mcp-project-runtime.js +0 -4
- package/dist/server/message-deletion.js +0 -2
- package/dist/server/message-entry-resolver.js +0 -8
- package/dist/server/message-window.js +0 -71
- package/dist/server/mobile-notification-events.js +16 -0
- package/dist/server/mobile-origin.js +79 -0
- package/dist/server/mobile-push.js +523 -0
- package/dist/server/model-admin.js +19 -358
- package/dist/server/model-enrich.js +0 -19
- package/dist/server/model-resolver.js +2 -61
- package/dist/server/native-cli-discovery.js +115 -0
- package/dist/server/native-cli-model.js +71 -0
- package/dist/server/native-cli-references.js +214 -0
- package/dist/server/native-cli-remote-cleanup.js +58 -0
- package/dist/server/native-cli-remote-files.js +282 -0
- package/dist/server/native-cli-routes.js +68 -0
- package/dist/server/native-cli-runtime.js +1 -0
- package/dist/server/native-cli-session-hooks.js +170 -0
- package/dist/server/native-cli-session.js +585 -0
- package/dist/server/native-cli-state.js +82 -0
- package/dist/server/native-cli.js +210 -0
- package/dist/server/net-guard.js +9 -71
- package/dist/server/office-parse.js +0 -50
- package/dist/server/orphan-manager.js +0 -18
- package/dist/server/patch-bash-process.js +0 -4
- package/dist/server/patch-executable-lookup.js +0 -77
- package/dist/server/patch-node-pty.js +6 -45
- package/dist/server/patch-remote-catalog.js +4 -34
- package/dist/server/patch-tool.js +0 -15
- package/dist/server/payload-limits.js +0 -5
- package/dist/server/pending-question.js +0 -5
- package/dist/server/permission-preset.js +4 -33
- package/dist/server/persona-chain.js +0 -26
- package/dist/server/pkg-info.js +1 -17
- package/dist/server/plan-manager.js +2 -49
- package/dist/server/plan-mode.js +0 -97
- package/dist/server/plan-update-tool.js +1 -15
- package/dist/server/plugin-api-catalog.js +6 -4
- package/dist/server/plugin-assets.js +1 -35
- package/dist/server/plugin-bundled.js +68 -0
- package/dist/server/plugin-catalog-sync.js +0 -37
- package/dist/server/plugin-catalog.js +13 -67
- package/dist/server/plugin-chat-attachments.js +0 -1
- package/dist/server/plugin-conversation-view.js +0 -20
- package/dist/server/plugin-dom.js +1 -23
- package/dist/server/plugin-facilities.js +4 -115
- package/dist/server/plugin-grants.js +2 -90
- package/dist/server/plugin-install-spec.js +0 -43
- package/dist/server/plugin-installer.js +34 -75
- package/dist/server/plugin-llm.js +4 -38
- package/dist/server/plugin-manifest-validate.js +0 -31
- package/dist/server/plugin-permissions.js +1 -24
- package/dist/server/plugin-project.js +7 -129
- package/dist/server/plugin-removal.js +1 -8
- package/dist/server/plugin-schedule.js +1 -38
- package/dist/server/plugin-secrets.js +3 -16
- package/dist/server/plugin-tool-guard.js +1 -28
- package/dist/server/plugin-ui-slots.js +0 -4
- package/dist/server/plugin-updater.js +15 -90
- package/dist/server/plugins.js +71 -619
- package/dist/server/present-files-tool.js +0 -57
- package/dist/server/preset-fields.js +24 -61
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +4 -172
- package/dist/server/process-utils.js +4 -80
- package/dist/server/prompt-assembler.js +2 -30
- package/dist/server/prompt-base-store.js +0 -47
- package/dist/server/prompt-composer.js +21 -98
- package/dist/server/prompt-templates.js +0 -2
- package/dist/server/protocol-version.js +1 -11
- package/dist/server/protocol.js +0 -5
- package/dist/server/queue-modes.js +0 -3
- package/dist/server/queue-utils.js +0 -40
- package/dist/server/quick-ask-context.js +384 -0
- package/dist/server/quick-ask-settings.js +61 -0
- package/dist/server/quick-ask.js +260 -0
- package/dist/server/read-tool.js +0 -65
- package/dist/server/reasoning-registry.js +1 -29
- package/dist/server/remote-cli-persistence.js +373 -0
- package/dist/server/remote-native-cli.js +78 -0
- package/dist/server/remote-ssh-service.js +481 -190
- package/dist/server/request-context.js +0 -9
- package/dist/server/resolve-global-sdk.js +55 -31
- package/dist/server/sandbox-data.js +0 -1
- package/dist/server/sandbox-engines.js +0 -1
- package/dist/server/sandbox-runtime-gate.js +0 -3
- package/dist/server/sandbox-service.js +0 -41
- package/dist/server/sandbox-tool.js +0 -20
- package/dist/server/schedule-agent-tool.js +2 -31
- package/dist/server/scheduler-tasks.js +32 -56
- package/dist/server/scm-commitmsg.js +0 -53
- package/dist/server/scm.js +3 -48
- package/dist/server/sdk-builtin-extensions.js +2 -29
- package/dist/server/sdk-origin.js +0 -45
- package/dist/server/serialize.js +2 -92
- package/dist/server/server-config.js +0 -11
- package/dist/server/session-branch.js +1 -87
- package/dist/server/session-list-scan.js +215 -0
- package/dist/server/session-open.js +69 -0
- package/dist/server/session-parser.js +4 -54
- package/dist/server/session-scan.js +81 -45
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +19 -126
- package/dist/server/setup-config.js +0 -2
- package/dist/server/setup-page.js +0 -9
- package/dist/server/skill-content-filler.js +0 -17
- package/dist/server/skill-discovery.js +5 -92
- package/dist/server/skill-maintenance.js +1 -28
- package/dist/server/skill-tool.js +0 -30
- package/dist/server/slash-commands.js +5 -50
- package/dist/server/soft-cap.js +3 -40
- package/dist/server/startup-banner.js +0 -8
- package/dist/server/subagent-handoff.js +0 -11
- package/dist/server/subagent-helpers.js +2 -17
- package/dist/server/subagent-notify.js +0 -19
- package/dist/server/subagent-security-gate.js +0 -50
- package/dist/server/subagent-task.js +0 -9
- package/dist/server/subagent-templates-hant.js +0 -10
- package/dist/server/subagent-templates.js +3 -103
- package/dist/server/subagents.js +1 -87
- package/dist/server/system-screenshot-windows.js +259 -0
- package/dist/server/system-screenshot.js +77 -0
- package/dist/server/tabs.js +3 -48
- package/dist/server/terminals.js +559 -586
- package/dist/server/text-quote.js +0 -12
- package/dist/server/text-sniff.js +2 -52
- package/dist/server/themes.js +2 -41
- package/dist/server/tool-approval.js +0 -47
- package/dist/server/tool-guards.js +0 -90
- package/dist/server/tool-host-factories.js +1 -16
- package/dist/server/tool-info.js +0 -13
- package/dist/server/tool-manager.js +1 -229
- package/dist/server/tool-overrides.js +1 -46
- package/dist/server/tool-prompt-overrides.js +1 -30
- package/dist/server/tool-prompts.js +0 -14
- package/dist/server/tool-signature.js +0 -25
- package/dist/server/transcript-prepare.js +55 -0
- package/dist/server/tts-routes.js +58 -0
- package/dist/server/tts-service.js +106 -0
- package/dist/server/tts-system.js +160 -0
- package/dist/server/turn-timing.js +0 -1
- package/dist/server/unauthorized-page.js +0 -8
- package/dist/server/universal/driver-base.js +2 -31
- package/dist/server/universal/drivers/claude-code.js +98 -194
- package/dist/server/universal/drivers/codex.js +12 -35
- package/dist/server/universal/drivers/mock-driver.js +1 -11
- package/dist/server/universal/index.js +0 -3
- package/dist/server/universal/session-store.js +4 -21
- package/dist/server/universal/universal-attachments.js +2 -36
- package/dist/server/universal/universal-service.js +5 -24
- package/dist/server/universal/universal-session.js +30 -148
- package/dist/server/universal/universal-types.js +0 -3
- package/dist/server/update-check.js +6 -182
- package/dist/server/uploads.js +4 -43
- package/dist/server/virtual-tui.js +2 -27
- package/dist/server/vision-bridge.js +0 -27
- package/dist/server/wait-subscription-scan.js +13 -115
- package/dist/server/webui-context.js +2 -87
- package/dist/server/workspace-handle.js +373 -0
- package/dist/server/workspace-snapshot.js +7 -113
- package/dist/server/worktree-service.js +2 -53
- package/dist/server/worktree-tool.js +0 -11
- package/dist/server/ws-client-id.js +0 -18
- package/dist/server/ws-pending-queue.js +0 -7
- package/dist/server/ws-unknown-types.js +0 -17
- package/docs/README.md +24 -17
- package/docs/architecture-plugins.md +55 -6
- package/docs/device-center.md +57 -23
- package/docs/device-desktop.md +3 -3
- package/docs/group-orchestration.md +142 -0
- package/docs/hub-upgrade-release-testing.md +46 -0
- package/extensions/webui.ts +3 -74
- package/package.json +9 -6
- package/plugin-sdk/README.md +22 -8
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +26 -0
- package/plugin-sdk/client.mjs +52 -0
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +128 -117
- package/plugin-sdk/index.mjs +2 -687
- package/plugin-sdk/package.json +15 -4
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +9 -0
- package/plugin-sdk/testing.mjs +511 -0
- package/plugins/catalog.json +52 -4
- package/plugins/superagent/README.md +110 -0
- package/plugins/superagent/client/entry.mjs +21 -0
- package/plugins/superagent/index.mjs +8 -0
- package/plugins/superagent/main.mjs +218 -0
- package/plugins/superagent/manifest.json +15 -0
- package/plugins/superagent/server.mjs +572 -0
- package/plugins/superagent/style.css +167 -0
- package/themes/aetheris.css +1 -31
- package/themes/ayu-light.css +0 -1
- package/themes/bases/flow-base.css +2 -83
- package/themes/bases/obsidian-base.css +2 -37
- package/themes/bases/statusbar-flat-base.css +0 -1
- package/themes/bases/zhujian-base.css +0 -63
- package/themes/bases/zhupi-base.css +0 -64
- package/themes/catppuccin-latte.css +0 -1
- package/themes/catppuccin.css +0 -1
- package/themes/claude-code-dark.css +0 -1
- package/themes/codex.css +0 -1
- package/themes/dark-teal.css +22 -54
- package/themes/everforest-light.css +0 -1
- package/themes/flow-cristallo.css +160 -0
- package/themes/flow-ink.css +160 -0
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +160 -0
- package/themes/flow-zurich.css +160 -0
- package/themes/flow.css +1 -9
- package/themes/geist.css +0 -1
- package/themes/gruvbox-light.css +0 -1
- package/themes/kanagawa-lotus.css +0 -1
- package/themes/md-preview.css +1 -2
- package/themes/mist.css +0 -1
- package/themes/nord.css +0 -1
- package/themes/one-dark.css +0 -1
- package/themes/paper.css +0 -1
- package/themes/rose-pine-dawn.css +0 -1
- package/themes/sakura.css +0 -1
- package/themes/solarized-light.css +0 -1
- package/themes/tokyo-night.css +0 -1
- package/themes/translucent.css +4 -35
- package/themes/transparent.css +4 -41
- package/themes/vs-code-dark.css +0 -1
- package/themes/wallpaper-flow.css +3 -17
- package/themes/wallpaper-obsidian.css +1 -4
- package/themes/white.css +0 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BDoOpj-F.js → BgTasksModal-D-x7kA63.js} +1 -1
- package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
- package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
- package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
- package/web/dist/assets/{Dropdown-C4LIhshN.js → Dropdown-CTgVLUbp.js} +1 -1
- package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
- package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
- package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
- package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
- package/web/dist/assets/{HintTip-c6d0TJoh.js → HintTip-Da6qc566.js} +1 -1
- package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
- package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
- package/web/dist/assets/{PiSetupModal-BmMrrgB9.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/SCMPanel-CuEgzAlO.js +2 -0
- package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
- package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
- package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
- package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
- package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
- package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
- package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
- package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
- package/web/dist/assets/index-CQc3VrWa.css +1 -0
- package/web/dist/assets/index-D_AGu4Zv.js +404 -0
- package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
- package/web/dist/assets/{remote-ssh-client-CfYSMEZg.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +12 -11
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/dist/gh-comment-781.md +0 -5
- package/dist/server/device-center/local-page.js +0 -17
- package/dist/server/device-center/smoke-preview.js +0 -3
- package/dist/server/durable/durable-capabilities.js +0 -11
- package/dist/server/markers/builtins/services.js +0 -123
- package/dist/server/markers/builtins/todo.js +0 -189
- package/dist/server/markers-list-tool.js +0 -34
- package/dist/server/orchestrator.js +0 -109
- package/dist/server/patch-turn-end-boundary.js +0 -77
- package/dist/server/system-prompt-soul.js +0 -41
- package/dist/server/univer-service.js +0 -448
- package/dist/server/universal/drivers/dsh-driver.js +0 -379
- package/dist/test-artifact.md +0 -9
- package/dist/test-preview-modal.md +0 -11
- package/dist/test-report.html +0 -20
- package/web/dist/assets/BgTasksModal-C0i3O1FT.js +0 -1
- package/web/dist/assets/CanvasStudio-B8thymBN.js +0 -1579
- package/web/dist/assets/CanvasStudio-zSxyIx1R.js +0 -1579
- package/web/dist/assets/DeviceCenter-DfAHKcid.js +0 -3
- package/web/dist/assets/DeviceCenter-ydvOTlzE.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-q5Ik8oXg.js +0 -1
- package/web/dist/assets/DeviceGroups-CI14_SRb.js +0 -1
- package/web/dist/assets/DeviceGroups-DvsB5IEU.js +0 -1
- package/web/dist/assets/FilePreview-BgGongmv.js +0 -2
- package/web/dist/assets/FilePreview-D4NrhF-U.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BWgU8yPd.js +0 -1
- package/web/dist/assets/GlobalSearchModal-F7fNimKk.js +0 -1
- package/web/dist/assets/GroupConversation-Dh71Pdb-.js +0 -17
- package/web/dist/assets/GroupConversation-ZK3nRmNm.js +0 -17
- package/web/dist/assets/ModelConfigModal-YVEgyy34.js +0 -2
- package/web/dist/assets/ModelConfigModal-vWtg3srp.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-BGSBIKD7.js +0 -1
- package/web/dist/assets/SCMPanel-B8_EDxNr.js +0 -2
- package/web/dist/assets/SCMPanel-BU58qk3T.js +0 -2
- package/web/dist/assets/SettingsModal-CMUybq3J.js +0 -32
- package/web/dist/assets/SettingsModal-OBmGTh-5.js +0 -32
- package/web/dist/assets/TerminalPanel-0CYvD72B.js +0 -3
- package/web/dist/assets/TerminalPanel-DDavKvFr.js +0 -3
- package/web/dist/assets/TuiOverlayModal-BsA-QTvN.js +0 -1
- package/web/dist/assets/TuiOverlayModal-DzoVQBuG.js +0 -1
- package/web/dist/assets/app-globals-CZxzGvIo.js +0 -123
- package/web/dist/assets/canvas-client-CUnXlQYX.js +0 -1
- package/web/dist/assets/desktop-aAKpvKJV.js +0 -1
- package/web/dist/assets/index-C6DwztqE.css +0 -1
- package/web/dist/assets/index-CuN802Sj.js +0 -93
- package/web/dist/assets/index-EH5Fw9fa.js +0 -93
- package/web/dist/assets/plugin-host-BRWib9DF.js +0 -1
- package/web/dist/assets/theme-D2l_mLNo.js +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,An as r,Cn as i,H as a,Ht as o,Pn as s,Pt as ee,Qt as te,Sn as ne,Ut as c,Z as l,fn as u,gt as d,kt as f,mn as p,on as m,pt as h,wn as g,xt as re,zn as _}from"./app-globals-CZjFtI4F.js";import{i as v,t as ie}from"./react-CR5VJ85Q.js";import{K as y,Xt as b,bt as x,v as S}from"./index-D_AGu4Zv.js";import{t as C}from"./DeviceExecutionSettings-BoX7-0h7.js";import{n as w,t as ae}from"./GroupWorkItems-BIvZtr10.js";var T=e(v(),1);async function E(e,t){let n=t.sleep??(e=>new Promise(t=>setTimeout(t,e))),r=Date.now()+(t.timeoutMs??18e5),i=e;if(!i||typeof i.id!=`string`||typeof i.fromBootId!=`string`)throw Error(`Invalid Hub upgrade response`);for(;;){if(t.isCurrent&&!t.isCurrent())throw new DOMException(`Hub upgrade view closed`,`AbortError`);if(i.id!==e.id)throw Error(`Hub upgrade job changed`);if(i.state===`failed`)throw Error(i.error||`Hub upgrade failed`);if(i.state===`succeeded`){if(!i.targetVersion||i.version!==i.targetVersion||!i.bootId||i.bootId===e.fromBootId)throw Error(`Hub upgrade result does not match the new version and process`);return i}if(i.state!==`queued`&&i.state!==`running`)throw Error(`Invalid Hub upgrade state`);if(Date.now()>=r)throw Error(`Hub upgrade timed out; inspect the Hub upgrade log`);if(await n(1500),t.isCurrent&&!t.isCurrent())throw new DOMException(`Hub upgrade view closed`,`AbortError`);try{i=await t.poll(e.id)}catch(e){let t=e.status;if(t&&t<500)throw e}}}var D=ie();function O(e){return!!e&&`mount`in e&&typeof e.mount==`function`}function k({plugin:e,epoch:t,onManageGroups:n}){let a=r(i()),[o,s]=(0,T.useState)(null),[ee,te]=(0,T.useState)(!1),[ne,c]=(0,T.useState)(0),{id:l,name:u,version:d,hasClient:f,error:p,isolated:m}=e??{},h=(0,T.useMemo)(()=>l?{id:l,name:u??l,version:d,hasClient:f??!1,error:p,isolated:m}:void 0,[l,u,d,f,p,m]);(0,T.useEffect)(()=>{let e=!1;if(s(null),te(!1),h&&!h.error&&h.hasClient)return y(h,t,{retry:ne>0}).then(t=>{e||(O(t)?s({info:h,module:t}):te(!0))}),()=>{e=!0}},[h,t,ne]);let g=!h||!h.hasClient;return(0,D.jsxs)(`section`,{className:`dc-card`,"aria-label":a?`外部渠道配置`:`External channel settings`,children:[(0,D.jsxs)(`header`,{className:`dc-card-header`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{children:a?`GitHub / 飞书渠道`:`GitHub / Feishu channels`}),(0,D.jsx)(`p`,{children:a?`将外部事件映射到群组,由群组 AI 分派任务并跟进工单。`:`Map external events to a group. Its AI delegates tasks and follows up on work items.`})]}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button`,onClick:n,children:a?`管理群组与 AI`:`Manage groups & AI`})]}),g?(0,D.jsx)(`p`,{role:`status`,children:a?`内置渠道模块暂不可用,请重新加载页面或重启主程序。`:`The built-in channel module is temporarily unavailable. Reload this page or restart the application.`}):h.error?(0,D.jsx)(`p`,{className:`dc-notice is-error`,role:`alert`,children:h.error}):ee?(0,D.jsxs)(`div`,{className:`dc-notice is-error`,role:`alert`,children:[(0,D.jsx)(`span`,{children:a?`渠道配置界面加载失败。`:`Channel settings failed to load.`}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button`,onClick:()=>c(e=>e+1),children:a?`重试`:`Retry`})]}):o?(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,minWidth:0,height:`min(72vh, 900px)`,minHeight:`360px`},children:(0,D.jsx)(S,{entry:o})}):(0,D.jsx)(`p`,{role:`status`,children:a?`正在加载渠道配置…`:`Loading channel settings…`})]})}function A({href:e,children:t}){let n=g(),[r,i]=(0,T.useState)(!1),[a,o]=(0,T.useState)(!1);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`a`,{className:`dc-button`,href:e,target:`_blank`,rel:`noopener noreferrer`,onClick:t=>{let n=window.piDesktop;n?.openHub&&(t.preventDefault(),!a&&(o(!0),i(!1),n.openHub(e).then(e=>i(!e),()=>i(!0)).finally(()=>o(!1))))},"aria-busy":a,children:t}),r&&(0,D.jsxs)(`span`,{role:`alert`,children:[n(`deviceHubNetworkError`),` `,(0,D.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:e})]})]})}function j(e){if(!M(e.host)||!Number.isInteger(e.port)||e.port<1024||e.port>65535||e.publicUrl.length>2048||/[\s\u0000-\u001f\u007f]/.test(e.publicUrl))return!1;try{let t=new URL(e.publicUrl);return[`http:`,`https:`].includes(t.protocol)&&!!t.hostname&&!t.username&&!t.password&&!t.search&&!t.hash&&t.pathname===`/`&&![`0.0.0.0`,`[::]`].includes(t.hostname)}catch{return!1}}function M(e){if(e===`localhost`)return!0;if(/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e))return e.split(`.`).every(e=>String(Number(e))===e&&Number(e)<=255);if(!e.includes(`:`)||!/^[0-9a-fA-F:.]+$/.test(e))return!1;try{return new URL(`http://[${e}]/`).hostname.startsWith(`[`)}catch{return!1}}function oe(e){try{let t=new URL(e);return[`http:`,`https:`].includes(t.protocol)&&[`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname)}catch{return!1}}var N=`https://raw.githubusercontent.com/xing-shuyin/pi-web-ui/main/docs/device-center-deployment.md`,P=`https://github.com/xing-shuyin/pi-web-ui/blob/main/docs/device-center-deployment.md`,se=`pi-web-ui hub install --host 0.0.0.0 --port 8790 --public-url http://SERVER_IP:8790 --allow-registration`;function F(e){let t=e=>e.includes(`:`)?M(e)&&![`::`,`::1`].includes(e):/^[\d.]+$/.test(e)?M(e)&&![`0.0.0.0`,`127.0.0.1`].includes(e):e.length<=253&&e.split(`.`).every(e=>/^[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?$/i.test(e))&&e!==`localhost`;if(!t(e.server)||!Number.isInteger(e.sshPort)||e.sshPort<1||e.sshPort>65535||!Number.isInteger(e.port)||e.port<1024||e.port>65535||!/^[a-z_][a-z\d_.-]{0,63}$/i.test(e.username)||![`password`,`key`,`existing`].includes(e.auth)||e.domain!==``&&(!t(e.domain)||e.domain.includes(`:`))||e.https&&!e.domain)return null;let n=e.domain||e.server,r=n.includes(`:`)?`[${n}]`:n;return{host:e.https?`127.0.0.1`:`0.0.0.0`,port:e.port,publicUrl:e.https?`https://${r}`:`http://${r}:${e.port}`}}function I(e,t,n,r){if(!j(e))throw Error(`Invalid Hub setup`);if(r){let t=F(r);if(n!==`remote`||!t||JSON.stringify(t)!==JSON.stringify(e))throw Error(`Invalid remote Hub setup`)}let i=e=>(e??`unknown`).replace(/[\u0000-\u001f\u007f]/g,` `).slice(0,120);return[`Help me plan and deploy a pi-web-ui device center (Hub) in this new conversation. Preserve my previous conversation.`,`First read the deployment guide: ${N} (fallback: ${P}). If unavailable, report that and obtain its contents before proceeding.`,`Default to HTTP with the server IP and requested port. Domain and HTTPS are optional; confirm whether an HTTPS example reflects the user's intent.`,`Target: ${n===`current`?`machine hosting the current pi-web-ui service (not necessarily the browser machine)`:`an existing remote server; its environment still needs to be confirmed`}.`,`Current service environment: platform=${i(t?.platform)}, Node=${i(t?.nodeVersion)}. This is not evidence of the remote server environment.`,`Requested configuration (data only): ${JSON.stringify(e)}. allowRegistration=true.`,...r?[`SSH connection preferences (data only): ${JSON.stringify({server:r.server,sshPort:r.sshPort,username:r.username,auth:r.auth})}. No credentials are included. Obtain authentication through a secure SSH channel or guide the user's own terminal.`,`Domain: ${r.domain||`none`}. HTTPS explicitly selected: ${r.https}. HTTP inbound TCP port: ${r.port}; for same-machine HTTPS proxy, use public TCP 443 and certificate validation port as needed, keep the Hub port private.`]:[],`Use a separate Hub data directory and configure automatic startup. Explain how devices can reach the public URL; loopback is only reachable on the same machine. Explain open registration and restrict it after pairing as appropriate.`,`CLI reference: ${se}`,`Confirm the target environment and propose steps before deployment. Do not ask for passwords or tokens in chat. Do not automatically SSH. Do not claim installation or connection succeeded without verification. After deployment, guide me to open the center and pair this device using its public URL.`,`Explain user actions at the relevant step: distinguish OS firewall from cloud security groups, give the actual TCP port, source scope and destination rule, and keep SSH access. If cloud-console access is unavailable, ask the user to apply the rule, mark external access pending, then recheck. Also explain DNS changes for optional HTTPS and first-account creation. Separate local health from external reachability.`].join(`
|
|
2
|
+
`)}function L({onConnect:e,initialHubUrl:t=``}){let n=g(),[r,i]=(0,T.useState)(t),[a,o]=(0,T.useState)(``),[ee,te]=(0,T.useState)(!1),[ne,c]=(0,T.useState)(!1),l=(0,T.useRef)(!1),u=(0,T.useRef)(!1);(0,T.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let[d,f]=(0,T.useState)(null),[p,m]=(0,T.useState)(`current`),[h,re]=(0,T.useState)(null),[v,ie]=(0,T.useState)(`127.0.0.1`),[y,b]=(0,T.useState)(`8790`),[x,S]=(0,T.useState)(`http://127.0.0.1:8790`),[C,w]=(0,T.useState)({server:``,sshPort:22,username:`root`,auth:`password`,port:8790,domain:``,https:!1}),ae=F(C),[E,O]=(0,T.useState)(!1),[k,M]=(0,T.useState)(!1),[N,P]=(0,T.useState)(null),[se,L]=(0,T.useState)(!1),[R,ce]=(0,T.useState)(!1),[z,B]=(0,T.useState)(!1),[V,H]=(0,T.useState)(null),U=(0,T.useRef)(null),W=(0,T.useRef)(!1),G=oe(window.location.origin);(0,T.useEffect)(()=>()=>U.current?.abort(),[]);let K=async()=>{if(W.current)return;U.current?.abort();let e=new AbortController;U.current=e,L(!1),ce(!1),B(!1);try{let t=await fetch(_(s(`/api/device-center/setup`)),{credentials:`same-origin`,signal:e.signal});if(!t.ok)throw Error();let n=await t.json();if(!n||typeof n.platform!=`string`||typeof n.nodeVersion!=`string`||typeof n.dataDir!=`string`||typeof n.cliPath!=`string`||!j({host:`127.0.0.1`,port:n.defaultPort,publicUrl:n.defaultPublicUrl}))throw Error();if(e.signal.aborted)return;re(n),n.installation?.installed?(ie(n.installation.host??`127.0.0.1`),b(String(n.installation.port)),S(n.installation.publicUrl??``),i(n.installation.publicUrl??``)):h||(b(String(n.defaultPort)),S(n.defaultPublicUrl))}catch{e.signal.aborted||(L(!0),B(!0))}finally{e.signal.aborted||ce(!0)}},q=async()=>{let e={host:v,port:Number(y),publicUrl:x};if(W.current||!G||!h||!R||z||h.busy||h.installation?.installed||!j(e))return;W.current=!0,U.current?.abort(),O(!0),L(!1),o(``);let t=new AbortController;U.current=t;try{let n=await fetch(_(s(`/api/device-center/setup`)),{credentials:`same-origin`,method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,allowRegistration:!0}),signal:t.signal});if(n.status===409){re(e=>e&&{...e,busy:!0}),W.current=!1,O(!1),await K();return}if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(typeof e.error==`string`?e.error.slice(0,4096):`HTTP ${n.status}`)}let r=await n.json();if(!j({...e,publicUrl:r.publicUrl})||typeof r.output!=`string`)throw Error();t.signal.aborted||H(r)}catch(e){t.signal.aborted||(L(!0),o(e instanceof Error?e.message.slice(0,4096):``))}finally{W.current=!1,t.signal.aborted||O(!1)}},le=async()=>{if(W.current||!G||!h||!R||z||h.busy||E||k)return;W.current=!0,U.current?.abort(),M(!0),L(!1),o(``),P(null);let e=new AbortController;U.current=e;try{let t=await fetch(_(s(`/api/device-center/setup/update`)),{credentials:`same-origin`,method:`POST`,headers:{"Content-Type":`application/json`},signal:e.signal});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(typeof e.error==`string`?e.error.slice(0,4096):`HTTP ${t.status}`)}let r=await t.json();e.signal.aborted||(P(r.output||n(`deviceSetupUpdateSuccess`)),await K())}catch(t){e.signal.aborted||(L(!0),o(t instanceof Error?t.message.slice(0,4096):``))}finally{W.current=!1,e.signal.aborted||M(!1)}},J=h?.installation,ue=!!J?.installed,de=ue&&J.running&&J.owned,Y=p===`remote`?ae:{host:v,port:Number(y),publicUrl:x},X=!!Y&&j(Y);return(0,D.jsxs)(`section`,{className:`dc-onboarding`,children:[(0,D.jsx)(`h3`,{children:n(`deviceSetupWelcome`)}),(0,D.jsx)(`p`,{children:n(`deviceSetupIntro`)}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[(0,D.jsx)(`button`,{className:`dc-button`,disabled:E,"aria-pressed":d===`connect`,onClick:()=>f(`connect`),children:n(`deviceSetupConnect`)}),(0,D.jsx)(`button`,{className:`dc-button`,disabled:E,"aria-pressed":d===`create`,onClick:()=>{f(`create`),!h&&G&&K()},children:n(`deviceSetupCreate`)})]}),d===`connect`&&(0,D.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),e(r.trim())},children:[(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceHubHubUrl`)}),(0,D.jsx)(`input`,{type:`url`,required:!0,maxLength:2048,value:r,onChange:e=>i(e.target.value),placeholder:`https://hub.example.com`})]}),(0,D.jsx)(`button`,{className:`dc-button is-primary`,disabled:!j({host:`localhost`,port:8790,publicUrl:r.trim()}),children:n(`deviceSetupPair`)})]}),d===`create`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceSetupTarget`)}),(0,D.jsxs)(`select`,{disabled:E,value:p,onChange:e=>m(e.target.value),children:[(0,D.jsx)(`option`,{value:`current`,children:n(`deviceSetupCurrent`)}),(0,D.jsx)(`option`,{value:`remote`,children:n(`deviceSetupRemote`)})]})]}),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`p`,{children:n(p===`current`?`deviceSetupCurrentHint`:`deviceSetupRemoteHint`)}),p===`current`&&(0,D.jsxs)(`div`,{className:`dc-setup-plan`,children:[(0,D.jsx)(`strong`,{children:n(`deviceSetupPlan`)}),(0,D.jsx)(`p`,{children:n(`deviceSetupPlanHint`)}),h&&(0,D.jsxs)(`dl`,{children:[(0,D.jsx)(`dt`,{children:n(`deviceSetupEnvironment`)}),(0,D.jsxs)(`dd`,{children:[h.platform,` · Node `,h.nodeVersion]}),(0,D.jsx)(`dt`,{children:n(`deviceSetupDataDir`)}),(0,D.jsx)(`dd`,{children:h.dataDir}),(0,D.jsx)(`dt`,{children:n(`deviceSetupCli`)}),(0,D.jsx)(`dd`,{children:h.cliPath})]}),!G&&(0,D.jsx)(`p`,{role:`status`,children:n(`deviceSetupLocalOnly`)}),(0,D.jsx)(`p`,{children:n(`deviceSetupBackground`)}),ue&&(0,D.jsxs)(`div`,{role:`status`,children:[(0,D.jsx)(`h4`,{children:n(de?`deviceSetupRestored`:`deviceSetupUnhealthy`)}),(0,D.jsx)(`p`,{children:J.publicUrl}),de&&X&&J.publicUrl?(0,D.jsxs)(`div`,{className:`dc-actions`,children:[(0,D.jsx)(A,{href:J.publicUrl,children:n(`deviceHubOpenHub`)}),(0,D.jsx)(`button`,{className:`dc-button`,onClick:()=>e(J.publicUrl),children:n(`deviceSetupPair`)}),G&&(0,D.jsx)(`button`,{className:`dc-button`,disabled:E||k,onClick:()=>void le(),children:n(k?`deviceSetupUpdating`:`deviceSetupUpdate`)})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`p`,{children:n(`deviceSetupRecovery`)}),(0,D.jsx)(`pre`,{className:`dc-setup-output`,children:`pi-web-ui hub status --json
|
|
3
|
+
pi-web-ui hub --help`}),G&&(0,D.jsx)(`button`,{className:`dc-button is-primary`,disabled:E||k,onClick:()=>void le(),children:n(k?`deviceSetupUpdating`:`deviceSetupUpdate`)})]}),N&&(0,D.jsx)(`pre`,{className:`dc-setup-output`,children:N.slice(0,16e3)})]}),h?.busy&&(0,D.jsx)(`p`,{role:`status`,children:n(`deviceSetupBusy`)}),G&&(0,D.jsx)(`button`,{className:`dc-button`,disabled:E||!R,onClick:()=>void K(),children:n(R?`deviceSetupRetry`:`deviceHubWorking`)})]}),p===`remote`?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`dc-setup-fields`,children:[(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceSetupServer`)}),(0,D.jsx)(`input`,{autoComplete:`off`,maxLength:253,placeholder:`203.0.113.10`,value:C.server,onChange:e=>w({...C,server:e.target.value.trim()})})]}),(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceSetupSshPort`)}),(0,D.jsx)(`input`,{type:`number`,min:1,max:65535,value:C.sshPort,onChange:e=>w({...C,sshPort:Number(e.target.value)})})]}),(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceSetupUsername`)}),(0,D.jsx)(`input`,{autoComplete:`off`,maxLength:64,value:C.username,onChange:e=>w({...C,username:e.target.value})})]}),(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceSetupAuth`)}),(0,D.jsxs)(`select`,{value:C.auth,onChange:e=>w({...C,auth:e.target.value}),children:[(0,D.jsx)(`option`,{value:`password`,children:n(`deviceSetupAuthPassword`)}),(0,D.jsx)(`option`,{value:`key`,children:n(`deviceSetupAuthKey`)}),(0,D.jsx)(`option`,{value:`existing`,children:n(`deviceSetupAuthExisting`)})]})]}),(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceSetupServicePort`)}),(0,D.jsx)(`input`,{type:`number`,min:1024,max:65535,value:C.port,onChange:e=>w({...C,port:Number(e.target.value)})})]})]}),(0,D.jsx)(`p`,{children:n(`deviceSetupCredentialHint`)}),(0,D.jsxs)(`details`,{children:[(0,D.jsx)(`summary`,{children:n(`deviceSetupOptionalTls`)}),(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceSetupDomain`)}),(0,D.jsx)(`input`,{maxLength:253,placeholder:`hub.example.com`,value:C.domain,onChange:e=>w({...C,domain:e.target.value.trim()})})]}),(0,D.jsxs)(`label`,{children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:C.https,onChange:e=>w({...C,https:e.target.checked})}),` `,n(`deviceSetupEnableHttps`)]}),(0,D.jsx)(`p`,{children:n(`deviceSetupTlsHint`)})]}),(0,D.jsxs)(`p`,{children:[(0,D.jsx)(`strong`,{children:n(`deviceSetupPreview`)}),` `,ae?.publicUrl??n(`deviceSetupPreviewEmpty`)]}),(0,D.jsxs)(`div`,{className:`dc-setup-plan`,children:[(0,D.jsx)(`strong`,{children:n(`deviceSetupUserActions`)}),(0,D.jsx)(`p`,{children:n(`deviceSetupCloudPorts`).replace(`{ports}`,C.https?`443 / 80`:String(C.port))}),(0,D.jsx)(`p`,{children:n(`deviceSetupSourceScope`)}),(0,D.jsx)(`p`,{children:n(`deviceSetupAfterStart`)})]}),(0,D.jsx)(`a`,{href:`https://github.com/xing-shuyin/pi-web-ui/blob/main/docs/device-center-deployment.md`,target:`_blank`,rel:`noopener noreferrer`,children:n(`deviceSetupGuide`)})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`dc-setup-fields`,children:[(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceSetupHost`)}),(0,D.jsx)(`input`,{disabled:E||!!V,maxLength:253,value:v,onChange:e=>ie(e.target.value)})]}),(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceSetupPort`)}),(0,D.jsx)(`input`,{disabled:E||!!V,type:`number`,min:1024,max:65535,value:y,onChange:e=>b(e.target.value)})]}),(0,D.jsxs)(`label`,{className:`dc-field`,children:[(0,D.jsx)(`span`,{children:n(`deviceHubHubUrl`)}),(0,D.jsx)(`input`,{disabled:E||!!V,maxLength:2048,value:x,onChange:e=>S(e.target.value)})]})]}),(0,D.jsx)(`p`,{className:`dc-setup-warning`,children:n(`deviceSetupReachable`)})]}),(0,D.jsx)(`p`,{children:n(`deviceSetupRegistration`)}),!X&&(0,D.jsx)(`p`,{role:`alert`,children:n(p===`remote`?`deviceSetupRemoteInvalid`:`deviceSetupInvalid`)}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[p===`current`&&!V&&!ue&&(0,D.jsx)(`button`,{className:`dc-button is-primary`,disabled:E||!G||!h||!R||z||!!h.busy||!X,onClick:()=>void q(),children:n(E?`deviceSetupInstalling`:`deviceSetupInstall`)}),(0,D.jsx)(`button`,{className:`dc-button`,disabled:E||ee||!X,onClick:()=>{if(!X||!Y||l.current)return;l.current=!0,te(!0),c(!1);let e=e=>{l.current=!1,u.current&&(te(!1),c(!e))},t=window.__piWebUiHost;try{t?.startChat({newChat:!0,prompt:I(Y,h,p,p===`remote`?C:void 0),onResult:e})||e(!1)}catch{e(!1)}},children:n(p===`remote`?`deviceSetupStartAi`:`deviceSetupAi`)})]}),(0,D.jsx)(`p`,{children:n(`deviceSetupAiHint`)}),ee&&(0,D.jsx)(`p`,{role:`status`,children:n(`deviceSetupAiCreating`)}),ne&&(0,D.jsx)(`p`,{role:`alert`,children:n(`deviceSetupAiFailed`)})]})]}),se&&(0,D.jsxs)(`div`,{role:`alert`,children:[(0,D.jsx)(`p`,{children:n(`deviceSetupFailed`)}),a&&(0,D.jsx)(`pre`,{className:`dc-setup-output`,children:a})]}),V&&(0,D.jsxs)(`div`,{role:`status`,children:[(0,D.jsx)(`h4`,{children:n(`deviceSetupSuccess`)}),(0,D.jsx)(`pre`,{className:`dc-setup-output`,children:V.output.slice(0,16e3)}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[(0,D.jsx)(A,{href:V.publicUrl,children:n(`deviceHubOpenHub`)}),(0,D.jsx)(`button`,{className:`dc-button is-primary`,onClick:()=>e(V.publicUrl),children:n(`deviceSetupPair`)})]})]})]})}var R=`pi-web-ui:device-groups-changed`;function ce(e){window.dispatchEvent(new CustomEvent(`pi-web-ui:device-group-open`,{detail:{roomId:e}}))}async function z(e,t,n){let r=await fetch(_(s(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,credentials:`same-origin`,signal:t,...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}:{}}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(i.error||i.message||`Request failed (${r.status})`);return i}function B({bindingKey:e=``}){return(0,D.jsx)(V,{},e)}function V(){let{locale:e}=ne(),t=r(e),[i,a]=(0,T.useState)([]),[s,ee]=(0,T.useState)([]),[te,d]=(0,T.useState)(!0),[h,g]=(0,T.useState)(``),[re,_]=(0,T.useState)(``),[v,ie]=(0,T.useState)(0),[y,b]=(0,T.useState)(!1),[x,S]=(0,T.useState)(``),[C,E]=(0,T.useState)([]),[O,k]=(0,T.useState)(``),[A,j]=(0,T.useState)(null),[M,oe]=(0,T.useState)([]),[N,P]=(0,T.useState)(``),[se,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(``),[B,V]=(0,T.useState)(!1),[H,U]=(0,T.useState)(null),W=i.find(e=>e.id===H?.roomId),G=(0,T.useRef)(0),K=(0,T.useRef)(null),q=(0,T.useRef)(null);function le(){++G.current,K.current?.abort(),ie(e=>e+1)}function J(){q.current?.abort();let e=new AbortController;return q.current=e,e}(0,T.useEffect)(()=>()=>q.current?.abort(),[]),(0,T.useEffect)(()=>{let e=++G.current,t=new AbortController;K.current=t;async function n(){try{let[n,r]=await Promise.all([z(`rooms`,t.signal),z(`bots`,t.signal)]);if(G.current!==e||t.signal.aborted)return;let i=Array.isArray(n.rooms)?n.rooms:[];a(i),U(e=>e&&i.some(t=>t.id===e.roomId)?e:null),ee(Array.isArray(r.bots)?r.bots:[]),g(``)}catch(n){G.current===e&&!t.signal.aborted&&g(n instanceof Error?n.message:String(n))}finally{G.current===e&&!t.signal.aborted&&d(!1)}}return n(),()=>{t.abort()}},[v]),(0,T.useEffect)(()=>{let e=()=>le();return window.addEventListener(R,e),()=>window.removeEventListener(R,e)},[]);async function ue(e){if(e.preventDefault(),!x.trim()||B)return;V(!0),g(``),_(``);let n=J();try{let e=C.includes(O)?O:``,r=await z(`rooms`,n.signal,{name:x.trim(),botIds:C,...e?{primaryBotId:e}:{}});if(n.signal.aborted)return;a(e=>[...e.filter(e=>e.id!==r.room.id),r.room]),b(!1),S(``),E([]),k(``),_(t?`群聊创建成功`:`Group created successfully`),window.dispatchEvent(new CustomEvent(R))}catch(e){n.signal.aborted||g(e instanceof Error?e.message:String(e))}finally{n.signal.aborted||V(!1)}}function de(e){j(e.id),oe([...e.botIds]),P(e.primaryBotId??``),F(null),b(!1),g(``),_(``)}async function Y(e){if(B)return;V(!0),g(``),_(``);let n=J();try{let r=M.includes(N)?N:null,i=await z(`rooms/${encodeURIComponent(e)}/members`,n.signal,{botIds:M,primaryBotId:r});if(n.signal.aborted)return;a(t=>t.map(t=>t.id===e?i.room:t)),j(null),_(t?`成员设置已保存`:`Members updated successfully`),window.dispatchEvent(new CustomEvent(R))}catch(e){n.signal.aborted||g(e instanceof Error?e.message:String(e))}finally{n.signal.aborted||V(!1)}}async function X(e){if(!I.trim()||B)return;V(!0),g(``),_(``);let n=J();try{if(await z(`rooms/${encodeURIComponent(e)}/rename`,n.signal,{name:I.trim()}),n.signal.aborted)return;a(t=>t.map(t=>t.id===e?{...t,name:I.trim()}:t)),F(null),_(t?`群聊名称已更新`:`Group renamed successfully`),window.dispatchEvent(new CustomEvent(R))}catch(e){n.signal.aborted||g(e instanceof Error?e.message:String(e))}finally{n.signal.aborted||V(!1)}}async function Z(e){if(B||!window.confirm(t?`确定删除群聊“${e.name}”?`:`Are you sure you want to delete "${e.name}"?`))return;V(!0),g(``),_(``);let n=J();try{if(await z(`rooms/${encodeURIComponent(e.id)}/delete`,n.signal,{}),n.signal.aborted)return;U(t=>t?.roomId===e.id?null:t),a(t=>t.filter(t=>t.id!==e.id)),A===e.id&&j(null),se===e.id&&F(null),_(t?`群聊已删除`:`Group deleted successfully`),window.dispatchEvent(new CustomEvent(R))}catch(e){n.signal.aborted||g(e instanceof Error?e.message:String(e))}finally{n.signal.aborted||V(!1)}}return(0,D.jsxs)(`section`,{className:`dc-card`,"aria-label":t?`群聊列表`:`Group list`,children:[(0,D.jsxs)(`div`,{className:`dc-card-header`,children:[(0,D.jsx)(`span`,{className:`dc-icon`,children:(0,D.jsx)(u,{"aria-hidden":!0})}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`h2`,{children:[t?`群聊列表`:`Group List`,` · `,i.length]}),(0,D.jsx)(`p`,{children:t?`管理群聊与成员 Bot,在此配置协作群组或直接进入聊天。`:`Manage groups and member Bots. Configure collaboration groups or open chats here.`})]}),(0,D.jsxs)(`div`,{className:`dc-actions`,style:{marginInlineStart:`auto`},children:[(0,D.jsxs)(`button`,{type:`button`,className:`dc-button is-primary`,disabled:B,onClick:()=>{b(e=>!e),j(null),F(null),S(``),E([]),k(``)},children:[(0,D.jsx)(o,{"aria-hidden":!0}),t?`新建群聊`:`Create Group`]}),(0,D.jsx)(`button`,{type:`button`,className:`dc-icon-button`,"aria-label":t?`刷新群聊`:`Refresh groups`,onClick:le,children:(0,D.jsx)(c,{})})]})]}),h&&(0,D.jsx)(`p`,{className:`dc-notice is-error`,role:`alert`,children:h}),re&&(0,D.jsxs)(`p`,{className:`dc-notice is-success`,role:`status`,children:[(0,D.jsx)(n,{"aria-hidden":!0}),re]}),y&&(0,D.jsxs)(`form`,{className:`dc-card`,style:{marginBottom:`16px`,background:`var(--bg)`,border:`1px solid var(--border)`},onSubmit:ue,children:[(0,D.jsxs)(`div`,{className:`dg-heading`,style:{marginBottom:`12px`},children:[(0,D.jsx)(`h3`,{children:t?`新建群聊`:`Create Group`}),(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,onClick:()=>b(!1),disabled:B,children:[(0,D.jsx)(p,{"aria-hidden":!0}),t?`关闭`:`Close`]})]}),(0,D.jsxs)(`div`,{className:`dc-field`,style:{marginBottom:`12px`},children:[(0,D.jsx)(`label`,{htmlFor:`dg-manager-new-name`,children:t?`群名称`:`Group Name`}),(0,D.jsx)(`input`,{id:`dg-manager-new-name`,type:`text`,required:!0,maxLength:80,value:x,placeholder:t?`输入群名称,如:研发协作群`:`Enter group name`,onChange:e=>S(e.target.value),disabled:B,style:{width:`100%`,background:`var(--bg-elev)`,border:`1px solid var(--border)`,borderRadius:`6px`,padding:`6px 10px`,color:`var(--text)`,fontSize:`13px`}})]}),(0,D.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,D.jsx)(`label`,{style:{display:`block`,marginBottom:`6px`,fontSize:`12px`,color:`var(--text-dim)`},children:t?`选择成员 Bot`:`Select Member Bots`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`6px`,maxHeight:`160px`,overflowY:`auto`,border:`1px solid var(--border)`,borderRadius:`6px`,padding:`8px`,background:`var(--bg-elev)`},children:s.length===0?(0,D.jsx)(`p`,{style:{margin:0,fontSize:`12px`,color:`var(--text-faint)`},children:t?`暂无可用 Bot,请先创建 Bot。`:`No Bots available. Please create a Bot first.`}):s.map(e=>(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`,fontSize:`12px`},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:C.includes(e.id),disabled:B||!e.enabled,onChange:t=>{E(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}}),(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:e.name}),(0,D.jsxs)(`small`,{style:{color:`var(--text-faint)`,marginInlineStart:`6px`},children:[e.online?t?`在线`:`Online`:t?`离线`:`Offline`,e.enabled?``:t?` · 已禁用`:` · Disabled`]})]})]},e.id))})]}),C.length>0&&(0,D.jsxs)(`div`,{className:`dc-field`,style:{marginBottom:`16px`},children:[(0,D.jsx)(`label`,{htmlFor:`dg-manager-new-primary`,children:t?`原主 Bot(Router 未启用时)`:`Legacy primary Bot (when Router is disabled)`}),(0,D.jsxs)(`select`,{id:`dg-manager-new-primary`,value:C.includes(O)?O:``,onChange:e=>k(e.target.value),disabled:B,style:{width:`100%`,background:`var(--bg-elev)`,border:`1px solid var(--border)`,borderRadius:`6px`,padding:`6px 10px`,color:`var(--text)`,fontSize:`13px`},children:[(0,D.jsx)(`option`,{value:``,children:t?`不设置(需 @ Bot)`:`None (mention a Bot)`}),s.filter(e=>C.includes(e.id)).map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[(0,D.jsxs)(`button`,{type:`submit`,className:`dc-button is-primary`,disabled:B||!x.trim(),children:[(0,D.jsx)(n,{"aria-hidden":!0}),B?t?`创建中…`:`Creating…`:t?`创建群聊`:`Create`]}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button`,onClick:()=>b(!1),disabled:B,children:t?`取消`:`Cancel`})]})]}),A&&(0,D.jsxs)(`div`,{className:`dc-card`,style:{marginBottom:`16px`,background:`var(--bg)`,border:`1px solid var(--border)`},children:[(0,D.jsxs)(`div`,{className:`dg-heading`,style:{marginBottom:`12px`},children:[(0,D.jsxs)(`h3`,{children:[t?`管理成员`:`Manage Members`,` · `,i.find(e=>e.id===A)?.name]}),(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,onClick:()=>j(null),disabled:B,children:[(0,D.jsx)(p,{"aria-hidden":!0}),t?`关闭`:`Close`]})]}),(0,D.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,D.jsx)(`label`,{style:{display:`block`,marginBottom:`6px`,fontSize:`12px`,color:`var(--text-dim)`},children:t?`选择成员 Bot`:`Select Member Bots`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`6px`,maxHeight:`160px`,overflowY:`auto`,border:`1px solid var(--border)`,borderRadius:`6px`,padding:`8px`,background:`var(--bg-elev)`},children:s.length===0?(0,D.jsx)(`p`,{style:{margin:0,fontSize:`12px`,color:`var(--text-faint)`},children:t?`暂无可用 Bot`:`No Bots available`}):s.map(e=>(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`,fontSize:`12px`},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:M.includes(e.id),disabled:B,onChange:t=>{oe(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}}),(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:e.name}),(0,D.jsxs)(`small`,{style:{color:`var(--text-faint)`,marginInlineStart:`6px`},children:[e.online?t?`在线`:`Online`:t?`离线`:`Offline`,e.enabled?``:t?` · 已禁用`:` · Disabled`]})]})]},e.id))})]}),!i.find(e=>e.id===A)?.router?.enabled&&(0,D.jsxs)(`div`,{className:`dc-field`,style:{marginBottom:`16px`},children:[(0,D.jsx)(`label`,{htmlFor:`dg-manager-edit-primary`,children:t?`原主 Bot(Router 未启用时)`:`Legacy primary Bot (when Router is disabled)`}),(0,D.jsxs)(`select`,{id:`dg-manager-edit-primary`,value:M.includes(N)?N:``,onChange:e=>P(e.target.value),disabled:B,style:{width:`100%`,background:`var(--bg-elev)`,border:`1px solid var(--border)`,borderRadius:`6px`,padding:`6px 10px`,color:`var(--text)`,fontSize:`13px`},children:[(0,D.jsx)(`option`,{value:``,children:t?`不设置(需 @ Bot)`:`None (mention a Bot)`}),s.filter(e=>M.includes(e.id)).map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`dc-button is-primary`,disabled:B,onClick:()=>void Y(A),children:[(0,D.jsx)(n,{"aria-hidden":!0}),B?t?`保存中…`:`Saving…`:t?`保存成员设置`:`Save Members`]}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button`,onClick:()=>j(null),disabled:B,children:t?`取消`:`Cancel`})]})]}),te&&(0,D.jsx)(`p`,{role:`status`,children:t?`加载中…`:`Loading…`}),!te&&i.length===0&&(0,D.jsx)(`p`,{style:{color:`var(--text-faint)`,fontSize:`13px`,padding:`12px 0`},children:t?`还没有群聊,点击上方“新建群聊”开始协作。`:`No groups yet. Click 'Create Group' above to get started.`}),(0,D.jsx)(`div`,{className:`dd-list`,children:i.map(e=>{let r=se===e.id,i=s.filter(t=>e.botIds.includes(t.id)),a=s.find(t=>t.id===e.primaryBotId);return(0,D.jsxs)(`div`,{className:`dd-device`,style:r?{flexWrap:`wrap`}:void 0,children:[(0,D.jsx)(`span`,{className:`dc-device-icon`,children:(0,D.jsx)(u,{"aria-hidden":!0})}),(0,D.jsxs)(`div`,{className:`dd-identity`,style:{flex:1,minWidth:`200px`},children:[(0,D.jsx)(`strong`,{children:e.name}),(0,D.jsxs)(`span`,{style:{display:`flex`,gap:`8px`,flexWrap:`wrap`,alignItems:`center`},children:[(0,D.jsx)(`span`,{children:t?`${e.botIds.length} 个 Bot${i.length?`: ${i.map(e=>e.name).join(`, `)}`:``}`:`${e.botIds.length} Bots${i.length?`: ${i.map(e=>e.name).join(`, `)}`:``}`}),e.router?.enabled&&(0,D.jsxs)(`span`,{children:[`AI Router · `,e.router.deviceId,` · `,e.router.model,` · `,e.router.thinkingLevel]}),!e.router?.enabled&&a&&(0,D.jsx)(`span`,{style:{color:`var(--accent)`},children:t?`[主 Bot: ${a.name}]`:`[Primary: ${a.name}]`})]})]}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`dc-button is-primary`,title:t?`打开聊天`:`Open chat`,onClick:()=>ce(e.id),children:[(0,D.jsx)(f,{"aria-hidden":!0}),t?`打开聊天`:`Open chat`]}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button`,"aria-expanded":H?.roomId===e.id&&H.kind===`router`,onClick:()=>U({roomId:e.id,kind:`router`}),children:`AI Router`}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button`,"aria-expanded":H?.roomId===e.id&&H.kind===`work`,onClick:()=>U({roomId:e.id,kind:`work`}),children:t?`工单与运行`:`Work items & runs`}),(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,title:t?`管理成员`:`Manage members`,onClick:()=>de(e),children:[(0,D.jsx)(u,{"aria-hidden":!0}),t?`管理成员`:`Members`]}),(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,title:t?`重命名`:`Rename`,onClick:()=>{r?F(null):(F(e.id),L(e.name))},children:[(0,D.jsx)(l,{"aria-hidden":!0}),t?`重命名`:`Rename`]}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button is-danger`,title:t?`删除群聊`:`Delete group`,disabled:B,onClick:()=>void Z(e),children:(0,D.jsx)(m,{"aria-hidden":!0})})]}),r&&(0,D.jsxs)(`form`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`,paddingTop:`8px`,paddingBottom:`4px`},onSubmit:t=>{t.preventDefault(),X(e.id)},children:[(0,D.jsx)(`input`,{type:`text`,maxLength:80,autoFocus:!0,disabled:B,value:I,onChange:e=>L(e.target.value),placeholder:t?`输入新群名称`:`Enter new name`,style:{flex:1,minWidth:`180px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:`6px`,padding:`6px 10px`,color:`var(--text)`,fontSize:`12px`}}),(0,D.jsxs)(`button`,{type:`submit`,className:`dc-button is-primary`,disabled:B||!I.trim(),children:[(0,D.jsx)(n,{"aria-hidden":!0}),t?`保存`:`Save`]}),(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,disabled:B,onClick:()=>F(null),children:[(0,D.jsx)(p,{"aria-hidden":!0}),t?`取消`:`Cancel`]})]})]},e.id)})}),W&&H&&(0,D.jsxs)(`section`,{className:`dc-card`,"aria-label":t?`群组设置`:`Group settings`,children:[(0,D.jsxs)(`div`,{className:`dg-heading`,children:[(0,D.jsx)(`h3`,{children:W.name}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[(0,D.jsx)(`button`,{type:`button`,className:`dc-button${H.kind===`router`?` is-primary`:``}`,"aria-pressed":H.kind===`router`,onClick:()=>U({roomId:W.id,kind:`router`}),children:`AI Router`}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button${H.kind===`work`?` is-primary`:``}`,"aria-pressed":H.kind===`work`,onClick:()=>U({roomId:W.id,kind:`work`}),children:t?`工单与运行`:`Work items & runs`}),(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,onClick:()=>U(null),children:[(0,D.jsx)(p,{"aria-hidden":!0}),t?`关闭`:`Close`]})]})]}),H.kind===`router`?(0,D.jsx)(w,{roomId:W.id,router:W.router,disabled:B,onSaved:le},W.id):(0,D.jsx)(ae,{roomId:W.id,disabled:B},W.id)]})]})}var H=class extends Error{status;constructor(e,t){super(t),this.status=e}};function U(e){try{let t=new URL(e);return[`http:`,`https:`].includes(t.protocol)&&!t.username&&!t.password?t.href:null}catch{return null}}function W(){let e=g(),t=i().startsWith(`zh`),[n,r]=(0,T.useState)(null),[a,o]=(0,T.useState)(!1),[te,ne]=(0,T.useState)(!1),[l,u]=(0,T.useState)(!1),[d,f]=(0,T.useState)(!1),p=(0,T.useRef)(0),m=(0,T.useRef)(null);async function h(e,t){if(m.current)return;let n=++p.current,i=new AbortController;m.current=i,o(!0),ne(!1);try{let a=await fetch(_(s(`/api/device-desktop/local/${e}`)),{method:t?`POST`:`GET`,credentials:`same-origin`,signal:i.signal,...t?{headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}:{}});if(p.current!==n||i.signal.aborted)return;if(a.status===403){u(!0),r(null);return}if(!a.ok)throw Error(`Request failed`);let o=await a.json();if(p.current!==n||i.signal.aborted)return;if(e===`permissions`){if(typeof o?.screen!=`boolean`||typeof o?.accessibility!=`boolean`)throw Error(`Invalid permission status`);r(e=>e&&{...e,permissions:{supported:!0,screen:o.screen,accessibility:o.accessibility}}),f(!0)}else{if(typeof o?.os!=`string`||typeof o.enabled!=`boolean`||typeof o.environmentEnabled!=`boolean`||typeof o.supported!=`boolean`)throw Error(`Invalid desktop status`);r(o)}}catch{p.current===n&&!i.signal.aborted&&ne(!0)}finally{p.current===n&&!i.signal.aborted&&(m.current=null,o(!1))}}return(0,T.useEffect)(()=>(h(`status`),()=>{p.current++,m.current?.abort(),m.current=null}),[]),(0,D.jsxs)(`section`,{className:`dc-card`,"aria-label":t?`本机远程桌面`:`Local remote desktop`,"aria-busy":a,children:[(0,D.jsxs)(`div`,{className:`dc-card-header`,children:[(0,D.jsx)(`span`,{className:`dc-icon`,children:(0,D.jsx)(ee,{"aria-hidden":!0})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{children:t?`本机远程桌面`:`Local remote desktop`}),(0,D.jsx)(`p`,{children:t?`管理这台设备的远程桌面与系统权限,无需连接设备中心。`:`Manage remote desktop and system permissions on this device, even while the device center is offline.`})]})]}),l?(0,D.jsx)(`p`,{role:`status`,children:t?`请在设备本机打开此页面以管理远程桌面权限。`:`Open this page on the device itself to manage remote desktop permissions.`}):(0,D.jsxs)(D.Fragment,{children:[n&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`dc-permission-row`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{id:`dc-desktop-label`,children:t?`启用远程桌面`:`Enable remote desktop`}),(0,D.jsx)(`p`,{children:n.enabled?t?`已启用`:`Enabled`:t?`未启用`:`Disabled`})]}),(0,D.jsx)(`button`,{type:`button`,className:`dc-toggle${n.enabled?` is-on`:``}`,role:`switch`,"aria-checked":n.enabled,"aria-labelledby":`dc-desktop-label`,disabled:a||n.environmentEnabled||!n.supported&&!n.enabled,onClick:()=>void h(`enable`,{enabled:!n.enabled}),children:(0,D.jsx)(`span`,{className:`dc-toggle-thumb`})})]}),!n.supported&&(0,D.jsx)(`p`,{children:t?`这台设备暂不支持远程桌面。`:`Remote desktop is currently unavailable on this device.`}),n.environmentEnabled&&(0,D.jsx)(`p`,{children:t?`远程桌面由本机服务设置保持启用。`:`Remote desktop is kept enabled by the service settings on this device.`}),n.os===`darwin`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`p`,{children:t?`点击下方按钮发起系统授权,请在这台 Mac 的系统设置中确认。授权后可能需要重启服务。`:`Use the buttons below to request system permission, then confirm in System Settings on this Mac. You may need to restart the service afterward.`}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[(0,D.jsx)(`button`,{type:`button`,className:`dc-button`,disabled:a||n.permissions?.supported===!1,onClick:()=>void h(`permissions`,{kind:`screen`}),children:t?`授予屏幕录制权限`:`Grant screen recording permission`}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button`,disabled:a||n.permissions?.supported===!1,onClick:()=>void h(`permissions`,{kind:`control`}),children:t?`授予远程控制权限`:`Grant remote control permission`})]}),n.permissions?.screen===!0&&(0,D.jsx)(`p`,{children:t?`屏幕录制:已授权`:`Screen recording: granted`}),n.permissions?.accessibility===!0&&(0,D.jsx)(`p`,{children:t?`远程控制:已授权`:`Remote control: granted`}),d&&(0,D.jsx)(`p`,{role:`status`,children:t?`已发起授权请求,请确认系统设置后刷新状态。`:`Permission requested. Confirm in System Settings, then refresh the status.`})]})]}),te&&(0,D.jsx)(`p`,{className:`dc-notice is-error`,role:`alert`,children:t?`无法更新本机远程桌面设置,请重试。`:`Unable to update local remote desktop settings. Please retry.`}),(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,disabled:a,onClick:()=>void h(`status`),children:[(0,D.jsx)(c,{"aria-hidden":!0}),a?e(`deviceHubWorking`):t?`刷新远程桌面状态`:`Refresh remote desktop status`]})]})]})}function G({pathCompletions:e=[],plugins:o=[],pluginsEpoch:ne=0}){let l=g(),f=r(i()),[p,m]=(0,T.useState)(`devices`),[v,ie]=(0,T.useState)(null),[y,S]=(0,T.useState)(``),[w,ae]=(0,T.useState)(``),[O,j]=(0,T.useState)(null),[M,oe]=(0,T.useState)(Date.now()),[N,P]=(0,T.useState)(null),[se,F]=(0,T.useState)(``),[I,R]=(0,T.useState)(``),[ce,z]=(0,T.useState)(``),[V,G]=(0,T.useState)(!1),K=(0,T.useRef)(!1),[q,le]=(0,T.useState)(!1),[J,ue]=(0,T.useState)(!0),de=(0,T.useRef)(!1),Y=(0,T.useRef)(0),X=(0,T.useRef)(new Set),Z=(0,T.useRef)(!1),fe=(0,T.useRef)(!1),pe=(0,T.useRef)(null),me=(0,T.useRef)(l);me.current=l,(0,T.useEffect)(()=>{let e=e=>{let t=e;t.detail?.deviceId&&pe.current?.deviceId===t.detail.deviceId&&(ie(e=>e&&{...e,remark:t.detail.remark}),pe.current&&(pe.current.remark=t.detail.remark))};return window.addEventListener(`pi-web-ui:device-remark-updated`,e),()=>window.removeEventListener(`pi-web-ui:device-remark-updated`,e)},[]);async function he(e,t){let n=new AbortController;X.current.add(n);try{let r=await fetch(_(s(`/api/device-center/${e}`)),{method:t?`POST`:`GET`,credentials:`same-origin`,signal:n.signal,...t?{headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}:{}}),i=await r.json().catch(()=>({}));if(!r.ok)throw new H(r.status,typeof i.error==`string`?i.error:me.current(`deviceHubRequestFailed`,{status:r.status}));return i}finally{X.current.delete(n)}}function Q(e){return de.current&&Y.current===e}function ge(e){return e instanceof H&&e.status===403?(le(!0),me.current(`deviceHubLocalOnly`)):e instanceof Error?e.message:me.current(`deviceHubNetworkError`)}function _e(e){pe.current=e,ie(e),fe.current||(ae(e.name),S(e.hubUrl??``))}async function ve(){let e=Y.current;try{let t=await he(`status`);if(!Q(e)||Z.current)return;_e(t),R(``),le(!1)}catch(t){Q(e)&&R(ge(t))}finally{Q(e)&&ue(!1)}}(0,T.useEffect)(()=>{de.current=!0;let e=!1,t,n=async()=>{await ve(),!e&&de.current&&(t=setTimeout(n,5e3))};return n(),()=>{e=!0,de.current=!1,Y.current++,clearTimeout(t);for(let e of X.current)e.abort()}},[]),(0,T.useEffect)(()=>{if(!O)return;let e=Y.current,t=!1,n,r=setInterval(()=>oe(Date.now()),1e3),i=async()=>{if(!(t||!Q(e)||Date.now()>=O.expiresAt)){try{let n=await he(`poll`,{});if(t||!Q(e))return;if(n.paired){let n=await he(`status`);if(t||!Q(e))return;fe.current=!1,_e(n),j(null),F(``),z(``);return}F(``)}catch(n){!t&&Q(e)&&F(`${me.current(`deviceHubPollError`)} ${ge(n)}`)}!t&&Q(e)&&(n=setTimeout(i,2e3))}};return n=setTimeout(i,2e3),()=>{t=!0,clearTimeout(n),clearInterval(r)}},[O]);async function ye(){if(Z.current)return;let e=U(y.trim());if(!e){F(l(`deviceHubInvalidUrl`));return}if(!w.trim()||w.trim().length>80){F(l(`deviceHubInvalidName`));return}let t=++Y.current;Z.current=!0,P(`pair`),F(``),z(``),j(null);try{let n=await he(`pair`,{hubUrl:e,name:w.trim()});if(!Q(t))return;if(!n.code||!Number.isFinite(n.expiresAt)||!U(n.hubUrl))throw Error(l(`deviceHubPairError`));oe(Date.now()),j(n)}catch(e){Q(t)&&F(`${l(`deviceHubPairError`)} ${ge(e)}`)}finally{Q(t)&&(Z.current=!1,P(null))}}async function be(){let e=pe.current;if(!e?.deviceId||Z.current)return;let t=++Y.current;Z.current=!0,P(`permission`),F(``),z(``),_e({...e,allowExecution:!e.allowExecution});try{await he(`execution`,{allowExecution:!e.allowExecution}),Q(t)&&z(l(`deviceHubSaved`))}catch(n){Q(t)&&(_e(e),F(`${l(`deviceHubPermissionError`)} ${ge(n)}`))}finally{Q(t)&&(Z.current=!1,P(null))}}async function xe(){let e=pe.current;if(!e?.deviceId||Z.current||!window.confirm(l(`deviceHubDisconnectConfirm`,{name:e.name})))return;let t=++Y.current;Z.current=!0,P(`disconnect`),F(``),z(``);try{if(await he(`disconnect`,{}),!Q(t))return;fe.current=!1,_e({name:e.name,allowExecution:!1,connected:!1}),j(null)}catch(e){Q(t)&&F(`${l(`deviceHubDisconnectError`)} ${ge(e)}`)}finally{Q(t)&&(Z.current=!1,P(null))}}async function Se(){if(K.current||N||!$||!v?.hubUrl||!window.confirm(l(`deviceHubConfirmUpgrade`)))return;let e=Y.current;K.current=!0,G(!0),F(``),z(``);try{let t=await he(`upgrade-hub`,{});if(!t.ok)throw Error(`Hub upgrade was not accepted`);await E(t.job,{isCurrent:()=>Q(e),poll:async e=>(await he(`upgrade-hub-status`,{id:e})).job}),Q(e)&&(z(l(`deviceHubUpgradeSuccess`)),await ve())}catch(t){Q(e)&&F(t instanceof Error?t.message:l(`deviceHubNetworkError`))}finally{K.current=!1,Q(e)&&G(!1)}}async function Ce(){if(!O)return;let e=Y.current;try{await navigator.clipboard.writeText(O.code),Q(e)&&z(l(`deviceHubCopied`))}catch{Q(e)&&F(l(`deviceHubCopyFailed`))}}let $=!!v?.deviceId,we=U($?v?.hubUrl??``:O?.hubUrl??``),Te=Math.max(0,Math.ceil(((O?.expiresAt??0)-M)/1e3)),Ee=`${Math.floor(Te/60)}:${String(Te%60).padStart(2,`0`)}`,De=we?(0,D.jsxs)(A,{href:we,children:[(0,D.jsx)(t,{"aria-hidden":!0}),l(`deviceHubOpenHub`)]}):null;return(0,D.jsxs)(`section`,{className:`dc-page`,"aria-label":l(`deviceHubTitle`),children:[(0,D.jsxs)(`header`,{className:`dc-header`,children:[(0,D.jsxs)(`div`,{className:`dc-heading`,children:[(0,D.jsxs)(`span`,{className:`dc-eyebrow`,children:[(0,D.jsx)(ee,{"aria-hidden":!0}),l(`deviceHubTitle`)]}),(0,D.jsx)(`h1`,{children:l(`deviceHubTitle`)}),(0,D.jsx)(`p`,{children:l(`deviceHubSubtitle`)})]}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[$&&De,(0,D.jsxs)(`span`,{className:`dc-status ${$?v?.connected?`is-online`:`is-offline`:`is-unpaired`}`,children:[(0,D.jsx)(`span`,{className:`dc-status-dot`}),l($?v?.connected?`deviceHubOnline`:`deviceHubOffline`:`deviceHubUnpaired`)]})]})]}),(0,D.jsxs)(`div`,{className:`dc-layout`,children:[(0,D.jsx)(`nav`,{className:`dc-sidebar`,"aria-label":f?`设备与协作导航`:`Devices and collaboration`,children:[[`devices`,ee,f?`设备与连接`:`Devices & connections`],[`groups`,u,f?`群组与工单`:`Groups & work items`],[`channels`,d,f?`外部渠道`:`External channels`]].map(([e,t,n])=>(0,D.jsxs)(`button`,{type:`button`,className:`dc-nav-item${p===e?` is-active`:``}`,"aria-pressed":p===e,onClick:()=>m(e),children:[(0,D.jsx)(t,{"aria-hidden":!0}),n]},e))}),(0,D.jsxs)(`main`,{className:`dc-content`,children:[J&&(0,D.jsxs)(`div`,{className:`dc-loading`,role:`status`,children:[(0,D.jsx)(c,{"aria-hidden":!0}),l(`deviceHubLoading`)]}),(q||I)&&(0,D.jsxs)(`div`,{className:`dc-notice is-error`,role:`alert`,children:[(0,D.jsx)(`span`,{children:q?l(`deviceHubLocalOnly`):`${l(`deviceHubStatusError`)} ${I}`}),(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,onClick:()=>void ve(),children:[(0,D.jsx)(c,{"aria-hidden":!0}),l(`deviceHubRetry`)]})]}),se&&!q&&(0,D.jsx)(`div`,{className:`dc-notice is-error`,role:`alert`,children:se}),ce&&(0,D.jsxs)(`div`,{className:`dc-notice is-success`,role:`status`,children:[(0,D.jsx)(n,{"aria-hidden":!0}),ce]}),p!==`devices`&&(!$||q)&&(0,D.jsxs)(`section`,{className:`dc-card`,children:[(0,D.jsx)(`h2`,{children:p===`groups`?f?`群组与工单`:`Groups & work items`:f?`外部渠道`:`External channels`}),(0,D.jsx)(`p`,{children:f?`先连接设备中心,再创建群组、配置群组 AI 并接入外部渠道。`:`Connect to a device hub before creating groups, configuring group AI, and connecting external channels.`}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button is-primary`,onClick:()=>m(`devices`),children:f?`前往设备连接`:`Connect a device`})]}),p===`groups`&&$&&!q&&(0,D.jsx)(B,{},`groups:${v?.hubUrl??``}:${v?.deviceId??``}`),p===`channels`&&$&&!q&&(0,D.jsx)(k,{plugin:o.find(e=>e.id===`superagent`),epoch:ne,onManageGroups:()=>m(`groups`)},`channels:${v?.hubUrl??``}:${v?.deviceId??``}`),p===`devices`&&(0,D.jsxs)(D.Fragment,{children:[!$&&(v||q)&&(0,D.jsx)(L,{initialHubUrl:y,onConnect:e=>{if(q){z(l(`deviceHubLocalOnly`));return}fe.current=!0,S(e)}}),v&&!q&&!$&&(0,D.jsxs)(`section`,{className:`dc-card`,children:[(0,D.jsxs)(`div`,{className:`dc-card-header`,children:[(0,D.jsx)(`span`,{className:`dc-icon`,children:(0,D.jsx)(re,{"aria-hidden":!0})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{children:l(`deviceHubPairTitle`)}),(0,D.jsx)(`p`,{children:l(`deviceHubPairHint`)})]})]}),(0,D.jsx)(`ol`,{className:`dc-steps`,children:[`deviceHubStepDetails`,`deviceHubStepApprove`,`deviceHubStepWait`].map((e,t)=>(0,D.jsxs)(`li`,{className:O?t===0?`is-complete`:`is-active`:t===0?`is-active`:``,children:[(0,D.jsx)(`span`,{className:`dc-step-number`,children:O&&t===0?(0,D.jsx)(n,{"aria-hidden":!0}):t+1}),(0,D.jsx)(`span`,{children:l(e)})]},e))}),(0,D.jsxs)(`form`,{className:`dc-form`,onSubmit:e=>{e.preventDefault(),ye()},children:[(0,D.jsxs)(`div`,{className:`dc-field`,children:[(0,D.jsx)(`label`,{htmlFor:`dc-hub-url`,children:l(`deviceHubHubUrl`)}),(0,D.jsx)(`input`,{id:`dc-hub-url`,type:`url`,autoComplete:`url`,required:!0,placeholder:l(`deviceHubHubPlaceholder`),value:y,disabled:!!O||!!N,onChange:e=>{fe.current=!0,S(e.target.value)}})]}),(0,D.jsxs)(`div`,{className:`dc-field`,children:[(0,D.jsx)(`label`,{htmlFor:`dc-device-name`,children:l(`deviceHubName`)}),(0,D.jsx)(`input`,{id:`dc-device-name`,maxLength:80,required:!0,autoComplete:`off`,placeholder:l(`deviceHubNamePlaceholder`),value:w,disabled:!!O||!!N,onChange:e=>{fe.current=!0,ae(e.target.value)}})]}),!O&&(0,D.jsx)(`div`,{className:`dc-actions`,children:(0,D.jsxs)(`button`,{className:`dc-button is-primary`,type:`submit`,disabled:!!N,children:[(0,D.jsx)(re,{"aria-hidden":!0}),l(N?`deviceHubWorking`:`deviceHubGetCode`)]})})]}),O&&(0,D.jsxs)(`div`,{className:`dc-pairing`,children:[(0,D.jsx)(`span`,{className:`dc-code-label`,children:l(`deviceHubCode`)}),(0,D.jsxs)(`div`,{className:`dc-code-row`,children:[(0,D.jsx)(`code`,{className:`dc-code`,children:O.code}),(0,D.jsx)(`button`,{className:`dc-icon-button`,type:`button`,"aria-label":l(`deviceHubCopy`),onClick:()=>void Ce(),children:(0,D.jsx)(a,{"aria-hidden":!0})})]}),(0,D.jsx)(`div`,{className:`dc-pair-meta`,children:l(Te?`deviceHubExpires`:`deviceHubExpired`,{time:Ee})}),(0,D.jsxs)(`div`,{className:`dc-actions`,children:[De,(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,disabled:!!N,onClick:()=>{++Y.current,j(null),F(``),z(``)},children:[(0,D.jsx)(c,{"aria-hidden":!0}),l(`deviceHubNewCode`)]})]}),Te>0&&(0,D.jsxs)(`p`,{className:`dc-progress`,role:`status`,children:[(0,D.jsx)(c,{"aria-hidden":!0}),l(`deviceHubWaiting`)]})]})]}),$&&v&&!q&&(0,D.jsxs)(`section`,{className:`dc-card`,children:[(0,D.jsxs)(`div`,{className:`dc-device-summary`,children:[(0,D.jsx)(`span`,{className:`dc-device-icon`,children:(0,D.jsx)(ee,{"aria-hidden":!0})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{children:v.remark?.trim()||v.name}),(0,D.jsx)(`p`,{children:v.remark?.trim()?`${v.name} · ${l(`deviceHubDeviceTitle`)}`:l(`deviceHubDeviceTitle`)})]})]}),(0,D.jsxs)(`dl`,{className:`dc-details`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`dt`,{children:l(`deviceHubDeviceId`)}),(0,D.jsx)(`dd`,{children:v.deviceId})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`dt`,{children:l(`deviceHubHubUrl`)}),(0,D.jsx)(`dd`,{children:v.hubUrl})]})]}),(0,D.jsx)(`div`,{className:`dc-actions`,style:{marginTop:`1rem`},children:(0,D.jsxs)(`button`,{type:`button`,className:`dc-button`,disabled:V||!!N,onClick:()=>void Se(),children:[(0,D.jsx)(c,{className:V?`spin`:``,"aria-hidden":!0}),l(V?`deviceHubUpgrading`:`deviceHubUpgradeAction`)]})})]}),$&&v?.hubUrl&&v.deviceId&&!q&&(0,D.jsx)(b,{hubUrl:v.hubUrl,currentDeviceId:v.deviceId},`directory:${v.hubUrl}:${v.deviceId}`),!q&&(0,D.jsx)(x,{pathCompletions:e},`bots:${v?.hubUrl??``}:${v?.deviceId??`unpaired`}`),(0,D.jsx)(W,{}),$&&v&&!q&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`section`,{className:`dc-card`,children:[(0,D.jsxs)(`div`,{className:`dc-card-header`,children:[(0,D.jsx)(`span`,{className:`dc-icon`,children:(0,D.jsx)(te,{"aria-hidden":!0})}),(0,D.jsx)(`div`,{children:(0,D.jsx)(`h2`,{children:l(`deviceHubPermissions`)})})]}),(0,D.jsxs)(`div`,{className:`dc-permission-row`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{id:`dc-permission-label`,children:l(`deviceHubPermissionLabel`)}),(0,D.jsx)(`p`,{id:`dc-permission-hint`,children:l(`deviceHubPermissionHint`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`dc-toggle${v.allowExecution?` is-on`:``}`,role:`switch`,"aria-checked":v.allowExecution,"aria-labelledby":`dc-permission-label`,"aria-describedby":`dc-permission-hint`,disabled:!!N,onClick:()=>void be(),children:(0,D.jsx)(`span`,{className:`dc-toggle-thumb`})})]}),(0,D.jsx)(`p`,{className:`dc-permission-state`,role:`status`,children:l(N===`permission`?`deviceHubSaving`:v.allowExecution?`deviceHubEnabled`:`deviceHubReadOnly`)})]}),(0,D.jsx)(C,{hubUrl:v?.hubUrl,deviceId:v?.deviceId,onNotice:z}),(0,D.jsxs)(`details`,{className:`dc-advanced`,children:[(0,D.jsx)(`summary`,{children:l(`deviceHubAdvanced`)}),(0,D.jsxs)(`div`,{className:`dc-danger-zone`,children:[(0,D.jsx)(`h3`,{children:l(`deviceHubDisconnect`)}),(0,D.jsx)(`p`,{children:l(`deviceHubDisconnectHint`)}),(0,D.jsx)(`button`,{type:`button`,className:`dc-button is-danger`,disabled:!!N,onClick:()=>void xe(),children:l(N===`disconnect`?`deviceHubWorking`:`deviceHubDisconnect`)})]})]})]}),(0,D.jsxs)(`aside`,{className:`dc-help`,children:[(0,D.jsx)(h,{className:`dc-help-icon`,"aria-hidden":!0}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{children:l(`deviceHubHelpTitle`)}),(0,D.jsx)(`p`,{children:l(`deviceHubHelpText`)})]})]})]})]})]})]})}export{G as DeviceCenter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,Ct as n,K as r,Pn as i,Qt as a,Ut as o,Vt as s,Wt as c,Zt as l,kt as u,mn as d,ot as f,p,wn as m,z as h,zn as g}from"./app-globals-CZjFtI4F.js";import{i as _,t as v}from"./react-CR5VJ85Q.js";var y=e(_(),1),b=v(),x={maxActiveTasks:4,maxWaitingTasks:32,starvationThresholdMs:8e3,maxSkipsBeforeStarvation:3,maxDispatchDepth:8,maxDispatchBudget:16,allowBotMentions:!1,groupContextBytes:262144,groupRetentionLimit:2e3,fileSyncMaxBytes:104857600,fileSyncMaxFiles:1e3,fileSyncStagedBytes:1073741824,resourceLockDefaultTtlMs:18e5,blackboardMaxBytes:262144,taskReportExcerptBytes:131072,maxResourceLocksPerTask:128,botMentionBudgetPerTurn:3};function S(e,t,n,r){return typeof e==`number`&&Number.isFinite(e)?Math.max(t,Math.min(n,Math.round(e))):r}function C(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KiB`,`MiB`,`GiB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${Number.isInteger(r)?r:r.toFixed(1)} ${t[n]}`}function w(e){return!Number.isFinite(e)||e<=0?`0 ms`:e<1e3?`${e} ms`:e<6e4?`${Math.round(e/1e3)} s`:`${(e/6e4).toFixed(1)} min`}function T(e){let t={settings:{...x},activeCount:0,waitingCount:0,blockedCount:0,running:[],waiting:[],blocked:[]};if(!e||typeof e!=`object`||Array.isArray(e))return t;let n=e,r=n.settings&&typeof n.settings==`object`&&!Array.isArray(n.settings)?n.settings:{},i={maxActiveTasks:S(r.maxActiveTasks,1,64,x.maxActiveTasks),maxWaitingTasks:S(r.maxWaitingTasks,0,1024,x.maxWaitingTasks),starvationThresholdMs:S(r.starvationThresholdMs,1e3,6e4,x.starvationThresholdMs),maxSkipsBeforeStarvation:S(r.maxSkipsBeforeStarvation,1,20,x.maxSkipsBeforeStarvation),maxDispatchDepth:S(r.maxDispatchDepth,1,64,x.maxDispatchDepth),maxDispatchBudget:S(r.maxDispatchBudget,1,256,x.maxDispatchBudget),allowBotMentions:typeof r.allowBotMentions==`boolean`?r.allowBotMentions:x.allowBotMentions,groupContextBytes:S(r.groupContextBytes,4096,2097152,x.groupContextBytes),groupRetentionLimit:S(r.groupRetentionLimit,50,2e4,x.groupRetentionLimit),fileSyncMaxBytes:S(r.fileSyncMaxBytes,1048576,10737418240,x.fileSyncMaxBytes),fileSyncMaxFiles:S(r.fileSyncMaxFiles,10,1e4,x.fileSyncMaxFiles),fileSyncStagedBytes:S(r.fileSyncStagedBytes,4194304,53687091200,x.fileSyncStagedBytes),resourceLockDefaultTtlMs:S(r.resourceLockDefaultTtlMs,6e4,864e5,x.resourceLockDefaultTtlMs),blackboardMaxBytes:S(r.blackboardMaxBytes,4096,4194304,x.blackboardMaxBytes),...typeof r.taskReportExcerptBytes==`number`?{taskReportExcerptBytes:r.taskReportExcerptBytes}:{},...typeof r.maxResourceLocksPerTask==`number`?{maxResourceLocksPerTask:r.maxResourceLocksPerTask}:{},...typeof r.botMentionBudgetPerTurn==`number`?{botMentionBudgetPerTurn:r.botMentionBudgetPerTurn}:{}},a=Array.isArray(n.running)?n.running:[],o=Array.isArray(n.waiting)?n.waiting:[],s=Array.isArray(n.blocked)?n.blocked:[];return{settings:i,activeCount:typeof n.activeCount==`number`?n.activeCount:a.length,waitingCount:typeof n.waitingCount==`number`?n.waitingCount:o.length,blockedCount:typeof n.blockedCount==`number`?n.blockedCount:s.length,running:a,waiting:o,blocked:s}}function E({hubUrl:e,deviceId:_,onNotice:v}){let E=m(),[D,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(x),[j,M]=(0,y.useState)(!1),[N,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(null),[z,B]=(0,y.useState)(null),V=(0,y.useRef)(!0),H=(0,y.useRef)(0),U=(0,y.useRef)(new Set),W=(0,y.useRef)(!1),G=(0,y.useRef)(!1),K=`${e??``}:${_??``}`,q=(0,y.useCallback)(async(e,t,n)=>{let r=new AbortController;U.current.add(r);let a=()=>r.abort();n&&(n.aborted?r.abort():n.addEventListener(`abort`,a,{once:!0}));try{let n=await fetch(g(i(`/api/device-center/${e}`)),{method:t?`POST`:`GET`,credentials:`same-origin`,signal:r.signal,headers:t?{"Content-Type":`application/json`}:void 0,body:t?JSON.stringify(t):void 0}),a=await n.json().catch(()=>({}));if(!n.ok){let e=typeof a.error==`string`?a.error:`HTTP ${n.status}`;throw Error(e)}return a}finally{n&&n.removeEventListener(`abort`,a),U.current.delete(r)}},[]),J=(0,y.useCallback)(async(e=!1)=>{if(!V.current||W.current)return;W.current=!0;let t=H.current;e||M(!0);try{let e=await q(`execution-queue`);if(!V.current||t!==H.current)return;let n=T(e);O(n),R(null),G.current||=(A({...n.settings}),!0)}catch(e){if(!V.current||t!==H.current)return;e.name!==`AbortError`&&R(e.message)}finally{W.current=!1,V.current&&t===H.current&&!e&&M(!1)}},[q]);(0,y.useEffect)(()=>{V.current=!0,H.current++;for(let e of U.current)e.abort();U.current.clear(),W.current=!1,G.current=!1,O(null),A({...x}),R(null),B(null),J(!1);let e=setInterval(()=>{J(!0)},3e3);return()=>{V.current=!1,H.current++;for(let e of U.current)e.abort();U.current.clear(),clearInterval(e)}},[K,J]);let Y=(e,t)=>{A(n=>({...n,[e]:t}))},X=(e,t)=>{A(n=>({...n,[e]:t}))},Z=()=>{A({...x})},Q=()=>{D?.settings?A({...D.settings}):A({...x})},$=async e=>{e.preventDefault();let t=H.current;P(!0),R(null),B(null);let n={maxActiveTasks:S(k.maxActiveTasks,1,64,x.maxActiveTasks),maxWaitingTasks:S(k.maxWaitingTasks,0,1024,x.maxWaitingTasks),starvationThresholdMs:S(k.starvationThresholdMs,1e3,6e4,x.starvationThresholdMs),maxSkipsBeforeStarvation:S(k.maxSkipsBeforeStarvation,1,20,x.maxSkipsBeforeStarvation),maxDispatchDepth:S(k.maxDispatchDepth,1,64,x.maxDispatchDepth),maxDispatchBudget:S(k.maxDispatchBudget,1,256,x.maxDispatchBudget),allowBotMentions:!!k.allowBotMentions,groupContextBytes:S(k.groupContextBytes,4096,2097152,x.groupContextBytes),groupRetentionLimit:S(k.groupRetentionLimit,50,2e4,x.groupRetentionLimit),fileSyncMaxBytes:S(k.fileSyncMaxBytes,1048576,10737418240,x.fileSyncMaxBytes),fileSyncMaxFiles:S(k.fileSyncMaxFiles,10,1e4,x.fileSyncMaxFiles),fileSyncStagedBytes:S(k.fileSyncStagedBytes,4194304,53687091200,x.fileSyncStagedBytes),resourceLockDefaultTtlMs:S(k.resourceLockDefaultTtlMs,6e4,864e5,x.resourceLockDefaultTtlMs),blackboardMaxBytes:S(k.blackboardMaxBytes,4096,4194304,x.blackboardMaxBytes),...k.taskReportExcerptBytes===void 0?{}:{taskReportExcerptBytes:k.taskReportExcerptBytes},...k.maxResourceLocksPerTask===void 0?{}:{maxResourceLocksPerTask:k.maxResourceLocksPerTask},...k.botMentionBudgetPerTurn===void 0?{}:{botMentionBudgetPerTurn:k.botMentionBudgetPerTurn}};try{let e=await q(`execution-settings`,n);if(!V.current||t!==H.current)return;e?.settings&&A({...e.settings}),B(E(`deviceExecSavedNotice`)),v?.(E(`deviceExecSavedNotice`)),await J(!0)}catch(e){if(!V.current||t!==H.current)return;e.name!==`AbortError`&&R(e.message)}finally{V.current&&t===H.current&&P(!1)}},ee=async(e,t)=>{let n=H.current;I(e),R(null);try{if(await q(`execution-queue/cancel`,{taskId:e,attemptId:t}),!V.current||n!==H.current)return;v?.(E(`deviceExecTaskCancelled`)),await J(!0)}catch(e){if(!V.current||n!==H.current)return;e.name!==`AbortError`&&R(e.message)}finally{V.current&&n===H.current&&I(null)}},te=e=>{switch(e){case`max_concurrency_reached`:return E(`deviceExecReasonMaxConcurrency`);case`bot_busy`:return E(`deviceExecReasonBotBusy`);case`workspace_conflict`:return E(`deviceExecReasonWorkspaceConflict`);case`workspace_blocked`:return E(`deviceExecReasonWorkspaceBlocked`);case`room_fairness_yield`:return E(`deviceExecReasonFairness`);default:return e}},ne=D?.settings?.maxActiveTasks??x.maxActiveTasks,re=D?.settings?.maxWaitingTasks??x.maxWaitingTasks;return(0,b.jsxs)(`div`,{className:`des-container`,children:[(0,b.jsxs)(`div`,{className:`des-header`,children:[(0,b.jsxs)(`div`,{className:`des-header-left`,children:[(0,b.jsx)(`h3`,{className:`des-title`,children:E(`deviceExecTitle`)}),(0,b.jsx)(`p`,{className:`des-subtitle`,children:E(`deviceExecSubtitle`)})]}),(0,b.jsx)(`button`,{type:`button`,className:`des-refresh-btn`,onClick:()=>void J(!1),disabled:j,title:E(`deviceExecRefresh`),children:(0,b.jsx)(o,{className:j?`des-spin`:``})})]}),L&&(0,b.jsxs)(`div`,{className:`des-alert des-alert-error`,role:`alert`,children:[(0,b.jsx)(p,{className:`des-alert-icon`}),(0,b.jsx)(`div`,{className:`des-alert-text`,children:L}),(0,b.jsx)(`button`,{type:`button`,className:`des-alert-close`,onClick:()=>R(null),children:(0,b.jsx)(d,{})})]}),z&&(0,b.jsxs)(`div`,{className:`des-alert des-alert-success`,role:`status`,children:[(0,b.jsx)(t,{className:`des-alert-icon`}),(0,b.jsx)(`div`,{className:`des-alert-text`,children:z}),(0,b.jsx)(`button`,{type:`button`,className:`des-alert-close`,onClick:()=>B(null),children:(0,b.jsx)(d,{})})]}),(0,b.jsxs)(`div`,{className:`des-stats-row`,children:[(0,b.jsxs)(`div`,{className:`des-stat-card`,children:[(0,b.jsxs)(`div`,{className:`des-stat-label`,children:[(0,b.jsx)(s,{className:`des-stat-icon is-running`}),` `,E(`deviceExecRunning`)]}),(0,b.jsxs)(`div`,{className:`des-stat-value`,children:[D?.activeCount??0,` `,(0,b.jsxs)(`span`,{className:`des-stat-sub`,children:[`/ `,ne]})]})]}),(0,b.jsxs)(`div`,{className:`des-stat-card`,children:[(0,b.jsxs)(`div`,{className:`des-stat-label`,children:[(0,b.jsx)(h,{className:`des-stat-icon is-waiting`}),` `,E(`deviceExecQueued`)]}),(0,b.jsxs)(`div`,{className:`des-stat-value`,children:[D?.waitingCount??0,` `,(0,b.jsxs)(`span`,{className:`des-stat-sub`,children:[`/ `,re]})]})]}),(0,b.jsxs)(`div`,{className:`des-stat-card`,children:[(0,b.jsxs)(`div`,{className:`des-stat-label`,children:[(0,b.jsx)(a,{className:`des-stat-icon is-blocked`}),` `,E(`deviceExecBlocked`)]}),(0,b.jsx)(`div`,{className:`des-stat-value${(D?.blockedCount??0)>0?` is-warn`:``}`,children:D?.blockedCount??0})]})]}),(0,b.jsxs)(`form`,{className:`des-form-card`,onSubmit:e=>void $(e),children:[(0,b.jsxs)(`div`,{className:`des-form-header`,children:[(0,b.jsx)(`h4`,{className:`des-form-title`,children:E(`deviceExecQuotaTitle`)}),(0,b.jsx)(`div`,{className:`des-form-header-actions`,children:(0,b.jsxs)(`button`,{type:`button`,className:`des-btn des-btn-secondary des-btn-sm`,disabled:N,onClick:Z,title:E(`deviceExecResetDefaultsTip`),children:[(0,b.jsx)(c,{className:`des-btn-icon`}),E(`deviceExecResetDefaults`)]})})]}),(0,b.jsxs)(`div`,{className:`des-group`,children:[(0,b.jsxs)(`div`,{className:`des-group-header`,children:[(0,b.jsx)(r,{className:`des-group-icon`}),(0,b.jsx)(`span`,{className:`des-group-title`,children:E(`deviceExecSchedulingTitle`)})]}),(0,b.jsxs)(`div`,{className:`des-fields-row`,children:[(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-max-active`,className:`des-label`,children:E(`deviceExecMaxActive`)}),(0,b.jsx)(`input`,{id:`des-max-active`,type:`number`,min:1,max:64,step:1,className:`des-input`,value:k.maxActiveTasks,onChange:e=>Y(`maxActiveTasks`,parseInt(e.target.value,10)||1),required:!0}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecMaxActiveHint`)})]}),(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-max-waiting`,className:`des-label`,children:E(`deviceExecMaxWaiting`)}),(0,b.jsx)(`input`,{id:`des-max-waiting`,type:`number`,min:0,max:1024,step:1,className:`des-input`,value:k.maxWaitingTasks,onChange:e=>Y(`maxWaitingTasks`,parseInt(e.target.value,10)||0),required:!0}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecMaxWaitingHint`)})]}),(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-starvation-ms`,className:`des-label`,children:E(`deviceExecStarvationMs`)}),(0,b.jsxs)(`div`,{className:`des-input-with-badge`,children:[(0,b.jsx)(`input`,{id:`des-starvation-ms`,type:`number`,min:1e3,max:6e4,step:500,className:`des-input`,value:k.starvationThresholdMs,onChange:e=>Y(`starvationThresholdMs`,parseInt(e.target.value,10)||1e3),required:!0}),(0,b.jsx)(`span`,{className:`des-input-badge`,children:w(k.starvationThresholdMs)})]}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecStarvationMsHint`)})]}),(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-max-skips`,className:`des-label`,children:E(`deviceExecMaxSkips`)}),(0,b.jsx)(`input`,{id:`des-max-skips`,type:`number`,min:1,max:20,step:1,className:`des-input`,value:k.maxSkipsBeforeStarvation,onChange:e=>Y(`maxSkipsBeforeStarvation`,parseInt(e.target.value,10)||1),required:!0}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecMaxSkipsHint`)})]})]})]}),(0,b.jsxs)(`div`,{className:`des-group`,children:[(0,b.jsxs)(`div`,{className:`des-group-header`,children:[(0,b.jsx)(l,{className:`des-group-icon`}),(0,b.jsx)(`span`,{className:`des-group-title`,children:E(`deviceExecDispatchTitle`)})]}),(0,b.jsxs)(`div`,{className:`des-fields-row`,children:[(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-max-depth`,className:`des-label`,children:E(`deviceExecMaxDepth`)}),(0,b.jsx)(`input`,{id:`des-max-depth`,type:`number`,min:1,max:64,step:1,className:`des-input`,value:k.maxDispatchDepth,onChange:e=>Y(`maxDispatchDepth`,parseInt(e.target.value,10)||1),required:!0}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecMaxDepthHint`)})]}),(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-max-budget`,className:`des-label`,children:E(`deviceExecMaxBudget`)}),(0,b.jsx)(`input`,{id:`des-max-budget`,type:`number`,min:1,max:256,step:1,className:`des-input`,value:k.maxDispatchBudget,onChange:e=>Y(`maxDispatchBudget`,parseInt(e.target.value,10)||1),required:!0}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecMaxBudgetHint`)})]}),(0,b.jsxs)(`div`,{className:`des-field des-field-checkbox`,children:[(0,b.jsxs)(`label`,{htmlFor:`des-allow-bot-mentions`,className:`des-checkbox-container`,children:[(0,b.jsx)(`input`,{id:`des-allow-bot-mentions`,type:`checkbox`,className:`des-checkbox`,checked:k.allowBotMentions,onChange:e=>X(`allowBotMentions`,e.target.checked)}),(0,b.jsx)(`span`,{className:`des-label`,children:E(`deviceExecAllowBotMentions`)})]}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecAllowBotMentionsHint`)})]})]})]}),(0,b.jsxs)(`div`,{className:`des-group`,children:[(0,b.jsxs)(`div`,{className:`des-group-header`,children:[(0,b.jsx)(u,{className:`des-group-icon`}),(0,b.jsx)(`span`,{className:`des-group-title`,children:E(`deviceExecContextTitle`)})]}),(0,b.jsxs)(`div`,{className:`des-fields-row`,children:[(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-group-context-bytes`,className:`des-label`,children:E(`deviceExecContextBytes`)}),(0,b.jsxs)(`div`,{className:`des-input-with-badge`,children:[(0,b.jsx)(`input`,{id:`des-group-context-bytes`,type:`number`,min:4096,max:2097152,step:1024,className:`des-input`,value:k.groupContextBytes,onChange:e=>Y(`groupContextBytes`,parseInt(e.target.value,10)||4096),required:!0}),(0,b.jsx)(`span`,{className:`des-input-badge`,children:C(k.groupContextBytes)})]}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecContextBytesHint`)})]}),(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-group-retention`,className:`des-label`,children:E(`deviceExecRetention`)}),(0,b.jsx)(`input`,{id:`des-group-retention`,type:`number`,min:50,max:2e4,step:10,className:`des-input`,value:k.groupRetentionLimit,onChange:e=>Y(`groupRetentionLimit`,parseInt(e.target.value,10)||50),required:!0}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecRetentionHint`)})]})]})]}),(0,b.jsxs)(`div`,{className:`des-group`,children:[(0,b.jsxs)(`div`,{className:`des-group-header`,children:[(0,b.jsx)(f,{className:`des-group-icon`}),(0,b.jsx)(`span`,{className:`des-group-title`,children:E(`deviceExecFileSyncTitle`)})]}),(0,b.jsxs)(`div`,{className:`des-fields-row`,children:[(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-file-sync-bytes`,className:`des-label`,children:E(`deviceExecFileSyncBytes`)}),(0,b.jsxs)(`div`,{className:`des-input-with-badge`,children:[(0,b.jsx)(`input`,{id:`des-file-sync-bytes`,type:`number`,min:1048576,max:10737418240,step:1048576,className:`des-input`,value:k.fileSyncMaxBytes,onChange:e=>Y(`fileSyncMaxBytes`,parseInt(e.target.value,10)||1048576),required:!0}),(0,b.jsx)(`span`,{className:`des-input-badge`,children:C(k.fileSyncMaxBytes)})]}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecFileSyncBytesHint`)})]}),(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-file-sync-files`,className:`des-label`,children:E(`deviceExecFileSyncFiles`)}),(0,b.jsx)(`input`,{id:`des-file-sync-files`,type:`number`,min:10,max:1e4,step:1,className:`des-input`,value:k.fileSyncMaxFiles,onChange:e=>Y(`fileSyncMaxFiles`,parseInt(e.target.value,10)||10),required:!0}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecFileSyncFilesHint`)})]}),(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-file-sync-staged-bytes`,className:`des-label`,children:E(`deviceExecFileSyncStagedBytes`)}),(0,b.jsxs)(`div`,{className:`des-input-with-badge`,children:[(0,b.jsx)(`input`,{id:`des-file-sync-staged-bytes`,type:`number`,min:4194304,max:53687091200,step:1048576,className:`des-input`,value:k.fileSyncStagedBytes,onChange:e=>Y(`fileSyncStagedBytes`,parseInt(e.target.value,10)||4194304),required:!0}),(0,b.jsx)(`span`,{className:`des-input-badge`,children:C(k.fileSyncStagedBytes)})]}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecFileSyncStagedBytesHint`)})]})]})]}),(0,b.jsxs)(`div`,{className:`des-group`,children:[(0,b.jsxs)(`div`,{className:`des-group-header`,children:[(0,b.jsx)(n,{className:`des-group-icon`}),(0,b.jsx)(`span`,{className:`des-group-title`,children:E(`deviceExecLocksTitle`)})]}),(0,b.jsxs)(`div`,{className:`des-fields-row`,children:[(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-resource-lock-ttl`,className:`des-label`,children:E(`deviceExecLockTtl`)}),(0,b.jsxs)(`div`,{className:`des-input-with-badge`,children:[(0,b.jsx)(`input`,{id:`des-resource-lock-ttl`,type:`number`,min:6e4,max:864e5,step:6e4,className:`des-input`,value:k.resourceLockDefaultTtlMs,onChange:e=>Y(`resourceLockDefaultTtlMs`,parseInt(e.target.value,10)||6e4),required:!0}),(0,b.jsx)(`span`,{className:`des-input-badge`,children:w(k.resourceLockDefaultTtlMs)})]}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecLockTtlHint`)})]}),(0,b.jsxs)(`div`,{className:`des-field`,children:[(0,b.jsx)(`label`,{htmlFor:`des-blackboard-bytes`,className:`des-label`,children:E(`deviceExecBlackboardBytes`)}),(0,b.jsxs)(`div`,{className:`des-input-with-badge`,children:[(0,b.jsx)(`input`,{id:`des-blackboard-bytes`,type:`number`,min:4096,max:4194304,step:1024,className:`des-input`,value:k.blackboardMaxBytes,onChange:e=>Y(`blackboardMaxBytes`,parseInt(e.target.value,10)||4096),required:!0}),(0,b.jsx)(`span`,{className:`des-input-badge`,children:C(k.blackboardMaxBytes)})]}),(0,b.jsx)(`span`,{className:`des-hint`,children:E(`deviceExecBlackboardBytesHint`)})]})]})]}),(0,b.jsxs)(`div`,{className:`des-form-actions`,children:[(0,b.jsx)(`button`,{type:`button`,className:`des-btn des-btn-secondary`,disabled:N,onClick:Z,children:E(`deviceExecResetDefaults`)}),(0,b.jsx)(`button`,{type:`button`,className:`des-btn des-btn-secondary`,disabled:N,onClick:Q,children:E(`deviceExecReset`)}),(0,b.jsx)(`button`,{type:`submit`,className:`des-btn des-btn-primary`,disabled:N,children:E(N?`deviceExecSaving`:`deviceExecSave`)})]})]}),D&&D.blocked&&D.blocked.length>0&&(0,b.jsxs)(`div`,{className:`des-section des-blocked-section`,children:[(0,b.jsxs)(`h4`,{className:`des-section-title is-danger`,children:[(0,b.jsx)(p,{}),` `,E(`deviceExecBlockedTitle`)]}),(0,b.jsx)(`p`,{className:`des-section-desc`,children:E(`deviceExecBlockedDesc`)}),(0,b.jsx)(`div`,{className:`des-table-wrap`,children:(0,b.jsxs)(`table`,{className:`des-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Task ID`}),(0,b.jsx)(`th`,{children:`Room ID`}),(0,b.jsx)(`th`,{children:`Bot ID`}),(0,b.jsx)(`th`,{children:E(`deviceExecReason`)})]})}),(0,b.jsx)(`tbody`,{children:D.blocked.map(e=>(0,b.jsxs)(`tr`,{className:`des-row-blocked`,children:[(0,b.jsxs)(`td`,{className:`des-mono`,children:[e.taskId.slice(0,8),`...`]}),(0,b.jsx)(`td`,{children:e.roomId}),(0,b.jsx)(`td`,{children:e.botId}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`des-badge is-danger`,children:e.reason})})]},`${e.taskId}-${e.attemptId}`))})]})})]}),(0,b.jsxs)(`div`,{className:`des-section`,children:[(0,b.jsxs)(`h4`,{className:`des-section-title`,children:[(0,b.jsx)(s,{}),` `,E(`deviceExecActiveTasks`),` (`,D?.running?.length??0,`)`]}),D&&D.running&&D.running.length>0?(0,b.jsx)(`div`,{className:`des-table-wrap`,children:(0,b.jsxs)(`table`,{className:`des-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Task ID`}),(0,b.jsx)(`th`,{children:`Room ID`}),(0,b.jsx)(`th`,{children:`Bot ID`}),(0,b.jsx)(`th`,{children:E(`deviceExecQueuedTime`)})]})}),(0,b.jsx)(`tbody`,{children:D.running.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{className:`des-mono`,title:e.taskId,children:[e.taskId.slice(0,8),`...`]}),(0,b.jsx)(`td`,{children:e.roomId}),(0,b.jsx)(`td`,{children:e.botId}),(0,b.jsx)(`td`,{children:new Date(e.startedAt).toLocaleTimeString()})]},`${e.taskId}-${e.attemptId}`))})]})}):(0,b.jsx)(`div`,{className:`des-empty`,children:E(`deviceExecNoActive`)})]}),(0,b.jsxs)(`div`,{className:`des-section`,children:[(0,b.jsxs)(`h4`,{className:`des-section-title`,children:[(0,b.jsx)(h,{}),` `,E(`deviceExecWaitingQueue`),` (`,D?.waiting?.length??0,`)`]}),D&&D.waiting&&D.waiting.length>0?(0,b.jsx)(`div`,{className:`des-table-wrap`,children:(0,b.jsxs)(`table`,{className:`des-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:E(`deviceExecPosition`)}),(0,b.jsx)(`th`,{children:`Task ID`}),(0,b.jsx)(`th`,{children:`Room ID`}),(0,b.jsx)(`th`,{children:`Bot ID`}),(0,b.jsx)(`th`,{children:E(`deviceExecReason`)}),(0,b.jsx)(`th`,{children:E(`deviceExecQueuedTime`)}),(0,b.jsx)(`th`,{children:E(`deviceExecActions`)})]})}),(0,b.jsx)(`tbody`,{children:D.waiting.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{children:(0,b.jsxs)(`span`,{className:`des-pos-badge`,children:[`#`,e.queuePosition]})}),(0,b.jsxs)(`td`,{className:`des-mono`,title:e.taskId,children:[e.taskId.slice(0,8),`...`]}),(0,b.jsx)(`td`,{children:e.roomId}),(0,b.jsx)(`td`,{children:e.botId}),(0,b.jsx)(`td`,{children:(0,b.jsxs)(`div`,{className:`des-reason-cell`,children:[(0,b.jsx)(`span`,{className:`des-badge des-badge-${e.blockReason}`,children:te(e.blockReason)}),(0,b.jsx)(`span`,{className:`des-reason-detail`,children:e.blockReasonDetail})]})}),(0,b.jsx)(`td`,{children:new Date(e.queuedAt).toLocaleTimeString()}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`button`,{type:`button`,className:`des-btn des-btn-danger-sm`,disabled:F===e.taskId,onClick:()=>void ee(e.taskId,e.attemptId),children:F===e.taskId?E(`deviceExecCancelling`):E(`deviceExecCancel`)})})]},`${e.taskId}-${e.attemptId}`))})]})}):(0,b.jsx)(`div`,{className:`des-empty`,children:E(`deviceExecNoWaiting`)})]})]})}export{E as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{An as t,Ht as n,Pn as r,Pt as i,Sn as a,fn as o,kt as s,qt as ee,zn as c}from"./app-globals-CZjFtI4F.js";import{i as l,r as u,t as d}from"./react-CR5VJ85Q.js";import{t as f}from"./shortcut-stack-hhrDyRBn.js";import{bt as te}from"./index-D_AGu4Zv.js";import{r as ne,t as re}from"./group-view-state-CGCzYF8k.js";var p=e(l(),1),m=u(),h=d();function ie(e,t){let n=e?.room;if(!n||typeof n.id!=`string`||!n.id||t!==void 0&&n.id!==t||typeof n.name!=`string`||!Array.isArray(n.botIds)||n.botIds.some(e=>typeof e!=`string`))throw Error(`Invalid group detail response`);return e}var ae={zh:{groups:`群聊`,manage:`管理成员`,save:`保存设置`,create:`建群`,name:`群名称`,devices:`选择 Bot(设备仅承载 Bot)`,empty:`还没有群聊,创建一个群开始协作。`,choose:`选择一个群聊`,open:`打开聊天`,online:`在线`,offline:`离线`,cancel:`取消`,loading:`加载中…`,rebind:`设备绑定已失效或已解除,请在设备设置中重新绑定。`,forbidden:`本机访问被拒绝,请检查本机登录状态与访问权限。`,failed:`请求失败`,searchPlaceholder:`搜索群或任务…`,matchedBot:`Bot: `,matchedTask:`任务: `},en:{groups:`Groups`,manage:`Manage members`,save:`Save settings`,create:`Create group`,name:`Group name`,devices:`Select Bots (devices host Bots)`,empty:`No groups yet. Create a group to collaborate.`,choose:`Select a group`,open:`Open chat`,online:`Online`,offline:`Offline`,cancel:`Cancel`,loading:`Loading…`,rebind:`The device binding has expired or was removed. Bind again in device settings.`,forbidden:`Local access denied. Check your local sign-in and access permissions.`,failed:`Request failed`,searchPlaceholder:`Search groups or tasks…`,matchedBot:`Bot: `,matchedTask:`Task: `}},oe=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};async function g(e,t,n){let i=await fetch(c(r(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,credentials:`same-origin`,signal:t,...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}:{}}),a=await i.json().catch(()=>({}));if(!i.ok)throw new oe(i.status,a.code??``,typeof a.error==`string`?a.error:String(i.status));return a}function _(e){window.dispatchEvent(new CustomEvent(`pi-web-ui:device-group-open`,{detail:{roomId:e}}))}function v({onClose:e}){let{locale:n}=a(),r=ae[t(n)?`zh`:`en`];return f(()=>{document.querySelector(`dialog[open]`)||e()}),(0,m.createPortal)((0,h.jsx)(`div`,{className:`modal-backdrop`,onClick:e,children:(0,h.jsx)(`div`,{className:`device-group-create-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":r.create,onClick:e=>e.stopPropagation(),children:(0,h.jsx)(y,{createOnly:!0,onClose:e})})}),document.body)}function y({active:e=!0,navigation:r,createOnly:c=!1,onClose:l}){let{locale:u}=a(),d=ae[t(u)?`zh`:`en`],[f,m]=(0,p.useState)([]),[v,y]=(0,p.useState)([]),[b,x]=(0,p.useState)(``),[S,C]=(0,p.useState)(null),[w,T]=(0,p.useState)(!0),[E,D]=(0,p.useState)(``),[se,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(c),[j,M]=(0,p.useState)(!1),[N,P]=(0,p.useState)(!1),[F,I]=(0,p.useState)(``),[L,R]=(0,p.useState)([]),[z,B]=(0,p.useState)(``),[V,H]=(0,p.useState)(!1),[ce,U]=(0,p.useState)(0),[W,le]=(0,p.useState)(``),[ue,de]=(0,p.useState)([]),G=(0,p.useRef)(new re),K=(0,p.useRef)(null),q=(0,p.useRef)(void 0),J=(0,p.useRef)(0),Y=(0,p.useRef)(null),X=(0,p.useRef)(d);X.current=d;function fe(e){let t=X.current;if(e instanceof oe){if(e.status===409&&/^(REPAIR_REQUIRED|NOT_PAIRED|DEVICE_CHANGED)$/.test(e.code)||e.status===403&&/binding|credential|unpaired|revoked|not_bound|hub_forbidden/i.test(e.code))return t.rebind;if(e.status===403)return t.forbidden}return`${t.failed}: ${e instanceof Error?e.message:String(e)}`}function Z(){Y.current?.abort(),Y.current=null,H(!1)}function Q(e,t=!1){++J.current,Z(),x(e),C(null),A(!1),M(t),O(!1),B(``),K.current=t?e:null,R([]),T(!0),D(``),U(e=>e+1)}function pe(){++J.current,Z(),A(!0),O(!1),B(``),M(!1),K.current=null,C(null),R([]),I(``),D(``),U(e=>e+1)}(0,p.useEffect)(()=>{let t=++J.current,n=null,r=!1,i=()=>J.current===t;async function a(){if(!e||document.visibilityState===`hidden`||r)return;r=!0;let t=new AbortController;n=t;try{let[e,n,r]=await Promise.all([g(`bots`,t.signal),g(`rooms`,t.signal),j&&b?g(`rooms/${encodeURIComponent(b)}`,t.signal).then(e=>ie(e,b)):Promise.resolve(null)]);if(!i()||t.signal.aborted)return;if(m(e.bots),y(n.rooms),C(r),r?.tasks){de(r.tasks);for(let e of r.tasks)e.status===`completed`?G.current.onTaskCompleted(e.roomId,e.id):e.status===`failed`&&G.current.onTaskFailed(e.roomId,e.id)}r&&K.current===r.room.id&&(K.current=null,R(r.room.botIds),B(r.room.primaryBotId??``)),D(``)}catch(e){i()&&!t.signal.aborted&&D(fe(e))}finally{t.abort(),r=!1,i()&&T(!1)}}a();let o=window.setInterval(()=>void a(),3e3),s=()=>{document.visibilityState===`hidden`?n?.abort():a()};return document.addEventListener(`visibilitychange`,s),()=>{++J.current,n?.abort(),clearInterval(o),document.removeEventListener(`visibilitychange`,s)}},[e,b,j,ce]),(0,p.useEffect)(()=>()=>Y.current?.abort(),[]),(0,p.useEffect)(()=>{e||Z()},[e]),(0,p.useEffect)(()=>{e&&r&&r.revision!==q.current&&(q.current=r.revision,r.create?pe():r.roomId&&Q(r.roomId,r.manage))},[e,r?.revision]);async function me(){if(!e||Y.current||(k?!F.trim():!S))return;let n=new AbortController;Y.current=n,H(!0),D(``),O(!1);let r=L.includes(z)?z:``,i=k,a=S?.room.id;try{let e=await g(i?`rooms`:`rooms/${encodeURIComponent(a)}/members`,n.signal,{...i?{name:F.trim()}:{},botIds:L,...z&&L.includes(z)?{primaryBotId:z}:!i&&S?.room.primaryBotId?{primaryBotId:null}:{}});if(n.signal.aborted||Y.current!==n)return;let{room:o}=ie(e,i?void 0:a);if((o.primaryBotId??``)!==r)throw Error(t(u)?`中心未保存主 Bot 设置,请更新群组所属的设备中心(Hub)后重试。`:`The Hub did not save the primary Bot setting. Update the group's Hub and retry.`);O(!0),y(e=>[...e.filter(e=>e.id!==o.id),o]),x(o.id),C({room:o}),A(!1),M(!i),I(``),R(i?[]:o.botIds),B(o.primaryBotId??``),U(e=>e+1),window.dispatchEvent(new CustomEvent(`pi-web-ui:device-groups-changed`)),i&&(_(o.id),c&&l?.())}catch(e){!n.signal.aborted&&Y.current===n&&D(fe(e))}finally{Y.current===n&&(Y.current=null,H(!1))}}let $=v.find(e=>e.id===b);return(0,h.jsxs)(`section`,{className:`dg-root`,"aria-label":d.groups,children:[!c&&(0,h.jsxs)(`div`,{className:`dc-card dg-sidebar`,children:[(0,h.jsxs)(`div`,{className:`dg-heading`,children:[(0,h.jsxs)(`h2`,{children:[(0,h.jsx)(o,{}),` `,d.groups]}),(0,h.jsxs)(`button`,{className:`dc-button`,type:`button`,disabled:!e,onClick:pe,children:[(0,h.jsx)(n,{}),` `,d.create]})]}),(0,h.jsx)(`div`,{className:`dg-search-bar`,style:{padding:`0 10px 8px 10px`},children:(0,h.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:`6px`,padding:`4px 8px`},children:[(0,h.jsx)(ee,{style:{color:`var(--text-dim)`,flex:`none`}}),(0,h.jsx)(`input`,{type:`search`,value:W,onChange:e=>le(e.target.value),placeholder:d.searchPlaceholder,style:{border:`none`,background:`transparent`,color:`var(--text)`,width:`100%`,fontSize:`12px`,outline:`none`}})]})}),(0,h.jsx)(`div`,{className:`dg-rooms`,children:ne(W,v,ue).map(t=>{let n=v.find(e=>e.id===t.roomId);if(!n)return null;let r=G.current.getPendingInteractionsCount(n.id);return(0,h.jsxs)(`button`,{className:`dc-button dg-room`,type:`button`,"aria-current":n.id===b?`page`:void 0,disabled:!e,onClick:()=>{Q(n.id),_(n.id)},children:[(0,h.jsx)(s,{}),(0,h.jsxs)(`span`,{style:{flex:1,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,textAlign:`left`},children:[n.name,t.matchedBy===`bot_id`&&(0,h.jsxs)(`small`,{style:{display:`block`,color:`var(--text-dim)`,fontSize:`11px`},children:[d.matchedBot,` `,W]}),t.matchedBy===`task_title`&&t.matchedTask&&(0,h.jsxs)(`small`,{style:{display:`block`,color:`var(--accent)`,fontSize:`11px`},children:[d.matchedTask,` `,t.matchedTask.title]}),t.matchedBy===`task_id`&&t.matchedTask&&(0,h.jsxs)(`small`,{style:{display:`block`,color:`var(--text-dim)`,fontSize:`11px`},children:[`ID: `,t.matchedTask.id.slice(0,8)]})]}),r>0&&(0,h.jsx)(`span`,{style:{flex:`none`,background:`var(--accent)`,color:`var(--accent-contrast, #fff)`,borderRadius:`10px`,padding:`1px 6px`,fontSize:`11px`,fontWeight:`bold`},children:r})]},t.matchedTask?`${n.id}:${t.matchedTask.id}`:n.id)})}),!w&&!v.length&&(0,h.jsx)(`p`,{className:`dg-empty`,children:d.empty})]}),(0,h.jsxs)(`div`,{className:`dc-card dg-chat`,children:[se&&(0,h.jsx)(`p`,{role:`status`,children:t(u)?`已保存成员和主 Bot 设置。`:`Members and primary Bot settings saved.`}),E&&(0,h.jsx)(`p`,{className:`dc-error`,role:`alert`,children:E}),w&&(0,h.jsx)(`p`,{role:`status`,children:d.loading}),k||j?(0,h.jsxs)(`form`,{className:`dg-create`,onSubmit:e=>{e.preventDefault(),me()},children:[(0,h.jsx)(`h2`,{children:k?d.create:d.manage}),k&&(0,h.jsxs)(`div`,{className:`dc-field`,children:[(0,h.jsx)(`label`,{htmlFor:`device-group-name`,children:d.name}),(0,h.jsx)(`input`,{id:`device-group-name`,value:F,onChange:e=>I(e.target.value),disabled:V||!e})]}),(0,h.jsxs)(`fieldset`,{disabled:V||!e||j&&!S,children:[(0,h.jsx)(`legend`,{children:d.devices}),f.map(e=>(0,h.jsxs)(`label`,{className:`dg-device`,children:[(0,h.jsx)(`input`,{type:`checkbox`,disabled:!e.enabled&&!L.includes(e.id),checked:L.includes(e.id),onChange:t=>R(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),(0,h.jsx)(i,{}),(0,h.jsxs)(`span`,{children:[e.name,` · `,e.id,` · `,e.deviceId,` · `,e.online?d.online:d.offline]})]},e.id))]}),!S?.room.router?.enabled&&(0,h.jsxs)(`div`,{className:`dc-field`,children:[(0,h.jsx)(`label`,{htmlFor:`device-group-primary-bot`,children:t(u)?`原主 Bot(Router 未启用时)`:`Legacy primary Bot (when Router is disabled)`}),(0,h.jsxs)(`select`,{id:`device-group-primary-bot`,value:L.includes(z)?z:``,disabled:V||!e||j&&!S,onChange:e=>B(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:t(u)?`不设置(需 @ Bot)`:`None (mention a Bot)`}),f.filter(e=>e.enabled&&L.includes(e.id)).map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.id]},e.id))]}),(0,h.jsx)(`p`,{children:t(u)?`未启用 Router 时,未 @ Bot 的消息发送给原主 Bot。独立 AI Router 请在群聊顶部配置。`:`When Router is disabled, messages without mentions go to the legacy primary Bot. Configure the independent AI Router from the group chat header.`})]}),S?.room.router?.enabled&&(0,h.jsxs)(`p`,{children:[`AI Router · `,S.room.router.deviceId,` · `,S.room.router.model,` ·`,` `,S.room.router.thinkingLevel]}),(0,h.jsxs)(`div`,{className:`dc-actions`,children:[(0,h.jsxs)(`button`,{className:`dc-button`,type:`button`,disabled:V||!e||N,onClick:()=>P(!0),children:[(0,h.jsx)(n,{}),` `,t(u)?`新建 Bot`:`Create Bot`]}),(0,h.jsx)(`button`,{className:`dc-button`,type:`submit`,disabled:V||!e||(k?!F.trim():!S),children:k?d.create:d.save}),(0,h.jsx)(`button`,{className:`dc-button`,type:`button`,onClick:()=>{Z(),K.current=null,c&&l?.(),A(!1),M(!1),D(``)},children:d.cancel})]})]}):$?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`dg-title`,children:(0,h.jsxs)(`h2`,{children:[(0,h.jsx)(o,{}),` `,$.name]})}),(0,h.jsxs)(`div`,{className:`dc-actions`,children:[(0,h.jsxs)(`button`,{className:`dc-button`,type:`button`,disabled:!e,onClick:()=>_($.id),children:[(0,h.jsx)(s,{}),d.open]}),(0,h.jsxs)(`button`,{className:`dc-button`,type:`button`,disabled:!e,onClick:()=>Q($.id,!0),children:[(0,h.jsx)(o,{}),d.manage]})]})]}):(0,h.jsx)(`p`,{className:`dg-empty`,children:d.choose})]}),N&&(0,h.jsx)(te,{createOnly:!0,onCancel:()=>P(!1),onCreated:(e,n)=>{P(!1),n&&e.enabled?(m(t=>[...t.filter(t=>t.id!==e.id),e]),R(t=>[...new Set([...t,e.id])])):D(t(u)?`Bot 已保存;请启用并同步到中心后,再加入群组。`:`Bot saved. Enable and sync it to the hub before adding it to the group.`)}})]})}export{v as DeviceGroupCreateDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{N as t}from"./app-globals-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{N as t}from"./app-globals-CZjFtI4F.js";import{i as n,r,t as i}from"./react-CR5VJ85Q.js";import{t as a}from"./shortcut-stack-hhrDyRBn.js";var o=r(),s=e(n(),1);function c(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,s.useRef)(t);(0,s.useLayoutEffect)(()=>{a.current=t}),(0,s.useEffect)(()=>{if(!r)return;let t=(e,t)=>{if(!t)return!1;let n=`current`in t?t.current:t;return n?n.contains(e):!1},n=n=>{let r=n.target;r instanceof Node&&(e.current?.contains(r)||i&&(Array.isArray(i)?i:[i]).some(e=>t(r,e))||a.current(n))};return document.addEventListener(`mousedown`,n),document.addEventListener(`touchstart`,n),()=>{document.removeEventListener(`mousedown`,n),document.removeEventListener(`touchstart`,n)}},[r,e,i])}var l=i();function u({align:e,triggerLeft:t,triggerRight:n,menuWidth:r,viewportWidth:i,margin:a=8}){if(r<=0||i<=0)return 0;let o=e===`left`?t:n-r,s=Math.max(a,i-a-r);return Math.round(Math.max(a,Math.min(o,s))-o)}function d({triggerRect:e,menuWidth:t,menuHeight:n,viewportWidth:r,viewportHeight:i,direction:a=`down`,align:o=`right`,gap:s=6,margin:c=8}){if(t<=0||r<=0||i<=0)return{left:Math.round(e.left),top:Math.round(e.bottom+s)};let l=Math.max(c,r-c-t),u=Math.max(c,i-c-n),d=c,f=c,p,m=Math.max(0,e.top-s-c),h=Math.max(0,i-e.bottom-s-c);if(a===`right`)d=e.right+s,d+t>r-c&&e.left-t-s>=c&&(d=e.left-t-s),d=Math.max(c,Math.min(d,l)),f=e.top,f+n>i-c&&(f=i-c-n),f=Math.max(c,Math.min(f,u)),p=Math.max(0,i-2*c);else if(a===`left`)d=e.left-t-s,d<c&&e.right+s+t<=r-c&&(d=e.right+s),d=Math.max(c,Math.min(d,l)),f=e.top,f+n>i-c&&(f=i-c-n),f=Math.max(c,Math.min(f,u)),p=Math.max(0,i-2*c);else if(a===`up`){m>=n?(f=e.top-n-s,p=m):h>=n||h>m?(f=e.bottom+s,p=h):(p=m,f=e.top-Math.min(n,m)-s);let r=Math.max(c,i-c-Math.min(n,p));f=Math.max(c,Math.min(f,r));let a=o===`left`?e.left:e.right-t;d=Math.max(c,Math.min(a,l))}else{h>=n?(f=e.bottom+s,p=h):m>=n?(f=e.top-n-s,p=m):m>h?(f=e.top-Math.min(n,m)-s,p=m):(f=e.bottom+s,p=h);let r=Math.max(c,i-c-Math.min(n,p));f=Math.max(c,Math.min(f,r));let a=o===`left`?e.left:e.right-t;d=Math.max(c,Math.min(a,l))}return{left:Math.round(d),top:Math.round(f),...p===void 0?{}:{maxHeight:Math.round(p)}}}function f({trigger:e,open:n,onOpenChange:r,children:i,align:f=`right`,fit:p=!1,direction:m=`down`,portal:h=!1,tip:g,caret:_=!0,menuClassName:v,triggerClassName:y,onContextMenu:b,dataBarItem:x,menuRef:S,menuStyle:C,className:w}){let T=(0,s.useRef)(null),E=(0,s.useRef)(null),[D,O]=(0,s.useState)(0),[k,A]=(0,s.useState)(null),j=e=>{E.current=e,typeof S==`function`?S(e):S&&`current`in S&&(S.current=e)},M=()=>{let e=T.current,t=E.current;if(!e||!t)return;if(window.innerWidth<=768){D!==0&&O(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){D!==0&&O(0);return}if(h){let e=d({triggerRect:r,menuWidth:n.width,menuHeight:n.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,direction:m,align:f,gap:6,margin:8});A(t=>t?.left===e.left&&t?.top===e.top&&t?.maxHeight===e.maxHeight?t:e)}else{let e=n.width,t=u({align:f,triggerLeft:r.left,triggerRight:r.right,menuWidth:e,viewportWidth:window.innerWidth,margin:8});t!==D&&O(t)}};(0,s.useLayoutEffect)(()=>{n?M():(D!==0&&O(0),k!==null&&A(null))}),(0,s.useEffect)(()=>{if(n)return window.addEventListener(`resize`,M),h&&window.addEventListener(`scroll`,M,!0),()=>{window.removeEventListener(`resize`,M),h&&window.removeEventListener(`scroll`,M,!0)}},[n,D,h,m,f]),c(T,()=>r(!1),{enabled:n,ignore:E}),a(()=>r(!1),n);let N=typeof window<`u`&&window.innerWidth<=768?{...C,pointerEvents:`auto`}:{...C,position:`fixed`,left:k?`${k.left}px`:`-9999px`,top:k?`${k.top}px`:`-9999px`,maxHeight:k?.maxHeight==null?C?.maxHeight:C?.maxHeight==null?`${k.maxHeight}px`:`min(${k.maxHeight}px, ${C.maxHeight})`,right:`auto`,bottom:`auto`,pointerEvents:`auto`,visibility:k?`visible`:`hidden`},P=k!=null&&T.current?k.top<T.current.getBoundingClientRect().top:m===`up`;return(0,l.jsxs)(`div`,{className:`dropdown ${f} ${p?`fit`:``} ${m===`up`?`dd-up`:``} ${w??``}`.trim(),ref:T,children:[(0,l.jsxs)(`button`,{type:`button`,className:y??`chip`,onClick:()=>r(!n),onContextMenu:b,"aria-expanded":n,"data-tip":g,"data-bar-item":x,children:[e,_&&(0,l.jsx)(t,{className:`dd-caret ${n?`up`:``}`})]}),n&&(h?(0,o.createPortal)((0,l.jsx)(`div`,{className:`dd-portal-wrapper dropdown ${f} ${p?`fit`:``} ${P?`dd-up`:``}`,style:{position:`fixed`,left:0,top:0,width:`100%`,height:`100%`,pointerEvents:`none`,zIndex:9999},children:(0,l.jsx)(`div`,{className:`dd-menu ${v??``}`,ref:j,style:N,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onWheel:e=>e.stopPropagation(),children:i})}),document.body):(0,l.jsx)(`div`,{className:`dd-menu ${v??``}`,ref:j,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onWheel:e=>e.stopPropagation(),style:D===0?C:{...C,transform:C?.transform?`${C.transform} translateX(${D}px)`:`translateX(${D}px)`},children:i}))]})}function p({active:e,disabled:t=!1,title:n,onClick:r,children:i}){return(0,l.jsx)(`button`,{type:`button`,className:`dd-item ${e?`active`:``}`,disabled:t,title:n,onClick:r,children:i})}export{p as n,f as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,B as r,Gt as i,Pn as a,Q as ee,St as te,Tt as ne,U as re,X as ie,_n as ae,et as oe,gn as se,jt as ce,mn as le,t as ue,wn as de,xt as fe,zn as pe}from"./app-globals-CZjFtI4F.js";import{i as me,t as o}from"./react-CR5VJ85Q.js";import{B as he,L as ge,f as _e,it as ve,ot as ye,tt as be}from"./index-D_AGu4Zv.js";var s=e(me(),1),c=`未命名章节`;function xe(e){return String(e??``).trim().replace(/[\s\u3000]+/g,`-`).replace(/[^\p{L}\p{N}_-]+/gu,`-`).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`section`}function Se(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=xe(r||c),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||c}})}function l(e){return e.length>=2}var u=o(),d=5e3,f=`pi-web-ui:preview-toc`;function p({file:e,composerSessionId:me,content:o,onAddLines:c,onAttach:xe,onClose:p,uiFilePreviewToolbar:Ce,onUiAction:we}){let _=de(),[v,Te]=(0,s.useState)(null),[y,Ee]=(0,s.useState)(!1),[b,x]=(0,s.useState)(null),[De,Oe]=(0,s.useState)(!1),[ke,Ae]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!1),[w,T]=(0,s.useState)(``),[E,D]=(0,s.useState)(!0),[O,k]=(0,s.useState)(!0),[A,je]=(0,s.useState)(!1),j=(0,s.useRef)(!1),[M,Me]=(0,s.useState)(!0),[N,Ne]=(0,s.useState)(!1),[P,Pe]=(0,s.useState)(100),F=(0,s.useRef)(0),I=(0,s.useRef)(!1),L=(0,s.useRef)(null),[Fe,R]=(0,s.useState)(!1),[Ie,z]=(0,s.useState)(!1),B=(0,s.useRef)(!1),V=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{L.current&&clearTimeout(L.current),V.current&&clearTimeout(V.current)},[]),(0,s.useEffect)(()=>{Ee(!0),Te(null),x(null),C(!1),T(``),D(!0),k(!0),je(!1),j.current=!1,B.current=!1,R(!1),z(!1),V.current&&clearTimeout(V.current),ue({type:`read_file`,path:e.path})},[e.path]),(0,s.useEffect)(()=>{o&&o.path===e.path&&(Te(o),S||T(o.text),Ee(!1),B.current&&(B.current=!1,V.current&&clearTimeout(V.current),R(!1),z(!1),C(!1),T(o.text),j.current&&(m(e.name)&&D(!0),g(e.name)&&k(!0)),x(null)))},[o,S,e.path]),(0,s.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){W();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&S){e.preventDefault(),We();return}let t=e.target,n=t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable);(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`&&!n&&(e.preventDefault(),Be())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p,v,S,w]),(0,s.useEffect)(()=>{let e=()=>{I.current=!1,Oe(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let H=(0,s.useMemo)(()=>{if(!v)return[];let e=v.text.split(`
|
|
2
|
+
`);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,d)},[v]),Le=v?.lines??0,Re=Le>d,ze=(e,t)=>{if(t){let t=F.current>0?F.current:e;x({start:Math.min(t,e),end:Math.max(t,e)})}else F.current=e,x({start:e,end:e})},Be=()=>{H.length!==0&&(F.current=1,x({start:1,end:H.length}))},Ve=()=>{b&&(c(e.path,e.name,b.start,b.end),Ae(!0),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>Ae(!1),1400))},U=v!==null&&v.kind===`text`&&!v.binary&&!v.truncated&&!h(e.name),He=()=>{B.current=!1,V.current&&clearTimeout(V.current),R(!1),z(!1),T(v?.text??``),C(!1),j.current&&(m(e.name)&&D(!0),g(e.name)&&k(!0))},Ue=()=>{if(S){if(w!==(v?.text??``)&&!window.confirm(_(`discardFileChanges`)))return;He();return}U&&v&&(j.current=m(e.name)&&E||g(e.name)&&O,m(e.name)&&D(!1),g(e.name)&&k(!1),x(null),T(v.text),C(!0))},We=()=>{S&&v&&U&&ue({type:`write_file`,path:e.path,text:w})&&(B.current=!0,z(!1),R(!0),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{B.current=!1,R(!1),z(!0)},5e3))},W=()=>{(!S||w===(v?.text??``)||window.confirm(_(`discardFileChanges`)))&&p()},Ge=e=>{Pe(Math.min(200,Math.max(50,e)))},Ke=b?b.end-b.start+1:0,G=v?.binary??!1,qe=v?.truncated??!1,K=v?.kind??`text`,q=m(e.name)||h(e.name),Je=g(e.name),Ye=h(e.name),J=q&&E&&!S&&K===`text`&&!G,Y=Je&&O&&!S&&K===`text`&&!G,[X,Xe]=(0,s.useState)(()=>{try{return localStorage.getItem(f)===`1`}catch{return!1}});(0,s.useEffect)(()=>{try{localStorage.setItem(f,X?`1`:`0`)}catch{}},[X]);let[Z,Ze]=(0,s.useState)([]),[Qe,$e]=(0,s.useState)(``),Q=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=Q.current;if(!e||!J){Ze([]);return}let t=[...e.querySelectorAll(`h1, h2, h3, h4, h5, h6`)],n=Se(t.map(e=>({level:Number(e.tagName.slice(1)),label:e.textContent??``})));t.forEach((e,t)=>{e.id||=n[t].id}),Ze(n)},[J,v?.text,e.path]),(0,s.useEffect)(()=>{let e=Q.current;if(!e||!X||!l(Z))return;let t=Z.map(t=>e.querySelector(`#${CSS.escape(t.id)}`)).filter(e=>e!==null);if(t.length===0)return;let n=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0];t?.target.id&&$e(t.target.id)},{rootMargin:`0px 0px -70% 0px`});for(let e of t)n.observe(e);return()=>n.disconnect()},[Z,X]);let et={"host:fp-md":q&&K===`text`&&!G&&v?(0,u.jsx)(`button`,{type:`button`,className:`fp-attach markdown ${E?`on`:``}`,"data-tip":_(E?`showMarkdownSource`:`showMarkdownPreview`),disabled:S,onClick:()=>D(e=>!e),children:E?(0,u.jsx)(oe,{}):(0,u.jsx)(r,{})}):null,"host:fp-toc":J&&l(Z)?(0,u.jsx)(`button`,{type:`button`,className:`fp-attach toc ${X?`on`:``}`,"data-tip":_(X?`previewTocHide`:`previewTocShow`),onClick:()=>Xe(e=>!e),children:(0,u.jsx)(te,{})}):null,"host:fp-html":Je&&K===`text`&&!G&&v?(0,u.jsx)(`button`,{type:`button`,className:`fp-attach html ${O?`on`:``}`,"data-tip":_(O?`showHtmlSource`:`showHtmlPreview`),disabled:S,onClick:()=>k(e=>!e),children:O?(0,u.jsx)(r,{}):(0,u.jsx)(oe,{})}):null,"host:fp-edit":K===`text`&&!G&&v?(0,u.jsx)(`button`,{type:`button`,className:`fp-attach edit ${S?`on`:``}`,"data-tip":_(qe?`fileEditTruncated`:S?`exitEditFile`:`editFile`),disabled:!U&&!S,onClick:Ue,children:(0,u.jsx)(ee,{})}):null,"host:fp-wrap":K===`text`&&!G&&!J&&!Y?(0,u.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${M?`on`:``}`,"data-tip":_(M?`disableWrap`:`enableWrap`),onClick:()=>Me(e=>!e),children:(0,u.jsx)(re,{})}):null,"host:fp-zoom":K===`text`&&v?(0,u.jsxs)(`span`,{className:`fp-zoom`,children:[(0,u.jsx)(`button`,{type:`button`,className:`fp-attach zoom-out`,"data-tip":_(`zoomOut`),disabled:P<=50,onClick:()=>Ge(P-10),children:(0,u.jsx)(ae,{})}),(0,u.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:_(`resetZoom`),onClick:()=>Pe(100),children:[P,`%`]}),(0,u.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":_(`zoomIn`),disabled:P>=200,onClick:()=>Ge(P+10),children:(0,u.jsx)(se,{})})]}):null,"host:fp-download":(0,u.jsx)(`button`,{type:`button`,className:`fp-attach download`,"data-tip":_(`downloadFile`),onClick:()=>void ve(e.path,e.name),children:(0,u.jsx)(ie,{})}),"host:fp-ref":(0,u.jsx)(`button`,{type:`button`,className:`fp-attach ref`,"data-tip":_(`referenceTip`),onClick:()=>xe(e.path,e.name,`reference`),children:(0,u.jsx)(fe,{})}),"host:fp-full":(0,u.jsx)(`button`,{type:`button`,className:`fp-attach full ${N?`on`:``}`,"data-tip":_(N?`exitFullscreen`:`fullscreen`),onClick:()=>Ne(e=>!e),children:N?(0,u.jsx)(ce,{}):(0,u.jsx)(ne,{})}),"host:fp-close":null},tt=Ce===void 0?[`host:fp-md`,`host:fp-toc`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-download`,`host:fp-ref`,`host:fp-full`].map(e=>({id:e,source:`host`})):Ce.filter(e=>!e.hidden&&e.id!==`host:fp-close`),$=e=>pe(a(`/api/file?clientId=${encodeURIComponent(he())}&path=${encodeURIComponent(e)}`)),nt=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`),n=/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`;return pe(a(`${n}?clientId=${encodeURIComponent(he())}${A?`&allowJs=1`:``}`))};return K===`image`&&!y?(0,u.jsx)(_e,{src:$(e.path),alt:e.name,onClose:W,composerSessionId:me}):(0,u.jsx)(`div`,{className:`fp-overlay ${N?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&W()},children:(0,u.jsxs)(`div`,{className:`fp ${N?`fullscreen`:``} ${Ye?`is-ppt`:``}`,style:{"--fp-zoom":P/100},children:[(0,u.jsxs)(`div`,{className:`fp-head`,onDoubleClick:e=>{let t=e.target;t&&!t.closest(`button, a, input`)&&Ne(e=>!e)},children:[(0,u.jsx)(`span`,{className:`fp-name`,title:e.path,children:e.name}),(0,u.jsx)(`span`,{className:`fp-path`,children:e.path}),(0,u.jsxs)(`span`,{className:`fp-meta`,children:[v&&K===`text`&&!G&&_(`fileLines`,{n:Le}),v&&` · ${be(v.size)}`]}),(0,u.jsx)(`span`,{className:`fp-head-actions`,children:ge(tt,et,we)}),(0,u.jsx)(`button`,{type:`button`,className:`fp-close`,title:_(`close`),"aria-label":_(`close`),onClick:W,children:(0,u.jsx)(le,{})})]}),qe&&K===`text`&&!G&&(0,u.jsx)(`div`,{className:`fp-notice`,children:h(e.name)?_(`previewLinesTruncated`,{n:H.length}):_(`previewTruncated`)}),y&&!v&&(0,u.jsx)(`div`,{className:`fp-empty`,children:_(`loading`)}),!y&&K===`none`&&!G&&(0,u.jsx)(`div`,{className:`fp-empty`,children:_(`previewNotSupported`)}),!y&&K===`video`&&(0,u.jsx)(`div`,{className:`fp-media-wrap`,children:(0,u.jsx)(`video`,{className:`fp-media`,src:$(e.path),controls:!0,preload:`metadata`})}),!y&&K===`audio`&&(0,u.jsx)(`div`,{className:`fp-media-wrap fp-audio-wrap`,children:(0,u.jsxs)(`div`,{className:`fp-audio-card`,children:[(0,u.jsx)(`div`,{className:`fp-audio-icon`,"aria-hidden":`true`,children:`🎵`}),(0,u.jsxs)(`div`,{className:`fp-audio-info`,children:[(0,u.jsx)(`div`,{className:`fp-audio-name`,title:e.name,children:e.name}),v?.size?(0,u.jsx)(`div`,{className:`fp-audio-size`,children:be(v.size)}):null]}),(0,u.jsx)(`audio`,{className:`fp-audio-element`,src:$(e.path),controls:!0,autoPlay:!0,preload:`metadata`})]})}),!y&&Y&&v&&(0,u.jsxs)(`div`,{className:`fp-html`,children:[(0,u.jsxs)(`div`,{className:`fp-html-bar`,children:[(0,u.jsx)(`span`,{className:`fp-html-hint`,title:_(A?`htmlJsOnTip`:`htmlJsOffTip`),children:_(A?`htmlJsOn`:`htmlJsOff`)}),(0,u.jsx)(`button`,{type:`button`,className:`fp-html-js ${A?`on`:``}`,"data-tip":_(A?`htmlDisableJs`:`htmlEnableJs`),onClick:()=>je(e=>!e),children:_(A?`htmlDisableJs`:`htmlEnableJs`)}),(0,u.jsxs)(`a`,{className:`fp-html-btn fp-html-external`,href:nt(e.path),target:`_blank`,rel:`noopener noreferrer`,title:_(`openInNewTab`),children:[(0,u.jsx)(t,{}),(0,u.jsx)(`span`,{children:_(`openInNewTab`)})]})]}),(0,u.jsx)(`iframe`,{className:`fp-html-frame`,src:nt(e.path),title:e.name,sandbox:A?`allow-scripts`:``,referrerPolicy:`no-referrer`},A?`js`:`nojs`)]}),!y&&J&&v&&(0,u.jsx)(`div`,{className:h(e.name)?`fp-markdown msg-text fp-office`:`fp-markdown msg-text`,children:(0,u.jsxs)(`div`,{className:X&&l(Z)?`fp-toc-layout`:void 0,children:[X&&l(Z)&&(0,u.jsx)(`nav`,{className:`fp-toc`,"aria-label":_(`previewTocLabel`),children:Z.map(e=>(0,u.jsx)(`a`,{className:`l${Math.min(e.level,6)}${e.id===Qe?` on`:``}`,href:`#${e.id}`,title:e.label,onClick:t=>{t.preventDefault(),Q.current?.querySelector(`#${CSS.escape(e.id)}`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:e.label},e.id))}),(0,u.jsx)(`div`,{className:`fp-markdown-zoom`,ref:Q,children:(0,u.jsx)(ye,{text:v.text})})]})}),!y&&G&&K!==`image`&&K!==`video`&&v&&(0,u.jsxs)(`div`,{className:`fp-hex-wrap`,children:[(0,u.jsxs)(`div`,{className:`fp-notice`,children:[_(`binaryFile`),v.truncated&&_(`binaryHexTruncated`)]}),(0,u.jsx)(`pre`,{className:`fp-hex`,children:v.text})]}),!y&&S&&K===`text`&&!G&&v&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`textarea`,{className:`fp-editor ${M?``:`no-wrap`}`,value:w,onChange:e=>T(e.target.value),wrap:M?`soft`:`off`,spellCheck:!1,autoFocus:!0}),Ie&&(0,u.jsx)(`div`,{className:`fp-notice`,role:`alert`,children:_(`saveResultUnknown`)})]}),!y&&!J&&!Y&&!S&&K===`text`&&!G&&v&&H.length===0&&(0,u.jsx)(`div`,{className:`fp-empty`,children:_(`emptyFile`)}),!y&&!J&&!Y&&!S&&K===`text`&&!G&&H.length>0&&(0,u.jsxs)(`div`,{className:`fp-code ${De?`dragging`:``} ${M?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[H.map((e,t)=>{let n=t+1,r=b!==null&&n>=b.start&&n<=b.end;return(0,u.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(ze(n,e.shiftKey),I.current=!0,Oe(!0))},onMouseEnter:()=>{I.current&&ze(n,!0)},children:[(0,u.jsx)(`span`,{className:`fp-num`,children:n}),(0,u.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),Re&&(0,u.jsx)(`div`,{className:`fp-lines-note`,children:_(`previewLinesTruncated`,{n:d})})]}),(S||!J&&!Y&&K===`text`)&&(0,u.jsx)(`div`,{className:`fp-foot`,children:S?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:`fp-hint`,children:_(`editFile`)}),(0,u.jsxs)(`div`,{className:`fp-actions`,children:[(0,u.jsx)(`button`,{type:`button`,className:`btn`,onClick:Ue,children:_(`cancel`)}),(0,u.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:Fe||w===(v?.text??``),onClick:We,children:[(0,u.jsx)(i,{}),` `,_(`saveFile`)]})]})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:`fp-hint`,children:b?_(`selectedRange`,{n:Ke,start:b.start,end:b.end}):_(`selectLinesHint`)}),(0,u.jsxs)(`div`,{className:`fp-actions`,children:[(0,u.jsx)(`button`,{type:`button`,className:`btn`,disabled:H.length===0,onClick:Be,children:_(`selectAll`)}),(0,u.jsx)(`button`,{type:`button`,className:`btn`,disabled:!b,onClick:()=>x(null),children:_(`clearSelection`)}),(0,u.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!b||G,onClick:Ve,children:[ke?(0,u.jsx)(n,{}):null,_(ke?`addedToChat`:`addToChat`)]})]})]})})]})})}function m(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function h(e){let t=e.toLowerCase();return t.endsWith(`.docx`)||t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`)||t.endsWith(`.pptx`)||t.endsWith(`.pptm`)||t.endsWith(`.ppsx`)||t.endsWith(`.potx`)}function g(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}export{p as FilePreview};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Rt as t,at as n,i as r,kt as i,mn as a,o,ot as s,qt as c,t as l,wn as u}from"./app-globals-CZjFtI4F.js";import{i as d,t as f}from"./react-CR5VJ85Q.js";import{t as p}from"./composer-bridge-CImnjDHq.js";import{f as m,s as h,u as g}from"./plugin-host-uqZGpvCs.js";import{O as _}from"./index-D_AGu4Zv.js";var v=e(d(),1),y=f();function b(e,t){return e.toLowerCase().includes(t)}function x({open:e,projects:d,fileSearch:f,sessionSearch:x,onClose:S,onSwitchSession:C,onSwitchProject:w,onPreviewFile:T}){let E=u(),D=o(),O=E(`pluginMenuTitle`),k=r(`cwd`),A=(0,v.useRef)(null),[j,M]=(0,v.useState)(``),N=(0,v.useDeferredValue)(j),[P,F]=(0,v.useState)(0),I=(0,v.useRef)(0),L=(0,v.useRef)(null),[R,z]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e)return;l({type:`list_sessions`}),l({type:`list_projects`});let t=j.trim();if(t){let e=_();I.current=e,V(!0),l({type:`search_files`,reqId:e,query:t}),l({type:`search_sessions`,reqId:e,query:t})}requestAnimationFrame(()=>A.current?.select())},[e]);let[B,V]=(0,v.useState)(!1);(0,v.useEffect)(()=>{L.current&&clearTimeout(L.current);let e=N.trim();if(!e){V(!1),z(null);return}return L.current=setTimeout(()=>{let t=_();I.current=t,V(!0),l({type:`search_files`,reqId:t,query:e}),l({type:`search_sessions`,reqId:t,query:e})},300),()=>{L.current&&clearTimeout(L.current)}},[N]),(0,v.useEffect)(()=>{f&&f.reqId===I.current&&z(f)},[f]);let H=N.trim().toLowerCase(),U=(0,v.useMemo)(()=>!H||!x||x.reqId!==I.current||!x.ok?[]:x.results,[x,H]),W=(0,v.useMemo)(()=>H?d.filter(e=>b(e.path,H)).slice(0,10):[],[d,H]),G=(0,v.useMemo)(()=>!H||!R||!R.ok?[]:R.results,[R,H]);(0,v.useEffect)(()=>{R&&R.reqId===I.current&&x&&x.reqId===I.current&&I.current!==0&&V(!1)},[R,x]);let K=!!R&&R.ok&&R.truncated,[q,J]=(0,v.useState)([]);(0,v.useEffect)(()=>{if(!e)return;let t=N.trim();if(!t){J([]);return}let n=!1,r=[];try{let e=window,t=e.__piWebUiHost?.searchProviders?.list;if(typeof t==`function`){let n=t.call(e.__piWebUiHost);Array.isArray(n)&&(r=n)}else typeof g==`function`&&(r=g())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=h(e.id);return t&&typeof t.search==`function`?{...e,search:t.search}:null}catch{return null}}).filter(e=>!!e);if(i.length===0){J([]);return}return Promise.allSettled(i.map(e=>Promise.race([e.search(t),new Promise((e,t)=>setTimeout(()=>t(Error(`timeout`)),3e3))]).then(t=>({provider:e,items:Array.isArray(t)?t:[]}),()=>({provider:e,items:[]})))).then(e=>{if(n)return;let t=[];for(let n of e)if(n.status===`fulfilled`)for(let e of n.value.items){if(!e||typeof e!=`object`)continue;let r=e;typeof r.title==`string`&&typeof r.action==`string`&&t.push({providerId:n.value.provider.id,providerLabel:n.value.provider.label,title:r.title,...typeof r.hint==`string`?{hint:r.hint}:{},action:r.action})}J(t.slice(0,20))}),()=>{n=!0}},[e,N]);let Y=(0,v.useMemo)(()=>[...U.map(e=>({kind:`session`,path:e.path,anchors:e.anchors})),...W.map(e=>({kind:`project`,path:e.path})),...G.filter(e=>e.type===`file`).map(e=>({kind:`file`,path:e.path,name:e.name})),...q.map(e=>({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}))],[U,W,G,q]);(0,v.useEffect)(()=>{F(0)},[N]);let X=(0,v.useCallback)(e=>{if(e){if(e.kind===`session`)C(e.path,e.anchors),S();else if(e.kind===`project`){w(e.path),l({type:`list_sessions`}),l({type:`list_projects`});let t=N.trim();if(t){let e=_();I.current=e,V(!0),l({type:`search_files`,reqId:e,query:t}),l({type:`search_sessions`,reqId:e,query:t})}}else e.kind===`plugin`?m(e.providerId,e.action,e.action).catch(()=>{}):T(e.path,e.name)}},[C,w,T,N]);(0,v.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),S()):e.key===`ArrowDown`?(e.preventDefault(),F(e=>Math.max(0,Math.min(e+1,Y.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),F(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),X(Y[P]))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[Y,P,X,S,e]);let Z=U.length+W.length+G.length+q.length,Q=(e,t,n)=>(0,y.jsxs)(`div`,{className:`gs-section-head`,children:[n,(0,y.jsx)(`span`,{children:e}),(0,y.jsx)(`em`,{children:t})]}),$=-1;return e?(0,y.jsx)(`div`,{className:`modal-backdrop gs-backdrop`,onClick:S,children:(0,y.jsxs)(`div`,{className:`gs-modal`,onClick:e=>e.stopPropagation(),children:[(0,y.jsxs)(`div`,{className:`gs-input-row`,children:[(0,y.jsx)(c,{}),(0,y.jsx)(`input`,{ref:A,type:`text`,value:j,placeholder:E(`gsPlaceholder`),onChange:e=>M(e.target.value)}),(0,y.jsx)(`button`,{type:`button`,className:`gs-close`,title:E(`close`),onClick:S,children:(0,y.jsx)(a,{})})]}),(0,y.jsxs)(`div`,{className:`gs-results`,children:[!H&&(0,y.jsx)(`div`,{className:`gs-empty`,children:E(`gsHint`)}),H&&Z===0&&!K&&(0,y.jsx)(`div`,{className:`gs-empty`,children:E(B?`gsSearching`:`gsNoResults`)}),U.length>0&&(0,y.jsxs)(`div`,{className:`gs-section`,children:[Q(E(`gsSessions`),U.length,(0,y.jsx)(i,{})),U.map(e=>{$++;let t=$,n=e.displayName||e.name||e.firstMessage?.trim()||(e.path.split(/[\\/]/).pop()||e.path).replace(/\.jsonl$/i,``);return(0,y.jsxs)(`div`,{className:`gs-item-wrap`,children:[(0,y.jsxs)(`button`,{type:`button`,className:t===P?`gs-item active`:`gs-item`,onMouseEnter:()=>F(t),onClick:()=>X({kind:`session`,path:e.path,anchors:e.anchors}),children:[(0,y.jsxs)(`span`,{className:`gs-item-title`,children:[n,(0,y.jsx)(`em`,{className:`gs-item-meta`,children:e.messageCount})]}),(0,y.jsx)(`span`,{className:`gs-item-sub`,children:e.firstMessage})]}),D.conversationRef&&(0,y.jsxs)(`button`,{type:`button`,className:`gs-quote`,title:E(`quoteConversation`),onClick:t=>{t.stopPropagation(),p({attachments:[{path:``,key:`conv||${e.path}`,name:n,mode:`conversation`,sessionPath:e.path}]})},children:[`💬 `,E(`quoteConversationShort`)]})]},e.path)})]}),W.length>0&&(0,y.jsxs)(`div`,{className:`gs-section`,children:[Q(E(`gsProjects`),W.length,(0,y.jsx)(s,{})),W.map(e=>{$++;let t=$,n=k&&e.path===k;return(0,y.jsxs)(`button`,{type:`button`,className:t===P?`gs-item active`:`gs-item`,onMouseEnter:()=>F(t),onClick:()=>X({kind:`project`,path:e.path}),children:[(0,y.jsxs)(`span`,{className:`gs-item-title`,children:[e.path.split(/[\\/]/).pop(),n&&(0,y.jsx)(`em`,{className:`gs-item-meta`,children:E(`gsCurrentProject`)})]}),(0,y.jsx)(`span`,{className:`gs-item-sub`,children:e.path})]},e.path)})]}),(G.length>0||H&&K)&&(0,y.jsxs)(`div`,{className:`gs-section`,children:[Q(E(`gsFiles`),G.length,(0,y.jsx)(n,{})),G.map(e=>{$++;let t=$;return(0,y.jsxs)(`button`,{type:`button`,className:t===P?`gs-item active`:`gs-item`,disabled:e.type===`dir`,title:e.type===`dir`?void 0:E(`gsOpenPreview`),onMouseEnter:()=>F(t),onClick:()=>{e.type===`file`&&X({kind:`file`,path:e.path,name:e.name})},children:[(0,y.jsx)(`span`,{className:`gs-item-title`,children:e.name}),(0,y.jsx)(`span`,{className:`gs-item-sub`,children:e.path})]},`${e.type}:${e.path}`)}),K&&(0,y.jsx)(`div`,{className:`gs-truncated`,children:E(`gsTruncated`)})]}),q.length>0&&(0,y.jsxs)(`div`,{className:`gs-section`,children:[Q(O,q.length,(0,y.jsx)(t,{})),q.map((e,t)=>{$++;let n=$;return(0,y.jsxs)(`button`,{type:`button`,className:n===P?`gs-item active`:`gs-item`,title:e.providerLabel,onMouseEnter:()=>F(n),onClick:()=>X({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}),children:[(0,y.jsx)(`span`,{className:`gs-item-title`,children:e.title}),(0,y.jsx)(`span`,{className:`gs-item-sub`,children:e.hint??e.providerLabel})]},`${e.providerId}:${e.action}:${t}`)})]})]}),(0,y.jsxs)(`div`,{className:`gs-foot`,children:[(0,y.jsxs)(`span`,{children:[`↑↓ `,E(`gsNavigate`)]}),(0,y.jsxs)(`span`,{children:[`Enter `,E(`gsOpen`)]}),(0,y.jsxs)(`span`,{children:[`Esc `,E(`gsCloseHint`)]})]})]})}):null}export{x as GlobalSearchModal};
|