pi-web-ui 0.117.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 +48 -2
- 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 +147 -43
- 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 +56 -444
- 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 +160 -374
- package/dist/server/agent-service.js +875 -2978
- 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 +26 -30
- 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 +6 -213
- 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 +3 -76
- 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 +0 -82
- 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 +0 -8
- 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 +1 -3
- package/dist/server/device-center/collab-tool.js +0 -10
- package/dist/server/device-center/connector.js +21 -11
- package/dist/server/device-center/delivery-authority.js +0 -3
- package/dist/server/device-center/delivery-subject.js +0 -1
- 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 +1 -27
- 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 +0 -1
- 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 +0 -27
- 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 +0 -12
- package/dist/server/device-center/hub-deliveries.js +0 -1
- package/dist/server/device-center/hub-integration.js +0 -8
- 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 +25 -7
- package/dist/server/device-center/hub-setup.js +0 -6
- package/dist/server/device-center/hub-transaction-log.js +0 -22
- 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 +210 -86
- 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 +0 -2
- package/dist/server/device-center/local-hub.js +0 -2
- package/dist/server/device-center/local-publication.js +1 -8
- package/dist/server/device-center/local-verification-job.js +0 -2
- package/dist/server/device-center/local-verification.js +0 -1
- package/dist/server/device-center/local.js +267 -39
- package/dist/server/device-center/main.js +14 -1
- 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 +0 -31
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +0 -7
- package/dist/server/device-center/publish-intent.js +0 -5
- package/dist/server/device-center/relay.js +85 -30
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +1 -18
- package/dist/server/device-center/store.js +13 -33
- 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 +0 -13
- 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 +5 -88
- 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 +0 -18
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +0 -50
- 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 +0 -1
- package/dist/server/device-center/work-contract.js +1 -73
- 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 +190 -32
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +69 -599
- 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 +177 -680
- 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 +3 -43
- package/dist/server/patch-remote-catalog.js +1 -32
- 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 +9 -62
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +3 -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 +34 -1
- package/dist/server/quick-ask.js +123 -27
- 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 +0 -26
- 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 +3 -54
- 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 +17 -25
- package/dist/server/session-open.js +2 -26
- package/dist/server/session-parser.js +1 -55
- package/dist/server/session-scan.js +1 -17
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +11 -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 +0 -42
- 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 +1 -19
- 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 +12 -172
- 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 +26 -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 +1 -56
- 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 +37 -1
- package/docs/device-center.md +28 -2
- 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 +7 -3
- package/plugin-sdk/README.md +6 -0
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +0 -1
- package/plugin-sdk/client.mjs +1 -31
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +120 -119
- package/plugin-sdk/index.mjs +0 -6
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +0 -1
- package/plugin-sdk/testing.mjs +31 -86
- 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 +1 -9
- package/themes/flow-ink.css +1 -10
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +1 -10
- package/themes/flow-zurich.css +1 -10
- 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-BjNRIUIc.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-CQtstPGv.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-ChTW8o1m.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-BX5rUuoI.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/{SCMPanel-DPAyY2sW.js → SCMPanel-CuEgzAlO.js} +2 -2
- 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-Dzi-eEyE.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +11 -10
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/web/dist/assets/BgTasksModal-C0zuU8FE.js +0 -1
- package/web/dist/assets/CanvasStudio-BWvdmJ0M.js +0 -1579
- package/web/dist/assets/CanvasStudio-VQFjmTGq.js +0 -1579
- package/web/dist/assets/DeviceCenter-DI9_0aBB.js +0 -3
- package/web/dist/assets/DeviceCenter-DsNtXqzY.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +0 -1
- package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +0 -1
- package/web/dist/assets/DeviceGroups-CP7CcyPD.js +0 -1
- package/web/dist/assets/FilePreview-BMB2tNyT.js +0 -2
- package/web/dist/assets/FilePreview-RGFQUbJo.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BM5wxiqU.js +0 -1
- package/web/dist/assets/GlobalSearchModal-DGv_WINq.js +0 -1
- package/web/dist/assets/GroupConversation-B7SnuXj1.js +0 -61
- package/web/dist/assets/GroupConversation-Dda69q-2.js +0 -61
- package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +0 -2
- package/web/dist/assets/ModelConfigModal-yqeadyab.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-DY4SCfXg.js +0 -1
- package/web/dist/assets/SCMPanel-C4KbQvvK.js +0 -2
- package/web/dist/assets/SettingsModal-DxZp6D_g.js +0 -32
- package/web/dist/assets/SettingsModal-WhQzaOPt.js +0 -32
- package/web/dist/assets/TerminalPanel-D4By_RVc.js +0 -3
- package/web/dist/assets/TerminalPanel-lZw8-i3j.js +0 -3
- package/web/dist/assets/TuiOverlayModal-C3pAVuC8.js +0 -1
- package/web/dist/assets/TuiOverlayModal-D7_rEXcJ.js +0 -1
- package/web/dist/assets/app-globals-KqOVtmp1.js +0 -123
- package/web/dist/assets/canvas-client-BY6ojmle.js +0 -1
- package/web/dist/assets/desktop-CV6KKp9R.js +0 -1
- package/web/dist/assets/index-BawF7ZP5.js +0 -397
- package/web/dist/assets/index-BoGCoq5X.js +0 -397
- package/web/dist/assets/index-CVW9FoY2.css +0 -1
- package/web/dist/assets/plugin-host-Dn8Dd6SC.js +0 -1
- package/web/dist/assets/theme-D_bihpdN.js +0 -1
|
@@ -1,32 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* plugin-catalog-sync — 受支持的「插件市场目录同步」(issue #148)。
|
|
3
|
-
*
|
|
4
|
-
* 第三方插件想把自己的插件清单同步进宿主,本来只能:派发私有的浏览器事件
|
|
5
|
-
* `pi-web-ui:plugin-run-command` + 让用户在可见终端里看它跑命令。私有事件随时会变,
|
|
6
|
-
* 宿主的目录更新也没有回执。这里把它做成**受支持的一条路径**:
|
|
7
|
-
*
|
|
8
|
-
* host.reloadCatalog(source, { install, replace }) (插件侧,浏览器)
|
|
9
|
-
* → plugin_catalog_sync (协议)
|
|
10
|
-
* → 本文件:读文档 → 校验 → 原子写盘 → 可选安装 → 重载 + 重推 → 回执
|
|
11
|
-
*
|
|
12
|
-
* 三条纪律(对齐 issue 的验收标准):
|
|
13
|
-
* 1. 校验与市场「添加到列表」同源(plugin-catalog.ts 的 toEntry)——不合法条目丢弃,
|
|
14
|
-
* 形状不对 / 读不到 / 解析失败时**一个字节都不写盘**(旧目录保持有效);
|
|
15
|
-
* 2. 安装走正常安装器(PluginInstaller,同 CLI + 同一把锁),失败逐条回报,
|
|
16
|
-
* 不因为一条坏条目就停掉整批;
|
|
17
|
-
* 3. 回执是结构化的(ok/error/entries/installed),不靠 DOM 事件或控制台文字。
|
|
18
|
-
*/
|
|
19
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
20
2
|
import { join } from "node:path";
|
|
21
3
|
import { pick } from "./i18n.js";
|
|
22
4
|
import { normalizeSyncPayload, writeCustomCatalog, writeCommunityCatalog } from "./plugin-catalog.js";
|
|
23
5
|
import { workspacePath } from "./files-service.js";
|
|
24
|
-
/**
|
|
25
|
-
* 读同步文档:`http(s)://` 走网络,其余当本地文件路径 —— **只允许工作区内的路径**
|
|
26
|
-
* (复用 files-service 的 workspacePath 校验;任意绝对路径可读会成为「文件存在 /
|
|
27
|
-
* 可读性」探测 oracle)。只读文本;本地来源的读失败与过大统一进 `localDocFailed`
|
|
28
|
-
* 这一条错误(调用方把解析失败也并进来),不区分「读不到 / 解析失败」两种失败。
|
|
29
|
-
*/
|
|
30
6
|
function localDocFailed(l) {
|
|
31
7
|
return {
|
|
32
8
|
error: pick(l, "目录文档无效或不可读(仅支持 http(s) URL 或工作区内的 JSON 文件)", "Invalid or unreadable catalog document (http(s) URL or an in-workspace JSON file only)", "plugincatalog.sync.doc.invalid"),
|
|
@@ -59,8 +35,6 @@ async function readDocument(source, deps, lang) {
|
|
|
59
35
|
};
|
|
60
36
|
return { text };
|
|
61
37
|
}
|
|
62
|
-
// 本地来源:必须在工作区内(workspacePath 对相对/绝对路径统一做越界判定)。
|
|
63
|
-
// 越界 / 读不到 / 过大统一返回同一条错误,不给调用方区分的余地。
|
|
64
38
|
const wp = deps.workspaceRoot ? workspacePath(deps.workspaceRoot, source.trim()) : null;
|
|
65
39
|
if (!wp)
|
|
66
40
|
return localDocFailed(l);
|
|
@@ -75,10 +49,6 @@ async function readDocument(source, deps, lang) {
|
|
|
75
49
|
return localDocFailed(l);
|
|
76
50
|
return { text };
|
|
77
51
|
}
|
|
78
|
-
/**
|
|
79
|
-
* 同步一次目录:读 → 校验 → 原子写 → 可选安装 → 重载 + 重推。
|
|
80
|
-
* 任何一步失败都以 `{ ok:false, error }` 返回(不抛),由协议层原样回给调用者。
|
|
81
|
-
*/
|
|
82
52
|
export async function syncPluginCatalog(source, opts, deps) {
|
|
83
53
|
const lang = deps.lang ?? (() => "en");
|
|
84
54
|
const l = lang();
|
|
@@ -97,8 +67,6 @@ export async function syncPluginCatalog(source, opts, deps) {
|
|
|
97
67
|
raw = JSON.parse(doc.text);
|
|
98
68
|
}
|
|
99
69
|
catch (err) {
|
|
100
|
-
// 本地来源不区分「读得到但解析失败 / 读不到 / 越界」——组合起来就是文件探测
|
|
101
|
-
// oracle;http(s) 来源与本地文件无关,保留解析细节方便排障。
|
|
102
70
|
if (isLocalSource)
|
|
103
71
|
return { ok: false, error: localDocFailed(lang()).error };
|
|
104
72
|
return {
|
|
@@ -109,7 +77,6 @@ export async function syncPluginCatalog(source, opts, deps) {
|
|
|
109
77
|
const payload = normalizeSyncPayload(raw, lang);
|
|
110
78
|
if ("error" in payload)
|
|
111
79
|
return { ok: false, error: payload.error };
|
|
112
|
-
// 到这里才动磁盘:校验失败的文档绝不覆盖一份有效目录。
|
|
113
80
|
const isCommunity = opts.target === "community" ||
|
|
114
81
|
(Boolean(deps.communityCatalogPath) &&
|
|
115
82
|
(source.includes("pi-web-ui-plugins/catalog.json") || source.endsWith("/community-catalog.json")));
|
|
@@ -122,9 +89,6 @@ export async function syncPluginCatalog(source, opts, deps) {
|
|
|
122
89
|
await deps.afterWrite();
|
|
123
90
|
let installed;
|
|
124
91
|
if (opts.install === true && payload.entries.length) {
|
|
125
|
-
// 安装确认门(P0):安装/更新插件是高风险动作,必须先经用户确认。第三方页面
|
|
126
|
-
// 脚本可以直发 plugin_catalog_sync,没有这道门就能静默装任意插件。拒绝 /
|
|
127
|
-
// 超时 / 无确认设施(无头 DSH)一律只保留目录更新,不安装。
|
|
128
92
|
const items = payload.entries.map((e) => ({ id: e.id, source: e.source }));
|
|
129
93
|
const confirmed = deps.confirmInstall ? await deps.confirmInstall(items) : false;
|
|
130
94
|
if (!confirmed)
|
|
@@ -135,7 +99,6 @@ export async function syncPluginCatalog(source, opts, deps) {
|
|
|
135
99
|
const res = await deps.installer.run({ jobId: `catalog-sync:${e.id}`, action, id: e.id, source: e.source }, { lang });
|
|
136
100
|
installed.push({ id: e.id, ok: res.ok, ...(res.error ? { error: res.error } : {}) });
|
|
137
101
|
}
|
|
138
|
-
// 安装改变了 <dataDir>/plugins —— 再重载/重推一次,让新插件与前端清单对齐。
|
|
139
102
|
await deps.afterWrite();
|
|
140
103
|
}
|
|
141
104
|
return { ok: true, installed };
|
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 插件市场 / 插件列表 —— 可一键安装的插件清单。
|
|
3
|
-
*
|
|
4
|
-
* 两层来源(合并后经协议 plugin_catalog 推给前端):
|
|
5
|
-
* - builtin : <pkgRoot>/plugins/catalog.json(随包发布,官方维护列表;
|
|
6
|
-
* 插件作者把新插件加进来 = 往这个文件加一条 + PR)
|
|
7
|
-
* - custom : <dataDir>/plugin-catalog.json(用户在设置面板「添加到列表」,
|
|
8
|
-
* 任何第三方插件都能随时填进列表;仅 custom 条目可经 UI 移除)
|
|
9
|
-
*
|
|
10
|
-
* 条目结构见 protocol.UiPluginCatalogEntry。`id` 是安装落盘目录名
|
|
11
|
-
* (<dataDir>/plugins/<id>);安装固定用 `pi-web-ui install <source>
|
|
12
|
-
* --name <id>` 保证目录名 == 列表 id,前端据此判断已装/未装。
|
|
13
|
-
*
|
|
14
|
-
* 设计上服务端不做网络探测(不拉 manifest):名称/简介/图标由条目本身携带
|
|
15
|
-
* (作者填),id 由来源推导或作者显式指定 —— 保持离线可用、可单测。
|
|
16
|
-
*/
|
|
17
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { isBuiltinModule } from "./builtin-modules.js";
|
|
18
3
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
19
4
|
import { normalizeIconSvg } from "./icon-svg.js";
|
|
20
5
|
import { pick } from "./i18n.js";
|
|
21
|
-
/** 合法插件 id(与 server/plugins.ts 的 ID_RE 一致,防路径穿越)。 */
|
|
22
6
|
const ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
23
|
-
/** source 校验:owner/repo 或 owner/repo/子路径[#ref]。宽松校验,实际解析
|
|
24
|
-
* 交给 CLI(pi-web-ui install)。只接受远程 GitHub 源,拒绝本地路径。 */
|
|
25
7
|
function isValidSource(source) {
|
|
26
8
|
if (!source || source.length > 300)
|
|
27
9
|
return false;
|
|
28
10
|
if (source.startsWith("/") || /^[A-Za-z]:[\\/]/.test(source))
|
|
29
11
|
return false;
|
|
30
12
|
if (/^https?:\/\//.test(source))
|
|
31
|
-
return true;
|
|
13
|
+
return true;
|
|
32
14
|
const spec = source.split("#")[0].replace(/\/+$/, "");
|
|
33
15
|
const segs = spec.split("/").filter(Boolean);
|
|
34
16
|
if (segs.length < 2)
|
|
@@ -38,11 +20,7 @@ function isValidSource(source) {
|
|
|
38
20
|
return false;
|
|
39
21
|
return true;
|
|
40
22
|
}
|
|
41
|
-
/** 导出给服务端其它模块(后台作业的安装源校验、目录同步),单一事实源。 */
|
|
42
23
|
export { isValidSource };
|
|
43
|
-
/** 推导默认 id:与 CLI(bin/pi-web-ui.mjs)的规则对齐 —— 子路径末段 > 仓库名
|
|
44
|
-
* > 来源末段;非法字符替换为 -,两端去 -;空则 "plugin"。显式 raw(含合法
|
|
45
|
-
* id 校验)优先。返回的 id 不保证通过 ID_RE(Cyrillic 等),调用方再校验。 */
|
|
46
24
|
export function deriveCatalogId(raw, source) {
|
|
47
25
|
if (raw && ID_RE.test(raw))
|
|
48
26
|
return raw;
|
|
@@ -63,7 +41,6 @@ function readJsonSafe(path, fallback) {
|
|
|
63
41
|
function atomicWrite(path, data) {
|
|
64
42
|
writeJsonAtomicSync(path, data);
|
|
65
43
|
}
|
|
66
|
-
/** 把任意对象规范化为合法条目;非法则返回 null。 */
|
|
67
44
|
function toEntry(raw, originOrBuiltin) {
|
|
68
45
|
const origin = typeof originOrBuiltin === "boolean" ? (originOrBuiltin ? "builtin" : "custom") : originOrBuiltin;
|
|
69
46
|
const builtin = origin === "builtin";
|
|
@@ -71,7 +48,7 @@ function toEntry(raw, originOrBuiltin) {
|
|
|
71
48
|
if (!isValidSource(source))
|
|
72
49
|
return null;
|
|
73
50
|
const id = deriveCatalogId(typeof raw.id === "string" ? raw.id.trim() : undefined, source);
|
|
74
|
-
if (!ID_RE.test(id))
|
|
51
|
+
if (!ID_RE.test(id) || isBuiltinModule(id.toLowerCase()))
|
|
75
52
|
return null;
|
|
76
53
|
const name = typeof raw.name === "string" && raw.name.trim() ? raw.name.trim() : id;
|
|
77
54
|
const nameEn = typeof raw.nameEn === "string" && raw.nameEn.trim() ? raw.nameEn.trim() : undefined;
|
|
@@ -94,17 +71,10 @@ function toEntry(raw, originOrBuiltin) {
|
|
|
94
71
|
...(homepage ? { homepage } : {}),
|
|
95
72
|
};
|
|
96
73
|
}
|
|
97
|
-
/** 读合并后的目录:
|
|
98
|
-
* 1. builtin : 项目随包内置核心插件(不可移除);
|
|
99
|
-
* 2. community : 官方社区生态清单(pi-web-ui-plugins 自动化审核构建,不可移除);
|
|
100
|
-
* 3. custom : 用户在设置面板手动填写的自定义条目(同 id 可覆盖 builtin/community,支持单独移除)。
|
|
101
|
-
* custom 覆盖 builtin 时强制打 `overridesBuiltin: true` 标记(builtin 同时为
|
|
102
|
-
* false):显示字段来自用户可写来源,前端据此把它标识为「自定义覆盖」。 */
|
|
103
74
|
export function readCatalog(builtinPath, customPath, communityPath) {
|
|
104
75
|
const out = [];
|
|
105
76
|
const seenBuiltin = new Set();
|
|
106
77
|
const seen = new Set();
|
|
107
|
-
// 1. 内置核心插件
|
|
108
78
|
if (existsSync(builtinPath)) {
|
|
109
79
|
const raw = readJsonSafe(builtinPath, []);
|
|
110
80
|
if (Array.isArray(raw)) {
|
|
@@ -118,7 +88,6 @@ export function readCatalog(builtinPath, customPath, communityPath) {
|
|
|
118
88
|
}
|
|
119
89
|
}
|
|
120
90
|
}
|
|
121
|
-
// 2. 官方社区生态插件(若存在)
|
|
122
91
|
if (communityPath && existsSync(communityPath)) {
|
|
123
92
|
const rawCommunity = readJsonSafe(communityPath, []);
|
|
124
93
|
const list = Array.isArray(rawCommunity)
|
|
@@ -132,7 +101,6 @@ export function readCatalog(builtinPath, customPath, communityPath) {
|
|
|
132
101
|
const e = it && typeof it === "object" ? toEntry(it, "community") : null;
|
|
133
102
|
if (!e)
|
|
134
103
|
continue;
|
|
135
|
-
// 内置插件绝对优先,不被社区同名条目替换
|
|
136
104
|
if (seenBuiltin.has(e.id))
|
|
137
105
|
continue;
|
|
138
106
|
const idx = out.findIndex((x) => x.id === e.id);
|
|
@@ -145,7 +113,6 @@ export function readCatalog(builtinPath, customPath, communityPath) {
|
|
|
145
113
|
seen.add(e.id);
|
|
146
114
|
}
|
|
147
115
|
}
|
|
148
|
-
// 3. 用户在设置面板手动添加的自定义条目
|
|
149
116
|
const rawCustom = readJsonSafe(customPath, {});
|
|
150
117
|
const list = rawCustom && typeof rawCustom === "object" && Array.isArray(rawCustom.entries)
|
|
151
118
|
? rawCustom.entries
|
|
@@ -156,7 +123,6 @@ export function readCatalog(builtinPath, customPath, communityPath) {
|
|
|
156
123
|
continue;
|
|
157
124
|
const idx = out.findIndex((x) => x.id === e.id);
|
|
158
125
|
if (idx >= 0) {
|
|
159
|
-
// 覆盖了同名 builtin/community 条目:强制带标识(不信任 custom 文件里的任何自标字段)。
|
|
160
126
|
out[idx] = { ...e, builtin: false, origin: "custom", overridesBuiltin: seenBuiltin.has(e.id) };
|
|
161
127
|
}
|
|
162
128
|
else {
|
|
@@ -166,11 +132,7 @@ export function readCatalog(builtinPath, customPath, communityPath) {
|
|
|
166
132
|
}
|
|
167
133
|
return out;
|
|
168
134
|
}
|
|
169
|
-
|
|
170
|
-
* 非法来源/条目抛 Error。 */
|
|
171
|
-
export function addCustomEntry(customPath, input,
|
|
172
|
-
/** 面向用户的抛错文案语言(默认英文);调用方可传 () => getLang() 实现跟随。 */
|
|
173
|
-
lang) {
|
|
135
|
+
export function addCustomEntry(customPath, input, lang) {
|
|
174
136
|
const l = lang?.() ?? "en";
|
|
175
137
|
const source = String(input?.source ?? "").trim();
|
|
176
138
|
if (!isValidSource(source)) {
|
|
@@ -179,6 +141,8 @@ lang) {
|
|
|
179
141
|
const id = deriveCatalogId(typeof input?.id === "string" ? input.id.trim() : undefined, source);
|
|
180
142
|
if (!ID_RE.test(id))
|
|
181
143
|
throw new Error(pick(l, `非法 id "${id}"(仅限字母数字-_)`, `Invalid id "${id}" (letters/digits/-/_ only)`, "plugincatalog.id.invalid", { id }));
|
|
144
|
+
if (isBuiltinModule(id.toLowerCase()))
|
|
145
|
+
throw new Error(pick(l, `内置模块 "${id}" 由宿主管理,不能添加为插件`, `Built-in module "${id}" is managed by the host and cannot be added as a plugin`));
|
|
182
146
|
const raw = readJsonSafe(customPath, {});
|
|
183
147
|
const entries = Array.isArray(raw.entries) ? raw.entries : [];
|
|
184
148
|
const next = entries.filter((x) => !(x && typeof x === "object" && x.id === id));
|
|
@@ -195,7 +159,6 @@ lang) {
|
|
|
195
159
|
atomicWrite(customPath, { entries: next });
|
|
196
160
|
return toEntry(next[next.length - 1], false);
|
|
197
161
|
}
|
|
198
|
-
/** 移除用户添加的条目(builtin 由文件自身控制,不可经此删除);返回是否删掉。 */
|
|
199
162
|
export function removeCustomEntry(customPath, id) {
|
|
200
163
|
if (!ID_RE.test(id))
|
|
201
164
|
return false;
|
|
@@ -208,14 +171,6 @@ export function removeCustomEntry(customPath, id) {
|
|
|
208
171
|
atomicWrite(customPath, { entries: next });
|
|
209
172
|
return true;
|
|
210
173
|
}
|
|
211
|
-
/**
|
|
212
|
-
* 把同步文档规范化为自定义条目列表(纯函数,不碰磁盘)。
|
|
213
|
-
*
|
|
214
|
-
* 文档形状:JSON 数组,或 `{ entries: [...] }`(与本文件自身的磁盘格式同形)。
|
|
215
|
-
* 每个条目走 `toEntry` —— 与市场“添加到列表”**同一套校验**(id 字符集、source 必须
|
|
216
|
-
* 是远程 owner/repo[/subdir][#ref]、字段 trimmed + 长度上限),非法条目丢弃并计数;
|
|
217
|
-
* 整份文档形状不对则直接报错,由调用方原样回给调用者(绝不写盘)。
|
|
218
|
-
*/
|
|
219
174
|
export function normalizeSyncPayload(raw, lang) {
|
|
220
175
|
const l = lang?.() ?? "en";
|
|
221
176
|
const list = Array.isArray(raw)
|
|
@@ -238,16 +193,6 @@ export function normalizeSyncPayload(raw, lang) {
|
|
|
238
193
|
}
|
|
239
194
|
return { entries, skipped };
|
|
240
195
|
}
|
|
241
|
-
/**
|
|
242
|
-
* 原子写入用户自定义列表。
|
|
243
|
-
*
|
|
244
|
-
* `replace=true` 整体替换(文档即真相);`false`(默认)按 id upsert:文档里出现的
|
|
245
|
-
* id 覆盖同名旧条目,文档没提的旧条目**保留** —— 这样插件只推送增量也能用。
|
|
246
|
-
* 写入内容只包含本文件认识的白名单字段(id/source/name/description/descriptionEn/
|
|
247
|
-
* icon/homepage),远端文档里塞的其他键不会落到磁盘上。
|
|
248
|
-
*
|
|
249
|
-
* 返回写盘后的自定义条目数(合并列表由 PluginManager.catalog() 重读得出)。
|
|
250
|
-
*/
|
|
251
196
|
export function writeCustomCatalog(customPath, incoming, replace) {
|
|
252
197
|
const byId = new Map();
|
|
253
198
|
if (!replace) {
|
|
@@ -259,8 +204,10 @@ export function writeCustomCatalog(customPath, incoming, replace) {
|
|
|
259
204
|
byId.set(e.id, e);
|
|
260
205
|
}
|
|
261
206
|
}
|
|
262
|
-
for (const e of incoming)
|
|
263
|
-
|
|
207
|
+
for (const e of incoming) {
|
|
208
|
+
if (!isBuiltinModule(e.id.toLowerCase()))
|
|
209
|
+
byId.set(e.id, e);
|
|
210
|
+
}
|
|
264
211
|
const entries = [...byId.values()].map((e) => ({
|
|
265
212
|
id: e.id,
|
|
266
213
|
source: e.source,
|
|
@@ -275,11 +222,10 @@ export function writeCustomCatalog(customPath, incoming, replace) {
|
|
|
275
222
|
atomicWrite(customPath, { entries });
|
|
276
223
|
return entries.length;
|
|
277
224
|
}
|
|
278
|
-
/**
|
|
279
|
-
* 原子写入官方社区生态清单(由远端构建的 catalog.json 同步而来,全量替换)。
|
|
280
|
-
*/
|
|
281
225
|
export function writeCommunityCatalog(communityPath, incoming) {
|
|
282
|
-
const entries = incoming
|
|
226
|
+
const entries = incoming
|
|
227
|
+
.filter((e) => !isBuiltinModule(e.id.toLowerCase()))
|
|
228
|
+
.map((e) => ({
|
|
283
229
|
id: e.id,
|
|
284
230
|
source: e.source,
|
|
285
231
|
name: e.name,
|
|
@@ -2,7 +2,6 @@ const MAX_COUNT = 8;
|
|
|
2
2
|
const MAX_ITEM_BYTES = 10 * 1024 * 1024;
|
|
3
3
|
const MAX_TOTAL_BYTES = 20 * 1024 * 1024;
|
|
4
4
|
const IMAGE_MIMES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
|
|
5
|
-
/** Validate before invoking the agent; never silently discard media or truncate base64. */
|
|
6
5
|
export function normalizePluginChatAttachments(value) {
|
|
7
6
|
if (value === undefined)
|
|
8
7
|
return undefined;
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 插件会话快照的「选哪个会话」策略(issue #542,纯函数,零宿主/零 SDK 依赖)。
|
|
3
|
-
*
|
|
4
|
-
* 背景:`host.getActiveConversation()` 原来只认「全局 lastActiveAt 最大者」,
|
|
5
|
-
* 于是两个标签页各看一个对话时,插件读到的是另一个标签页的会话;子代理跑起来
|
|
6
|
-
* 比用户正在看的对话还勤,也会把父对话挤出快照。这里把选会话的两条口径拆成
|
|
7
|
-
* 纯函数,让 agent-service 只负责取数据、这里负责判定(可单测)。
|
|
8
|
-
*
|
|
9
|
-
* 另外附一个模型变更事件去重键:`host.onClientModelChanged` 只在模型真的换了
|
|
10
|
-
* 的时候发一次(重复点同一个模型、重连重放 set_model 都不该重复触发订阅者)。
|
|
11
|
-
*/
|
|
12
|
-
/** 单客户端内选会话:给了 `active` 就优先认它(= 该标签页正在看的对话),
|
|
13
|
-
* 否则退回归属本客户端的「最近活跃」会话;`includeSubagents=false`(缺省)时
|
|
14
|
-
* 跳过子代理对话。找不到任何符合条件的会话 → null(调用方据此回落)。
|
|
15
|
-
*
|
|
16
|
-
* `conversations` 只遍历一遍(Map.values() 直传,不额外建数组)。 */
|
|
17
1
|
export function pickClientConversation(conversations, opts = {}) {
|
|
18
2
|
const include = opts.includeSubagents === true;
|
|
19
3
|
const active = opts.active;
|
|
@@ -28,9 +12,6 @@ export function pickClientConversation(conversations, opts = {}) {
|
|
|
28
12
|
}
|
|
29
13
|
return best;
|
|
30
14
|
}
|
|
31
|
-
/** 跨客户端回落:最近活跃的**非子代理**会话(`at` 最大者)。
|
|
32
|
-
* 缺省语义(不传 clientId / clientId 不认识)走这条 —— 与 #542 之前的行为
|
|
33
|
-
* 一致,只多一条「子代理不算数」。 */
|
|
34
15
|
export function pickLatestClientSnapshot(snapshots) {
|
|
35
16
|
let best = null;
|
|
36
17
|
for (const s of snapshots) {
|
|
@@ -41,7 +22,6 @@ export function pickLatestClientSnapshot(snapshots) {
|
|
|
41
22
|
}
|
|
42
23
|
return best;
|
|
43
24
|
}
|
|
44
|
-
/** 模型变更事件的去重键:同一客户端、同一对话、同一模型 = 同一件事。 */
|
|
45
25
|
export function modelChangeKey(snap) {
|
|
46
26
|
return `${snap.clientId}\u0000${snap.conversationId}\u0000${snap.model ?? ""}`;
|
|
47
27
|
}
|
|
@@ -1,25 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 特权 DOM 访问授权表(`<dataDir>/plugin-dom.json`)。
|
|
3
|
-
*
|
|
4
|
-
* 背景:插件 client bundle 与主应用同源,JS 层面拦不住它碰 `document`——真正的门禁
|
|
5
|
-
* 只能放在 bundle 下发处(`/plugins/:id/client/*`)。manifest.permissions 含 "dom"
|
|
6
|
-
* 族的插件,其 bundle 默认 403;用户在设置面板逐个授权后才放行(并 epoch+1 让
|
|
7
|
-
* 浏览器重拉)。授权是整机全局的(与 plugin-grants.json 同口径),任何浏览器看到
|
|
8
|
-
* 的都是同一份。
|
|
9
|
-
*
|
|
10
|
-
* 语义:
|
|
11
|
-
* - 读不出来 / JSON 坏 / 形状不对 → 当空表,且**不在读路径回写**(一次磁盘抖动不
|
|
12
|
-
* 能静默清空用户授权;与 PluginGrantsStore 同一条纪律)。
|
|
13
|
-
* - 只有真正发生变更的写才落盘(临时文件 + rename 原子写);写失败 best-effort
|
|
14
|
-
* (内存态仍生效,本次会话可用)。
|
|
15
|
-
*/
|
|
16
1
|
import { readFileSync } from "node:fs";
|
|
17
2
|
import { join } from "node:path";
|
|
18
3
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
19
4
|
const FILE = "plugin-dom.json";
|
|
20
|
-
/** manifest.permissions 条目 → 是否请求特权 DOM(只看 `:` 前的族名,与宿主 can() 同口径)。
|
|
21
|
-
* 例外:`dom:anchor` 只是客户端锚点挂载点的范围 DOM(免用户授权),不触发 bundle 403;
|
|
22
|
-
* 完整 document 访问仍需 `dom`(或除 anchor 外的其它 dom 子族)+ 用户授权。 */
|
|
23
5
|
export function declarationWantsDom(permissions) {
|
|
24
6
|
if (!Array.isArray(permissions))
|
|
25
7
|
return false;
|
|
@@ -32,7 +14,6 @@ export function declarationWantsDom(permissions) {
|
|
|
32
14
|
return sub === undefined || sub === "" || sub !== "anchor";
|
|
33
15
|
});
|
|
34
16
|
}
|
|
35
|
-
/** 静态门禁判定:纯函数,单测覆盖。未知插件(wantsDom=false)一律放行——向后兼容。 */
|
|
36
17
|
export function isDomBundleBlocked(wantsDom, granted) {
|
|
37
18
|
return wantsDom && !granted;
|
|
38
19
|
}
|
|
@@ -59,7 +40,6 @@ export class PluginDomConsent {
|
|
|
59
40
|
list() {
|
|
60
41
|
return [...this.granted].sort();
|
|
61
42
|
}
|
|
62
|
-
/** 授权/撤销。返回是否真的发生了变更(没变就不落盘、不推快照)。 */
|
|
63
43
|
set(pluginId, granted) {
|
|
64
44
|
const id = String(pluginId ?? "").trim();
|
|
65
45
|
if (!id)
|
|
@@ -74,9 +54,7 @@ export class PluginDomConsent {
|
|
|
74
54
|
try {
|
|
75
55
|
writeJsonAtomicSync(join(this.dataDir, FILE), { v: 1, granted: this.list() });
|
|
76
56
|
}
|
|
77
|
-
catch {
|
|
78
|
-
/* 写失败 best-effort:内存态仍生效,本次会话可用 */
|
|
79
|
-
}
|
|
57
|
+
catch { }
|
|
80
58
|
return true;
|
|
81
59
|
}
|
|
82
60
|
}
|