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,259 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
export const WINDOWS_SCREENSHOT_SOURCE = String.raw `
|
|
3
|
+
using System;
|
|
4
|
+
using System.Diagnostics;
|
|
5
|
+
using System.Drawing;
|
|
6
|
+
using System.Drawing.Imaging;
|
|
7
|
+
using System.IO;
|
|
8
|
+
using System.Runtime.InteropServices;
|
|
9
|
+
using System.Text;
|
|
10
|
+
using System.Threading.Tasks;
|
|
11
|
+
using System.Windows.Forms;
|
|
12
|
+
|
|
13
|
+
public sealed class PiScreenSelection : Form {
|
|
14
|
+
[DllImport("user32.dll")] static extern IntPtr GetForegroundWindow();
|
|
15
|
+
[DllImport("user32.dll", CharSet = CharSet.Unicode)] static extern int GetWindowText(IntPtr h, StringBuilder text, int count);
|
|
16
|
+
[DllImport("user32.dll")] static extern bool ShowWindow(IntPtr h, int command);
|
|
17
|
+
[DllImport("user32.dll")] static extern bool SetForegroundWindow(IntPtr h);
|
|
18
|
+
[DllImport("user32.dll")] static extern bool IsWindow(IntPtr h);
|
|
19
|
+
[DllImport("user32.dll")] static extern bool IsZoomed(IntPtr h);
|
|
20
|
+
[DllImport("user32.dll")] static extern bool SetProcessDpiAwarenessContext(IntPtr context);
|
|
21
|
+
[DllImport("user32.dll")] static extern bool SetProcessDPIAware();
|
|
22
|
+
readonly Bitmap screen;
|
|
23
|
+
readonly string hint;
|
|
24
|
+
readonly System.Windows.Forms.Timer timer;
|
|
25
|
+
Point start;
|
|
26
|
+
Rectangle selection;
|
|
27
|
+
bool dragging;
|
|
28
|
+
public Bitmap Result;
|
|
29
|
+
|
|
30
|
+
PiScreenSelection(Bitmap screen, Rectangle bounds, string hint, Task<string> cancel, Process parent) {
|
|
31
|
+
this.screen = screen;
|
|
32
|
+
this.hint = hint;
|
|
33
|
+
Text = "pi-web-ui system screenshot";
|
|
34
|
+
FormBorderStyle = FormBorderStyle.None;
|
|
35
|
+
AutoScaleMode = AutoScaleMode.None;
|
|
36
|
+
StartPosition = FormStartPosition.Manual;
|
|
37
|
+
Bounds = bounds;
|
|
38
|
+
ShowInTaskbar = false;
|
|
39
|
+
TopMost = true;
|
|
40
|
+
DoubleBuffered = true;
|
|
41
|
+
KeyPreview = true;
|
|
42
|
+
Cursor = Cursors.Cross;
|
|
43
|
+
var deadline = DateTime.UtcNow.AddSeconds(90);
|
|
44
|
+
timer = new System.Windows.Forms.Timer { Interval = 100 };
|
|
45
|
+
timer.Tick += (s, e) => {
|
|
46
|
+
if (cancel.IsCompleted || parent.HasExited || DateTime.UtcNow >= deadline) Close();
|
|
47
|
+
};
|
|
48
|
+
timer.Start();
|
|
49
|
+
}
|
|
50
|
+
protected override void Dispose(bool disposing) {
|
|
51
|
+
if (disposing) timer.Dispose();
|
|
52
|
+
base.Dispose(disposing);
|
|
53
|
+
}
|
|
54
|
+
protected override void OnShown(EventArgs e) {
|
|
55
|
+
base.OnShown(e);
|
|
56
|
+
Activate();
|
|
57
|
+
SetForegroundWindow(Handle);
|
|
58
|
+
}
|
|
59
|
+
protected override void OnPaint(PaintEventArgs e) {
|
|
60
|
+
e.Graphics.DrawImageUnscaled(screen, 0, 0);
|
|
61
|
+
using (var shade = new SolidBrush(Color.FromArgb(115, 0, 0, 0)))
|
|
62
|
+
using (var outside = new Region(ClientRectangle)) {
|
|
63
|
+
if (selection.Width > 0 && selection.Height > 0) outside.Exclude(selection);
|
|
64
|
+
e.Graphics.FillRegion(shade, outside);
|
|
65
|
+
}
|
|
66
|
+
if (selection.Width > 0 && selection.Height > 0) {
|
|
67
|
+
e.Graphics.DrawRectangle(Pens.White, selection.X, selection.Y, selection.Width - 1, selection.Height - 1);
|
|
68
|
+
}
|
|
69
|
+
// Keep instructions on the display containing the pointer, including negative-origin monitors.
|
|
70
|
+
var display = Screen.FromPoint(Cursor.Position).Bounds;
|
|
71
|
+
var position = new Point(display.Left - Left + 20, display.Top - Top + 20);
|
|
72
|
+
using (var background = new SolidBrush(Color.FromArgb(210, 0, 0, 0))) {
|
|
73
|
+
var size = e.Graphics.MeasureString(hint, SystemFonts.MessageBoxFont);
|
|
74
|
+
e.Graphics.FillRectangle(background, position.X - 8, position.Y - 6, size.Width + 16, size.Height + 12);
|
|
75
|
+
e.Graphics.DrawString(hint, SystemFonts.MessageBoxFont, Brushes.White, position);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
Point Clamp(Point p) {
|
|
79
|
+
return new Point(Math.Max(0, Math.Min(screen.Width, p.X)), Math.Max(0, Math.Min(screen.Height, p.Y)));
|
|
80
|
+
}
|
|
81
|
+
void UpdateSelection(Point end) {
|
|
82
|
+
end = Clamp(end);
|
|
83
|
+
selection = Rectangle.FromLTRB(Math.Min(start.X, end.X), Math.Min(start.Y, end.Y),
|
|
84
|
+
Math.Max(start.X, end.X), Math.Max(start.Y, end.Y));
|
|
85
|
+
Invalidate();
|
|
86
|
+
}
|
|
87
|
+
protected override void OnMouseDown(MouseEventArgs e) {
|
|
88
|
+
if (e.Button == MouseButtons.Right) { Close(); return; }
|
|
89
|
+
if (e.Button != MouseButtons.Left) return;
|
|
90
|
+
start = Clamp(e.Location);
|
|
91
|
+
dragging = true;
|
|
92
|
+
Capture = true;
|
|
93
|
+
UpdateSelection(start);
|
|
94
|
+
}
|
|
95
|
+
protected override void OnMouseMove(MouseEventArgs e) {
|
|
96
|
+
if (dragging) UpdateSelection(e.Location);
|
|
97
|
+
}
|
|
98
|
+
protected override void OnMouseUp(MouseEventArgs e) {
|
|
99
|
+
if (e.Button != MouseButtons.Left || !dragging) return;
|
|
100
|
+
UpdateSelection(e.Location);
|
|
101
|
+
dragging = false;
|
|
102
|
+
Capture = false;
|
|
103
|
+
if (selection.Width < 2 || selection.Height < 2) { Invalidate(); return; }
|
|
104
|
+
Result = screen.Clone(selection, PixelFormat.Format32bppArgb);
|
|
105
|
+
Close();
|
|
106
|
+
}
|
|
107
|
+
protected override void OnKeyDown(KeyEventArgs e) {
|
|
108
|
+
if (e.KeyCode == Keys.Escape) { e.Handled = true; Close(); }
|
|
109
|
+
base.OnKeyDown(e);
|
|
110
|
+
}
|
|
111
|
+
public static void Run(string token, string hint, int parentId, bool hideWindow) {
|
|
112
|
+
try { SetProcessDpiAwarenessContext(new IntPtr(-4)); }
|
|
113
|
+
catch (EntryPointNotFoundException) { SetProcessDPIAware(); }
|
|
114
|
+
var window = GetForegroundWindow();
|
|
115
|
+
var title = new StringBuilder(2048);
|
|
116
|
+
GetWindowText(window, title, title.Capacity);
|
|
117
|
+
// Never minimize a different foreground window if focus changed during helper startup.
|
|
118
|
+
if (hideWindow && (window == IntPtr.Zero || title.ToString().IndexOf(token, StringComparison.Ordinal) < 0))
|
|
119
|
+
throw new InvalidOperationException("window-not-focused");
|
|
120
|
+
var restore = IsZoomed(window) ? 3 : 9;
|
|
121
|
+
using (var parent = Process.GetProcessById(parentId)) {
|
|
122
|
+
// Console.In.ReadLineAsync can block synchronously on .NET Framework's SyncTextReader.
|
|
123
|
+
var cancel = Task.Run(() => Console.In.ReadLine());
|
|
124
|
+
if (cancel.IsCompleted || parent.HasExited) return;
|
|
125
|
+
// Only hidden windows need recovery if the helper cannot exit normally.
|
|
126
|
+
if (hideWindow) {
|
|
127
|
+
Console.Error.WriteLine("window:" + window.ToInt64() + ":" + restore);
|
|
128
|
+
Console.Error.Flush();
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
if (hideWindow) ShowWindow(window, 6);
|
|
132
|
+
System.Threading.Thread.Sleep(400);
|
|
133
|
+
if (cancel.IsCompleted || parent.HasExited) return;
|
|
134
|
+
var bounds = SystemInformation.VirtualScreen;
|
|
135
|
+
if ((long)bounds.Width * bounds.Height > 100000000)
|
|
136
|
+
throw new InvalidOperationException("screen-too-large");
|
|
137
|
+
using (var screen = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb)) {
|
|
138
|
+
using (var graphics = Graphics.FromImage(screen))
|
|
139
|
+
graphics.CopyFromScreen(bounds.Location, Point.Empty, bounds.Size, CopyPixelOperation.SourceCopy);
|
|
140
|
+
using (var picker = new PiScreenSelection(screen, bounds, hint, cancel, parent)) {
|
|
141
|
+
Application.Run(picker);
|
|
142
|
+
using (var result = picker.Result) {
|
|
143
|
+
if (result == null) return;
|
|
144
|
+
using (var stream = new MemoryStream()) {
|
|
145
|
+
result.Save(stream, ImageFormat.Png);
|
|
146
|
+
Console.Out.Write(Convert.ToBase64String(stream.ToArray()));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
} finally {
|
|
152
|
+
if (hideWindow && IsWindow(window)) {
|
|
153
|
+
ShowWindow(window, restore);
|
|
154
|
+
SetForegroundWindow(window);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
`;
|
|
161
|
+
export function windowsScreenshotScript(token, locale, parentId = process.pid, hideWindow = true) {
|
|
162
|
+
if (!/^[a-f0-9]{32}$/.test(token))
|
|
163
|
+
throw new Error("invalid screenshot token");
|
|
164
|
+
const hint = locale === "zh"
|
|
165
|
+
? "拖动框选 · 松开完成 · Esc / 右键取消"
|
|
166
|
+
: "Drag to select · Release to capture · Esc / right click to cancel";
|
|
167
|
+
return `$ErrorActionPreference = 'Stop'
|
|
168
|
+
Add-Type -TypeDefinition @'
|
|
169
|
+
${WINDOWS_SCREENSHOT_SOURCE}
|
|
170
|
+
'@ -ReferencedAssemblies System.Windows.Forms,System.Drawing
|
|
171
|
+
try { [PiScreenSelection]::Run('${token}', '${hint}', ${parentId}, $${hideWindow ? "true" : "false"}) }
|
|
172
|
+
catch { [Console]::Error.WriteLine($_.Exception.ToString()); exit 1 }
|
|
173
|
+
`;
|
|
174
|
+
}
|
|
175
|
+
const MAX_IMAGE_BYTES = 64 * 1024 * 1024;
|
|
176
|
+
const PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
177
|
+
export function captureWindowsScreenshot(token, locale, signal, hideWindow = true) {
|
|
178
|
+
if (signal.aborted)
|
|
179
|
+
return Promise.resolve(null);
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
181
|
+
const script = windowsScreenshotScript(token, locale, process.pid, hideWindow);
|
|
182
|
+
const child = spawn("powershell.exe", [
|
|
183
|
+
"-NoLogo",
|
|
184
|
+
"-NoProfile",
|
|
185
|
+
"-NonInteractive",
|
|
186
|
+
"-STA",
|
|
187
|
+
"-EncodedCommand",
|
|
188
|
+
Buffer.from(script, "utf16le").toString("base64"),
|
|
189
|
+
], { windowsHide: true, stdio: ["pipe", "pipe", "pipe"] });
|
|
190
|
+
const chunks = [];
|
|
191
|
+
let bytes = 0;
|
|
192
|
+
let stderr = "";
|
|
193
|
+
let failure = null;
|
|
194
|
+
let forceTimer;
|
|
195
|
+
let closing = false;
|
|
196
|
+
const cancel = () => {
|
|
197
|
+
if (closing)
|
|
198
|
+
return;
|
|
199
|
+
closing = true;
|
|
200
|
+
child.stdin.end("cancel\n");
|
|
201
|
+
forceTimer = setTimeout(() => {
|
|
202
|
+
child.kill();
|
|
203
|
+
const window = /window:(\d+):(3|9)/.exec(stderr);
|
|
204
|
+
if (!window)
|
|
205
|
+
return;
|
|
206
|
+
const recovery = `Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public class PiRestore { [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr h, int n); }'; [PiRestore]::ShowWindow([IntPtr]${window[1]}, ${window[2]}) | Out-Null`;
|
|
207
|
+
const restore = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", recovery], {
|
|
208
|
+
windowsHide: true,
|
|
209
|
+
stdio: "ignore",
|
|
210
|
+
});
|
|
211
|
+
restore.on("error", () => { });
|
|
212
|
+
}, 5000);
|
|
213
|
+
};
|
|
214
|
+
child.stdin.on("error", () => { });
|
|
215
|
+
const timeout = setTimeout(() => {
|
|
216
|
+
failure = new Error("screenshot-timeout");
|
|
217
|
+
cancel();
|
|
218
|
+
}, 150_000);
|
|
219
|
+
const cleanup = () => {
|
|
220
|
+
clearTimeout(timeout);
|
|
221
|
+
clearTimeout(forceTimer);
|
|
222
|
+
signal.removeEventListener("abort", cancel);
|
|
223
|
+
};
|
|
224
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
225
|
+
if (signal.aborted)
|
|
226
|
+
cancel();
|
|
227
|
+
child.stdout.on("data", (chunk) => {
|
|
228
|
+
bytes += chunk.length;
|
|
229
|
+
if (bytes > MAX_IMAGE_BYTES) {
|
|
230
|
+
failure = new Error("screen-too-large");
|
|
231
|
+
cancel();
|
|
232
|
+
}
|
|
233
|
+
else
|
|
234
|
+
chunks.push(chunk);
|
|
235
|
+
});
|
|
236
|
+
child.stderr.on("data", (chunk) => {
|
|
237
|
+
stderr = (stderr + chunk.toString()).slice(-8192);
|
|
238
|
+
});
|
|
239
|
+
child.once("error", (error) => {
|
|
240
|
+
cleanup();
|
|
241
|
+
reject(error);
|
|
242
|
+
});
|
|
243
|
+
child.once("close", (code) => {
|
|
244
|
+
cleanup();
|
|
245
|
+
if (failure)
|
|
246
|
+
return reject(failure);
|
|
247
|
+
if (signal.aborted)
|
|
248
|
+
return resolve(null);
|
|
249
|
+
if (code !== 0)
|
|
250
|
+
return reject(new Error(stderr.includes("window-not-focused") ? "window-not-focused" : "capture-failed"));
|
|
251
|
+
const base64 = Buffer.concat(chunks).toString().trim();
|
|
252
|
+
if (!base64)
|
|
253
|
+
return resolve(null);
|
|
254
|
+
if (!Buffer.from(base64.slice(0, 12), "base64").subarray(0, 8).equals(PNG_SIGNATURE))
|
|
255
|
+
return reject(new Error("capture-failed"));
|
|
256
|
+
resolve(`data:image/png;base64,${base64}`);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { hostWithoutPort, isLoopbackHost } from "./host-guard.js";
|
|
2
|
+
import { isLoopbackAddress } from "./server-config.js";
|
|
3
|
+
import { captureWindowsScreenshot } from "./system-screenshot-windows.js";
|
|
4
|
+
export function isLocalScreenshotRequest(req) {
|
|
5
|
+
if (!isLoopbackAddress(req.socket.remoteAddress))
|
|
6
|
+
return false;
|
|
7
|
+
if (req.headers.forwarded || req.headers["x-forwarded-for"] || req.headers["x-real-ip"])
|
|
8
|
+
return false;
|
|
9
|
+
const host = req.headers.host ?? "";
|
|
10
|
+
if (!isLoopbackHost(hostWithoutPort(host)))
|
|
11
|
+
return false;
|
|
12
|
+
if (req.headers["sec-fetch-site"] === "cross-site")
|
|
13
|
+
return false;
|
|
14
|
+
const origin = req.headers.origin;
|
|
15
|
+
if (!origin)
|
|
16
|
+
return true;
|
|
17
|
+
try {
|
|
18
|
+
const url = new URL(origin);
|
|
19
|
+
return ["http:", "https:"].includes(url.protocol) && url.host === host;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function registerSystemScreenshotRoutes(app, options = {}) {
|
|
26
|
+
const platform = options.platform ?? process.platform;
|
|
27
|
+
const capture = options.capture ?? captureWindowsScreenshot;
|
|
28
|
+
let busy = false;
|
|
29
|
+
app.get("/api/system-screenshot", (req, res) => {
|
|
30
|
+
res.setHeader("Cache-Control", "no-store");
|
|
31
|
+
res.json({ available: platform === "win32" && isLocalScreenshotRequest(req) });
|
|
32
|
+
});
|
|
33
|
+
app.post("/api/system-screenshot", async (req, res) => {
|
|
34
|
+
res.setHeader("Cache-Control", "no-store");
|
|
35
|
+
if (!isLocalScreenshotRequest(req)) {
|
|
36
|
+
res.status(403).json({ error: "local-only" });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (platform !== "win32") {
|
|
40
|
+
res.status(501).json({ error: "unsupported" });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { token, locale, hideWindow = true } = req.body ?? {};
|
|
44
|
+
if (typeof token !== "string" ||
|
|
45
|
+
!/^[a-f0-9]{32}$/.test(token) ||
|
|
46
|
+
(locale !== "zh" && locale !== "en") ||
|
|
47
|
+
typeof hideWindow !== "boolean") {
|
|
48
|
+
res.status(400).json({ error: "invalid-request" });
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (busy) {
|
|
52
|
+
res.status(409).json({ error: "busy" });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
busy = true;
|
|
56
|
+
const controller = new AbortController();
|
|
57
|
+
const disconnect = () => controller.abort();
|
|
58
|
+
res.once("close", disconnect);
|
|
59
|
+
try {
|
|
60
|
+
const dataUrl = await capture(token, locale, controller.signal, hideWindow);
|
|
61
|
+
if (!res.destroyed)
|
|
62
|
+
res.json({ cancelled: dataUrl === null, ...(dataUrl ? { dataUrl } : {}) });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
const reason = error instanceof Error ? error.message : "capture-failed";
|
|
66
|
+
const code = ["window-not-focused", "screen-too-large", "screenshot-timeout"].includes(reason)
|
|
67
|
+
? reason
|
|
68
|
+
: "capture-failed";
|
|
69
|
+
if (!res.destroyed)
|
|
70
|
+
res.status(500).json({ error: code });
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
res.off("close", disconnect);
|
|
74
|
+
busy = false;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
package/dist/server/tabs.js
CHANGED
|
@@ -1,41 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tabs — choose what an instance offers.
|
|
3
|
-
*
|
|
4
|
-
* pi-web-ui shows Chat, Terminal, Git, Search, Background tasks and Settings,
|
|
5
|
-
* always, plus a tab per installed plugin. On the machine you are working on
|
|
6
|
-
* that is the point of the tool. Exposed to other people it is not: Terminal
|
|
7
|
-
* opens a shell as the server's user, and Git shows the working copy with
|
|
8
|
-
* commit and diff a click away. Today there is no way to leave those out.
|
|
9
|
-
*
|
|
10
|
-
* `PI_WEB_TABS=chat,search,settings` is that way. Absent — the default —
|
|
11
|
-
* means every tab, so nothing changes for anybody who does not set it.
|
|
12
|
-
*
|
|
13
|
-
* The rule that shapes the whole thing: **a hidden tab whose messages the
|
|
14
|
-
* server still accepts is a hidden tab, not a disabled one.** Anything that
|
|
15
|
-
* can open the WebSocket can send `terminal_create`. So the client stops
|
|
16
|
-
* drawing them and the server stops answering them, and the second half is the
|
|
17
|
-
* one that matters.
|
|
18
|
-
*
|
|
19
|
-
* Chat is never off: it is the application.
|
|
20
|
-
*/
|
|
21
|
-
/** Every tab that can be listed. `chat` is always on and is listed for symmetry. */
|
|
22
1
|
export const ALL_TABS = ["chat", "terminal", "git", "search", "tasks", "settings", "plugins"];
|
|
23
|
-
/**
|
|
24
|
-
* The messages each tab owns exclusively.
|
|
25
|
-
*
|
|
26
|
-
* Only exclusive ones: `abort_bash` stops the agent's own bash tool inside a
|
|
27
|
-
* chat answer, not a terminal the user opened, so it is not listed — turning
|
|
28
|
-
* off the Terminal tab must not change what the agent can do in a conversation.
|
|
29
|
-
*
|
|
30
|
-
* `run_command` is listed under terminal because it starts a process in one:
|
|
31
|
-
* leaving it out would take the tab away and leave the shell reachable, which
|
|
32
|
-
* is exactly the failure this module exists to prevent.
|
|
33
|
-
*/
|
|
34
2
|
const OWNED = {
|
|
35
3
|
terminal: [
|
|
4
|
+
"new_cli_chat",
|
|
36
5
|
"terminal_attach",
|
|
37
6
|
"terminal_create",
|
|
38
7
|
"terminal_input",
|
|
8
|
+
"terminal_cli_paste",
|
|
9
|
+
"terminal_cli_control",
|
|
39
10
|
"terminal_resize",
|
|
40
11
|
"terminal_kill",
|
|
41
12
|
"rename_terminal",
|
|
@@ -45,14 +16,6 @@ const OWNED = {
|
|
|
45
16
|
tasks: ["list_bg_servers", "kill_background_server", "kill_background_servers"],
|
|
46
17
|
search: ["search_files", "search_sessions"],
|
|
47
18
|
};
|
|
48
|
-
/**
|
|
49
|
-
* The allow-list, or null when there is none.
|
|
50
|
-
*
|
|
51
|
-
* Case and spaces are forgiven because this is written by hand in a systemd
|
|
52
|
-
* unit or a compose file. Unknown names are kept rather than rejected: a
|
|
53
|
-
* plugin tab, or a tab a later version adds, should not make the server fail
|
|
54
|
-
* to start.
|
|
55
|
-
*/
|
|
56
19
|
export function parseTabs(env = process.env) {
|
|
57
20
|
const raw = (env.PI_WEB_TABS ?? "").trim();
|
|
58
21
|
if (!raw)
|
|
@@ -66,7 +29,6 @@ export function parseTabs(env = process.env) {
|
|
|
66
29
|
tabs.add("chat");
|
|
67
30
|
return tabs;
|
|
68
31
|
}
|
|
69
|
-
/** Whether a tab is offered. No list means every tab. */
|
|
70
32
|
export function isTabAllowed(tab, tabs) {
|
|
71
33
|
if (!tabs)
|
|
72
34
|
return true;
|
|
@@ -74,13 +36,6 @@ export function isTabAllowed(tab, tabs) {
|
|
|
74
36
|
return true;
|
|
75
37
|
return tabs.has(tab.toLowerCase());
|
|
76
38
|
}
|
|
77
|
-
/**
|
|
78
|
-
* The reason to refuse a message, or null when it may proceed.
|
|
79
|
-
*
|
|
80
|
-
* Returning the sentence rather than a boolean keeps the call site one line and
|
|
81
|
-
* puts the explanation next to the rule: the user sees why, instead of a
|
|
82
|
-
* message that vanishes.
|
|
83
|
-
*/
|
|
84
39
|
export function tabsRefusal(type, tabs) {
|
|
85
40
|
if (!tabs)
|
|
86
41
|
return null;
|