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,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* json-utils.ts — 跨模块共享 JSON 工具集。
|
|
3
|
-
*
|
|
4
|
-
* 统一收敛带注释 JSON(JSONC)的安全剥离与解析,消除跨模块重复手搓。
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* 剥离 JSON 字符串中的 // 单行注释与 /* *\/ 块级注释。
|
|
8
|
-
* 保护字符串字面量内部内容(如 URL 中的 "https://..." 或包含引号/斜杠的内容)。
|
|
9
|
-
*/
|
|
10
1
|
export function stripJsonComments(src) {
|
|
11
2
|
let out = "";
|
|
12
3
|
let inString = false;
|
|
@@ -49,9 +40,6 @@ export function stripJsonComments(src) {
|
|
|
49
40
|
}
|
|
50
41
|
return out;
|
|
51
42
|
}
|
|
52
|
-
/**
|
|
53
|
-
* 安全解析可能包含注释的 JSON 文本。
|
|
54
|
-
*/
|
|
55
43
|
export function parseJsonWithComments(src) {
|
|
56
44
|
return JSON.parse(stripJsonComments(src));
|
|
57
45
|
}
|
|
@@ -1,40 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* launch-origin — 这个进程是被谁启动的?
|
|
3
|
-
*
|
|
4
|
-
* 界面里有一处需要知道答案:更新面板的「重启服务」按钮。它只有在**退出后会被
|
|
5
|
-
* 自动拉起**的实例上才有意义(`pi-web-ui server start` 起的是这种),前台
|
|
6
|
-
* `pi-web-ui` / `npm run dev` 起的实例点它 = 把服务关掉不回来了。
|
|
7
|
-
*
|
|
8
|
-
* 判定的是「有没有 supervisor 会在本进程退出后把它拉起来」,一共三种:
|
|
9
|
-
* - **launchd**(macOS,`server install` 写的 plist)——launchd 给每个 job 设
|
|
10
|
-
* `XPC_SERVICE_NAME`,据此认出我们生成的 label(com.xingshuyin.pi-web-ui /
|
|
11
|
-
* com.<name>.server);
|
|
12
|
-
* - **systemd**(Linux,`Restart=always`)——systemd 给每个 unit 设
|
|
13
|
-
* `INVOCATION_ID`;unit 名从 /proc/self/cgroup 里取(`…/pi-web-ui.service`);
|
|
14
|
-
* - **windows-watchdog**(Windows,`server install` 写的 ps1:
|
|
15
|
-
* `while ($true) { node …; Start-Sleep 10 }`)——没有环境变量可依,靠 PID
|
|
16
|
-
* 文件反查:ps1 把自己的 PID 写进 `%APPDATA%\pi-web-ui\<name>.pid`,而 node
|
|
17
|
-
* 是它的直接子进程,所以 `process.ppid` 等于文件里那个 PID。同名 ps1 里必须
|
|
18
|
-
* 真的有 watchdog 循环 —— 桌面快捷方式的 ps1 也写同一个 PID 文件,但它
|
|
19
|
-
* (未安装服务时)是前台跑,退出不会回来。
|
|
20
|
-
*
|
|
21
|
-
* 新版 `server install` 另外烘焙 `PI_WEB_LAUNCHED_BY=service` +
|
|
22
|
-
* `PI_WEB_SERVICE_NAME=<name>`(最高优先级、最明确的一路);已装好的老服务没有
|
|
23
|
-
* 这两个变量,所以上面的运行时判据必须保留。
|
|
24
|
-
*
|
|
25
|
-
* Docker **刻意不算**:容器由编排/`restart:` 策略管,重启容器不是这个按钮该干的事。
|
|
26
|
-
*
|
|
27
|
-
* 纯函数(env / ppid / fs 读取全部可注入)便于单测;`launchOrigin()` 是进程级
|
|
28
|
-
* 缓存的一次性探测,服务端多处共用同一份结论。
|
|
29
|
-
*/
|
|
30
1
|
import { readdirSync, readFileSync } from "node:fs";
|
|
31
2
|
import { homedir } from "node:os";
|
|
32
3
|
import { join } from "node:path";
|
|
33
|
-
/** 默认服务名(`server install` 没传 --name 时)。 */
|
|
34
4
|
export const DEFAULT_SERVICE_NAME = "pi-web-ui";
|
|
35
|
-
/** 默认 launchd label —— 与 bin/pi-web-ui.mjs 的 serviceLabel() 保持一致。 */
|
|
36
5
|
const LAUNCHD_LABEL_DEFAULT = "com.xingshuyin.pi-web-ui";
|
|
37
|
-
/** Windows 启动器目录(CLI 的 winServiceDir 同源)。 */
|
|
38
6
|
const WIN_SERVICE_DIR_NAME = "pi-web-ui";
|
|
39
7
|
function defaultListDir(dir) {
|
|
40
8
|
try {
|
|
@@ -52,25 +20,20 @@ function defaultReadFile(path) {
|
|
|
52
20
|
return null;
|
|
53
21
|
}
|
|
54
22
|
}
|
|
55
|
-
/** Windows 启动器目录:`%APPDATA%\pi-web-ui`(CLI 的 winServiceDir)。 */
|
|
56
23
|
export function winServiceDir(env = process.env) {
|
|
57
24
|
const appData = env.APPDATA?.trim() || join(homedir(), "AppData", "Roaming");
|
|
58
25
|
return join(appData, WIN_SERVICE_DIR_NAME);
|
|
59
26
|
}
|
|
60
|
-
/** launchd label → 服务名;不是我们生成的 label 返回 null。 */
|
|
61
27
|
function nameFromLaunchdLabel(label) {
|
|
62
28
|
if (label === LAUNCHD_LABEL_DEFAULT)
|
|
63
29
|
return DEFAULT_SERVICE_NAME;
|
|
64
|
-
// serviceLabel(`--name foo`) = com.foo.server
|
|
65
30
|
const m = /^com\.(.+)\.server$/.exec(label);
|
|
66
31
|
return m?.[1] ?? null;
|
|
67
32
|
}
|
|
68
|
-
/** systemd cgroup 内容 → unit 名(`0::/system.slice/pi-web-ui.service`)。 */
|
|
69
33
|
function nameFromCgroup(content) {
|
|
70
34
|
const m = /([A-Za-z0-9_.@-]+)\.service/.exec(content ?? "");
|
|
71
35
|
return m?.[1];
|
|
72
36
|
}
|
|
73
|
-
/** `PI_WEB_LAUNCHED_BY=service` 时的 supervisor(按平台推导)。 */
|
|
74
37
|
function supervisorForPlatform(platform) {
|
|
75
38
|
if (platform === "win32")
|
|
76
39
|
return "windows-watchdog";
|
|
@@ -78,7 +41,6 @@ function supervisorForPlatform(platform) {
|
|
|
78
41
|
return "launchd";
|
|
79
42
|
return "systemd";
|
|
80
43
|
}
|
|
81
|
-
/** Windows:PID 文件里的 PID === 本进程的 ppid,且同名 ps1 里确实有 watchdog 循环。 */
|
|
82
44
|
function detectWindows(input, env) {
|
|
83
45
|
const dir = input.winServiceDir ?? winServiceDir(env);
|
|
84
46
|
const listDir = input.listDir ?? defaultListDir;
|
|
@@ -99,10 +61,6 @@ function detectWindows(input, env) {
|
|
|
99
61
|
}
|
|
100
62
|
return { supervisor: null };
|
|
101
63
|
}
|
|
102
|
-
/**
|
|
103
|
-
* 探测启动来源。`PI_WEB_LAUNCHED_BY=service` 优先(新版 install 烘焙的),
|
|
104
|
-
* 否则按平台识别 supervisor 自己的运行时痕迹。
|
|
105
|
-
*/
|
|
106
64
|
export function detectLaunchOrigin(input = {}) {
|
|
107
65
|
const env = input.env ?? process.env;
|
|
108
66
|
const platform = input.platform ?? process.platform;
|
|
@@ -131,12 +89,10 @@ function defaultReadCgroup() {
|
|
|
131
89
|
return defaultReadFile("/proc/self/cgroup");
|
|
132
90
|
}
|
|
133
91
|
let cached = null;
|
|
134
|
-
/** 进程级缓存的一次性探测(服务端多处共用:ready 消息 / quit 语义 / 控制 socket)。 */
|
|
135
92
|
export function launchOrigin() {
|
|
136
93
|
cached ??= detectLaunchOrigin();
|
|
137
94
|
return cached;
|
|
138
95
|
}
|
|
139
|
-
/** 下发给浏览器的服务信息(null = 没有 supervisor,界面不提供「重启服务」)。 */
|
|
140
96
|
export function toServiceInfo(origin) {
|
|
141
97
|
if (!origin.supervisor)
|
|
142
98
|
return null;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
/** 单个插件同时可见的条目上限(超出的丢弃并给诊断)。 */
|
|
2
1
|
export const PANEL_ITEM_CAP = 50;
|
|
3
|
-
/** 心跳 TTL:缺省 60 秒(插件若不传 ttlMs)。 */
|
|
4
2
|
export const PANEL_TTL_DEFAULT_MS = 60_000;
|
|
5
|
-
/** TTL 夹取区间:过短会抖动,过长等于没有超时。 */
|
|
6
3
|
export const PANEL_TTL_MIN_MS = 5_000;
|
|
7
4
|
export const PANEL_TTL_MAX_MS = 3_600_000;
|
|
8
5
|
const ID_MAX = 96;
|
|
@@ -11,7 +8,6 @@ const HINT_MAX = 200;
|
|
|
11
8
|
const ICON_MAX = 8;
|
|
12
9
|
const ACTION_MAX = 96;
|
|
13
10
|
const STATUSES = new Set(["running", "done", "error"]);
|
|
14
|
-
/** 把插件传来的 `items` 清洗成可信的条目列表(纯函数)。不合法的条目丢弃,不抛错。 */
|
|
15
11
|
export function sanitizePanelItems(raw) {
|
|
16
12
|
const diags = [];
|
|
17
13
|
const items = [];
|
|
@@ -59,7 +55,6 @@ export function sanitizePanelItems(raw) {
|
|
|
59
55
|
});
|
|
60
56
|
return { items, diags };
|
|
61
57
|
}
|
|
62
|
-
/** TTL 夹取:非数字 / 缺省 → 默认值;其余夹进 [MIN, MAX]。 */
|
|
63
58
|
export function clampPanelTtl(raw) {
|
|
64
59
|
const n = typeof raw === "number" && Number.isFinite(raw) ? raw : PANEL_TTL_DEFAULT_MS;
|
|
65
60
|
return Math.min(PANEL_TTL_MAX_MS, Math.max(PANEL_TTL_MIN_MS, Math.round(n)));
|
|
@@ -70,7 +65,6 @@ export class LeftPanelRunningStore {
|
|
|
70
65
|
constructor(now = Date.now) {
|
|
71
66
|
this.now = now;
|
|
72
67
|
}
|
|
73
|
-
/** 整体替换某插件的运行条目(同时是心跳)。 */
|
|
74
68
|
set(pluginId, pluginName, raw, opts) {
|
|
75
69
|
const { items, diags } = sanitizePanelItems(raw);
|
|
76
70
|
if (items.length === 0) {
|
|
@@ -83,11 +77,9 @@ export class LeftPanelRunningStore {
|
|
|
83
77
|
this.slots.set(pluginId, { pluginName, items, ttlMs, touchedAt: this.now() });
|
|
84
78
|
return { count: items.length, changed, diags };
|
|
85
79
|
}
|
|
86
|
-
/** 清空某插件的条目。返回是否真的删了东西(没有则不需要广播)。 */
|
|
87
80
|
clear(pluginId) {
|
|
88
81
|
return this.slots.delete(pluginId);
|
|
89
82
|
}
|
|
90
|
-
/** 清掉心跳过期的插件,返回被清掉的插件 id 列表(调用方据此广播)。 */
|
|
91
83
|
sweep() {
|
|
92
84
|
const t = this.now();
|
|
93
85
|
const expired = [];
|
|
@@ -99,7 +91,6 @@ export class LeftPanelRunningStore {
|
|
|
99
91
|
}
|
|
100
92
|
return expired;
|
|
101
93
|
}
|
|
102
|
-
/** 当前全部分组(按插件 id 排序,空组不出现)。返回副本,调用方随便改。 */
|
|
103
94
|
groups() {
|
|
104
95
|
return [...this.slots.entries()]
|
|
105
96
|
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { performance } from "node:perf_hooks";
|
|
2
2
|
const disabled = { mark() { }, finish() { } };
|
|
3
|
-
/** Opt-in diagnostics; deliberately omit transcript paths, IDs and message content. */
|
|
4
3
|
export function startLoadTiming(enabled = /^(1|true|on|yes)$/i.test(process.env.PI_WEB_LOAD_TIMING ?? ""), now = () => performance.now(), report = (record) => console.info("[load-timing]", JSON.stringify(record))) {
|
|
5
4
|
if (!enabled)
|
|
6
5
|
return disabled;
|
|
@@ -23,9 +22,7 @@ export function startLoadTiming(enabled = /^(1|true|on|yes)$/i.test(process.env.
|
|
|
23
22
|
try {
|
|
24
23
|
report({ event: "history-open", outcome, totalMs: Number((now() - start).toFixed(3)), stages });
|
|
25
24
|
}
|
|
26
|
-
catch {
|
|
27
|
-
// Diagnostics must never change session loading behavior.
|
|
28
|
-
}
|
|
25
|
+
catch { }
|
|
29
26
|
},
|
|
30
27
|
};
|
|
31
28
|
}
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// load-tools-tool.ts — 延迟加载模式下模型拉取工具 schema 的唯一入口。
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// 背景:模型每轮都会拿到**全部活跃工具**的名字 + 完整参数 schema,几十个工具加起来
|
|
5
|
-
// 是几万字符的常驻开销(设置页「查看工具 schema」能看到了多少)。延迟加载把工具分成
|
|
6
|
-
// 两层:
|
|
7
|
-
// - 常驻:核心工具(bash/read/edit/write)+ 本工具;
|
|
8
|
-
// - 目录:其余工具只在系统提示词里以「名字 + 一行摘要」出现(见 prompt-composer 的
|
|
9
|
-
// tool catalog 段)。
|
|
10
|
-
// 模型要用某个目录里的工具时先调本工具,那批工具才会被激活 —— SDK 的中途工具变更会
|
|
11
|
-
// 把新增工具以 defer_loading / tool_search 的形式注入(见 agent-session 的
|
|
12
|
-
// `_preparePromptAndToolLoadout`),不占首轮上下文。
|
|
13
|
-
//
|
|
14
|
-
// 与 skills 的 `skill` 工具同构:名录常驻、正文按需。区别只在「正文」是工具 schema。
|
|
15
|
-
//
|
|
16
|
-
// 文案约定:工具 definition(description/promptSnippet/promptGuidelines)纯英文;
|
|
17
|
-
// per-call 返回文本按 lang 走 pick(lang, zh, en, key)。
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
1
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
20
2
|
import { Type } from "typebox";
|
|
21
3
|
import { pick } from "./i18n.js";
|
|
22
4
|
import { LOAD_TOOLS_TOOL_NAME } from "./tool-manager.js";
|
|
23
|
-
/** 单次最多加载多少(防模型一口气把整个目录塞回来)。 */
|
|
24
5
|
export const LOAD_TOOLS_MAX = 20;
|
|
25
6
|
function describe(t) {
|
|
26
7
|
const text = (t.description ?? t.summary ?? "").trim().split("\n")[0] ?? "";
|
|
@@ -76,7 +57,6 @@ export function makeLoadToolsTool(host, lang) {
|
|
|
76
57
|
for (const t of loaded) {
|
|
77
58
|
const d = describe(t);
|
|
78
59
|
lines.push(`- ${t.name}${d ? `: ${d}` : ""}`);
|
|
79
|
-
// guidelines 不进系统提示词(会随加载变化、打坏前缀缓存),在此随回执交付。
|
|
80
60
|
for (const g of t.guidelines ?? []) {
|
|
81
61
|
const rule = g.trim();
|
|
82
62
|
if (rule)
|
package/dist/server/locales.js
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* locales — downloadable language packs.
|
|
3
|
-
*
|
|
4
|
-
* Core ships zh/en only (see web/src/i18n.tsx). Every other language lives in
|
|
5
|
-
* `locales/<code>.json` in the git repo (NOT in the npm `files` whitelist, so
|
|
6
|
-
* packs never ship with the package) with shape:
|
|
7
|
-
* { code, nativeName, version, strings: Record<string,string> }
|
|
8
|
-
*
|
|
9
|
-
* On demand the server downloads a pack from PI_WEB_LOCALE_BASE_URL
|
|
10
|
-
* (default: GitHub raw — version tag first, `main` as fallback) into
|
|
11
|
-
* <dataDir>/locales/<code>.json and serves it to the browser. Missing keys
|
|
12
|
-
* fall back to English client-side, so version skew between app and pack is
|
|
13
|
-
* tolerable. Manually dropped <dataDir>/locales/*.json files work too
|
|
14
|
-
* (offline installs) — the list is read from disk.
|
|
15
|
-
*/
|
|
16
1
|
import { existsSync, readFileSync, readdirSync, rmSync } from "node:fs";
|
|
17
2
|
import { join } from "node:path";
|
|
18
3
|
import { extractServerStrings, registerServerStrings, unregisterServerStrings } from "./i18n.js";
|
|
19
4
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
20
|
-
/** Packs available for download (alphabetical by code). */
|
|
21
5
|
export const LOCALE_PACKS = [
|
|
22
6
|
{ code: "de", nativeName: "Deutsch" },
|
|
23
7
|
{ code: "es", nativeName: "Español" },
|
|
@@ -28,8 +12,6 @@ export const LOCALE_PACKS = [
|
|
|
28
12
|
{ code: "pt", nativeName: "Português" },
|
|
29
13
|
{ code: "ru", nativeName: "Русский" },
|
|
30
14
|
{ code: "tr", nativeName: "Türkçe" },
|
|
31
|
-
// Traditional Chinese packs. Core "zh" is Simplified; generated from it
|
|
32
|
-
// by OpenCC + glossaries (scripts/zh-tw-locale).
|
|
33
15
|
{ code: "zh-Hant", nativeName: "繁體中文" },
|
|
34
16
|
{ code: "zh-HK", nativeName: "繁體中文(香港)" },
|
|
35
17
|
{ code: "zh-TW", nativeName: "繁體中文(台灣)" },
|
|
@@ -43,7 +25,6 @@ export function packMeta(code) {
|
|
|
43
25
|
export function packPath(dataDir, code) {
|
|
44
26
|
return join(dataDir, "locales", `${code}.json`);
|
|
45
27
|
}
|
|
46
|
-
/** Downloaded packs must look like this (extra fields ignored). */
|
|
47
28
|
export function validatePack(data, code) {
|
|
48
29
|
if (!data || typeof data !== "object")
|
|
49
30
|
return { ok: false, error: "not an object" };
|
|
@@ -63,8 +44,6 @@ export function validatePack(data, code) {
|
|
|
63
44
|
}
|
|
64
45
|
if (Object.keys(strings).length === 0)
|
|
65
46
|
return { ok: false, error: "empty strings" };
|
|
66
|
-
// Optional translator table for server-authored strings (issue #91 v2).
|
|
67
|
-
// Non-string values are rejected (same strictness as `strings`).
|
|
68
47
|
let serverStrings;
|
|
69
48
|
if (d["serverStrings"] !== undefined) {
|
|
70
49
|
if (!d["serverStrings"] || typeof d["serverStrings"] !== "object" || Array.isArray(d["serverStrings"])) {
|
|
@@ -91,7 +70,6 @@ export function validatePack(data, code) {
|
|
|
91
70
|
},
|
|
92
71
|
};
|
|
93
72
|
}
|
|
94
|
-
/** Read an installed pack (null when missing / corrupt — corrupt files are ignored, not deleted). */
|
|
95
73
|
export function readPackFile(dataDir, code) {
|
|
96
74
|
if (!isKnownPack(code))
|
|
97
75
|
return null;
|
|
@@ -113,13 +91,6 @@ export function listPacks(dataDir) {
|
|
|
113
91
|
return { ...meta, installed: installed !== null, version: installed?.version ?? null };
|
|
114
92
|
});
|
|
115
93
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Server-string tables (issue #91 v2): scan `<dataDir>/locales/*.json` pack
|
|
118
|
-
* files and register each pack's `serverStrings` section for pick() lookup.
|
|
119
|
-
* Called once at startup and after every pack install/remove. Files that are
|
|
120
|
-
* missing/corrupt/have no table are skipped (best-effort, never throws).
|
|
121
|
-
* Returns the language codes that actually contributed a table.
|
|
122
|
-
*/
|
|
123
94
|
export function loadServerStrings(dataDir) {
|
|
124
95
|
const loaded = [];
|
|
125
96
|
let files = [];
|
|
@@ -138,13 +109,10 @@ export function loadServerStrings(dataDir) {
|
|
|
138
109
|
loaded.push(extracted.code);
|
|
139
110
|
}
|
|
140
111
|
}
|
|
141
|
-
catch {
|
|
142
|
-
// corrupt pack — UI serving already ignores it; skip here too
|
|
143
|
-
}
|
|
112
|
+
catch { }
|
|
144
113
|
}
|
|
145
114
|
return loaded;
|
|
146
115
|
}
|
|
147
|
-
/** Drop one language's server-string table (pack removed). */
|
|
148
116
|
export function unloadServerStrings(code) {
|
|
149
117
|
unregisterServerStrings(code);
|
|
150
118
|
}
|
|
@@ -158,10 +126,6 @@ export function removePack(dataDir, code) {
|
|
|
158
126
|
return true;
|
|
159
127
|
}
|
|
160
128
|
const MAX_PACK_BYTES = 4 * 1024 * 1024;
|
|
161
|
-
/**
|
|
162
|
-
* Download a pack and persist it under <dataDir>/locales/<code>.json
|
|
163
|
-
* (atomic write via tmp + rename). Throws on network / validation errors.
|
|
164
|
-
*/
|
|
165
129
|
export async function installPack(dataDir, code, opts = {}) {
|
|
166
130
|
const meta = packMeta(code);
|
|
167
131
|
if (!meta)
|
|
@@ -201,8 +165,6 @@ export async function installPack(dataDir, code, opts = {}) {
|
|
|
201
165
|
}
|
|
202
166
|
catch (e) {
|
|
203
167
|
lastError = e instanceof Error ? e.message : String(e);
|
|
204
|
-
// A validation error means the URL answered with wrong content —
|
|
205
|
-
// don't silently retry the fallback for it, surface it directly.
|
|
206
168
|
if (lastError.startsWith("invalid "))
|
|
207
169
|
throw e;
|
|
208
170
|
}
|
|
@@ -212,12 +174,6 @@ export async function installPack(dataDir, code, opts = {}) {
|
|
|
212
174
|
}
|
|
213
175
|
throw new Error(lastError || `download failed for ${code}`);
|
|
214
176
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Resolve the system default fallback locale.
|
|
217
|
-
*
|
|
218
|
-
* Checks PI_WEB_LOCALE first, then inspects standard POSIX environment variables
|
|
219
|
-
* (LC_ALL, LC_MESSAGES, LANG, LANGUAGE). Normalizes tags (e.g. "en_US.UTF-8" -> "en").
|
|
220
|
-
*/
|
|
221
177
|
export function resolveSystemDefaultLocale(env = process.env) {
|
|
222
178
|
const explicit = (env.PI_WEB_LOCALE ?? "").trim();
|
|
223
179
|
if (explicit)
|
|
@@ -227,7 +183,6 @@ export function resolveSystemDefaultLocale(env = process.env) {
|
|
|
227
183
|
const val = (raw ?? "").trim();
|
|
228
184
|
if (!val || val === "C" || val === "POSIX")
|
|
229
185
|
continue;
|
|
230
|
-
// e.g. "en_US.UTF-8", "zh_CN.gbk", "zh_TW.UTF-8", "en-US", "de"
|
|
231
186
|
const cleaned = val.split(".")[0].split("@")[0].replace(/_/g, "-");
|
|
232
187
|
const lower = cleaned.toLowerCase();
|
|
233
188
|
if (lower === "zh-tw" || lower === "zh-hant" || lower === "zh-mo") {
|