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,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All-source update check: pi-web-ui itself, the installed pi core
|
|
3
|
-
* (@earendil-works/pi-coding-agent — probed via `pi --version`, with a
|
|
4
|
-
* vendored-copy fallback), the DIRECT pi extensions declared in
|
|
5
|
-
* <agentDir>/npm/package.json (fallback: raw node_modules walk), plus the
|
|
6
|
-
* git-source extensions declared in global/project settings.json (issue #178).
|
|
7
|
-
* Pure logic lives here so it can be unit-tested with an injected fetcher
|
|
8
|
-
* (and an injected pi-core probe); ClientSession only wires it to the wire
|
|
9
|
-
* protocol.
|
|
10
|
-
*/
|
|
11
1
|
import { execFile } from "node:child_process";
|
|
12
2
|
import { readdirSync, readFileSync, realpathSync, existsSync } from "node:fs";
|
|
13
3
|
import { delimiter, dirname, isAbsolute, join } from "node:path";
|
|
@@ -15,12 +5,9 @@ import { promisify } from "node:util";
|
|
|
15
5
|
import { pick } from "./i18n.js";
|
|
16
6
|
import { sdkCopies } from "./sdk-origin.js";
|
|
17
7
|
const PI_CORE_PACKAGE = "@earendil-works/pi-coding-agent";
|
|
18
|
-
/** npm 官方源;用户在 <agentDir>/npm/.npmrc 里配了镜像/私有源时会被覆盖(issue #151)。 */
|
|
19
8
|
export const NPM_DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
20
9
|
const FETCH_TIMEOUT_MS = 8_000;
|
|
21
|
-
/** Parallel registry lookups per batch. */
|
|
22
10
|
const CONCURRENCY = 5;
|
|
23
|
-
/** Simple numeric semver compare: >0 means a newer than b. */
|
|
24
11
|
export function compareVersions(a, b) {
|
|
25
12
|
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
26
13
|
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
@@ -32,43 +19,22 @@ export function compareVersions(a, b) {
|
|
|
32
19
|
}
|
|
33
20
|
return 0;
|
|
34
21
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Parse `pi --version` stdout into a version string, or null. Two-stage:
|
|
37
|
-
* prefer a line that is exactly the version (optional leading "v", optional
|
|
38
|
-
* prerelease/build suffix) so a stdout preamble like "Update available:
|
|
39
|
-
* 0.85.0" cannot forge it; otherwise fall back to the first loose
|
|
40
|
-
* semver-looking token. The exact-line match keeps the FULL version incl.
|
|
41
|
-
* prerelease (0.85.0-beta.1 stays 0.85.0-beta.1).
|
|
42
|
-
*/
|
|
43
22
|
export function parsePiVersionOutput(stdout) {
|
|
44
23
|
const exact = stdout.match(/^\s*v?(\d+\.\d+\.\d+(?:[-+][\w.]+)*)\s*$/m)?.[1];
|
|
45
24
|
if (exact)
|
|
46
25
|
return exact;
|
|
47
26
|
return stdout.match(/\d+\.\d+\.\d+/)?.[0] ?? null;
|
|
48
27
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Enumerate installed pi packages for the "check all updates" list, matching
|
|
51
|
-
* what the TUI shows: the DIRECT dependencies declared in
|
|
52
|
-
* <agentDir>/npm/package.json, with each installed version resolved from
|
|
53
|
-
* node_modules/<name>/package.json (not the manifest range). Transitive deps
|
|
54
|
-
* are not listed.
|
|
55
|
-
*
|
|
56
|
-
* Fallback: when the manifest is missing/unreadable or declares no
|
|
57
|
-
* dependencies, fall back to the historical raw node_modules walk.
|
|
58
|
-
*/
|
|
59
28
|
export function listInstalledPackages(agentDir) {
|
|
60
29
|
const direct = readManifestDeps(agentDir);
|
|
61
30
|
if (direct)
|
|
62
31
|
return direct;
|
|
63
32
|
return walkNodeModules(agentDir);
|
|
64
33
|
}
|
|
65
|
-
/** Direct deps from the npm manifest with installed versions, or null. */
|
|
66
34
|
function readManifestDeps(agentDir) {
|
|
67
35
|
let manifest;
|
|
68
36
|
try {
|
|
69
37
|
manifest = JSON.parse(readFileSync(join(agentDir, "npm", "package.json"), "utf8"));
|
|
70
|
-
// Literal `null` parses fine but explodes on property access — treat as
|
|
71
|
-
// unreadable (fallback to the raw walk), per the documented contract.
|
|
72
38
|
if (!manifest || typeof manifest !== "object")
|
|
73
39
|
return null;
|
|
74
40
|
}
|
|
@@ -83,18 +49,11 @@ function readManifestDeps(agentDir) {
|
|
|
83
49
|
const out = [];
|
|
84
50
|
for (const name of Object.keys(deps)) {
|
|
85
51
|
const item = readLocalPackage(join(root, ...name.split("/")));
|
|
86
|
-
// Broken/uninstalled entries are skipped (the registry never sees them).
|
|
87
52
|
if (item)
|
|
88
53
|
out.push(item);
|
|
89
54
|
}
|
|
90
|
-
// Deterministic order (manifest key order is arbitrary).
|
|
91
55
|
return out.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
92
56
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Legacy fallback: raw walk of <agentDir>/npm/node_modules — top-level plain
|
|
95
|
-
* names plus one level inside @scope dirs. Skips .bin, dotfiles and anything
|
|
96
|
-
* without a readable package.json.
|
|
97
|
-
*/
|
|
98
57
|
function walkNodeModules(agentDir) {
|
|
99
58
|
const root = join(agentDir, "npm", "node_modules");
|
|
100
59
|
const out = [];
|
|
@@ -130,7 +89,6 @@ function walkNodeModules(agentDir) {
|
|
|
130
89
|
out.push(item);
|
|
131
90
|
}
|
|
132
91
|
}
|
|
133
|
-
// Deterministic order (readdir order is FS-dependent).
|
|
134
92
|
return out.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
135
93
|
}
|
|
136
94
|
function readLocalPackage(dir) {
|
|
@@ -144,12 +102,7 @@ function readLocalPackage(dir) {
|
|
|
144
102
|
return null;
|
|
145
103
|
}
|
|
146
104
|
}
|
|
147
|
-
// -- git-source extensions (issue #178) --------------------------------------
|
|
148
|
-
// The panel historically enumerated only npm direct deps, so `git:` entries in
|
|
149
|
-
// settings.json never appeared. pi core updates both (`updateConfiguredSources`
|
|
150
|
-
// buckets npmCandidates/gitCandidates), keyed by normalized `git:host/path`.
|
|
151
105
|
const execFileAsync = promisify(execFile);
|
|
152
|
-
/** Matches pi core NETWORK_TIMEOUT_MS so slow forges degrade the same way. */
|
|
153
106
|
const GIT_TIMEOUT_MS = 10_000;
|
|
154
107
|
function hasUnsafeGitPart(value, allowSlash) {
|
|
155
108
|
if (value.includes("\0") || value.includes("\\") || value.startsWith("/"))
|
|
@@ -176,19 +129,12 @@ function normalizeGitRepo(host, path, ref) {
|
|
|
176
129
|
identity: `git:${host}/${cleanPath}`,
|
|
177
130
|
};
|
|
178
131
|
}
|
|
179
|
-
/** Split `rest` (the part after the host) on the first `@` into path + ref. */
|
|
180
132
|
function splitGitRef(rest) {
|
|
181
133
|
const at = rest.indexOf("@");
|
|
182
134
|
if (at < 0)
|
|
183
135
|
return { path: rest, ref: null };
|
|
184
136
|
return { path: rest.slice(0, at), ref: rest.slice(at + 1) || null };
|
|
185
137
|
}
|
|
186
|
-
/**
|
|
187
|
-
* Parse a settings `packages` entry into a git source, or null when it is not
|
|
188
|
-
* one. Accepts the same shapes pi core does (`parseGitUrl`): `git:`-prefixed
|
|
189
|
-
* shorthand/URLs plus bare explicit protocol URLs. `npm:`/local entries yield
|
|
190
|
-
* null — they are handled by the npm enumeration, not here.
|
|
191
|
-
*/
|
|
192
138
|
export function parseGitExtensionSource(entry) {
|
|
193
139
|
const trimmed = entry.trim();
|
|
194
140
|
if (!trimmed || trimmed.startsWith("npm:"))
|
|
@@ -196,13 +142,11 @@ export function parseGitExtensionSource(entry) {
|
|
|
196
142
|
const url = trimmed.startsWith("git:") ? trimmed.slice(4).trim() : trimmed;
|
|
197
143
|
if (!url)
|
|
198
144
|
return null;
|
|
199
|
-
// scp-like: git@host:owner/repo[.git][@ref]
|
|
200
145
|
const scp = url.match(/^git@([^:]+):(.+)$/);
|
|
201
146
|
if (scp) {
|
|
202
147
|
const { path, ref } = splitGitRef(scp[2]);
|
|
203
148
|
return normalizeGitRepo(scp[1], path, ref);
|
|
204
149
|
}
|
|
205
|
-
// Explicit protocol URLs (bare or git:-prefixed).
|
|
206
150
|
if (/^(https?|ssh|git):\/\//i.test(url)) {
|
|
207
151
|
let host;
|
|
208
152
|
let rest;
|
|
@@ -217,7 +161,6 @@ export function parseGitExtensionSource(entry) {
|
|
|
217
161
|
const { path, ref } = splitGitRef(rest);
|
|
218
162
|
return normalizeGitRepo(host, path, ref);
|
|
219
163
|
}
|
|
220
|
-
// Shorthand only with an explicit git: prefix (bare `a/b` is a local path).
|
|
221
164
|
if (!trimmed.startsWith("git:"))
|
|
222
165
|
return null;
|
|
223
166
|
const slash = url.indexOf("/");
|
|
@@ -229,10 +172,6 @@ export function parseGitExtensionSource(entry) {
|
|
|
229
172
|
const { path, ref } = splitGitRef(url.slice(slash + 1));
|
|
230
173
|
return normalizeGitRepo(host, path, ref);
|
|
231
174
|
}
|
|
232
|
-
/**
|
|
233
|
-
* Total switch for the git-source check (issue #178 step 8). `0/false/no/off`
|
|
234
|
-
* disables it (large-monorepo escape hatch); unset or anything else enables.
|
|
235
|
-
*/
|
|
236
175
|
export function isGitExtensionCheckEnabled(env = process.env) {
|
|
237
176
|
const v = (env.PI_WEB_GIT_EXTENSION_CHECK ?? "").trim().toLowerCase();
|
|
238
177
|
return v !== "0" && v !== "false" && v !== "no" && v !== "off";
|
|
@@ -251,9 +190,6 @@ function readSettingsPackagesFile(file) {
|
|
|
251
190
|
function readGitCloneNameVersion(installDir) {
|
|
252
191
|
try {
|
|
253
192
|
const pkg = JSON.parse(readFileSync(join(installDir, "package.json"), "utf8"));
|
|
254
|
-
// Name and version fall back independently: a clone with a version but
|
|
255
|
-
// no usable name still reports its version (name falls back to the
|
|
256
|
-
// source shorthand at the call site), and vice versa.
|
|
257
193
|
return {
|
|
258
194
|
...(typeof pkg.name === "string" && pkg.name ? { name: pkg.name } : {}),
|
|
259
195
|
...(typeof pkg.version === "string" && pkg.version ? { version: pkg.version } : {}),
|
|
@@ -302,8 +238,6 @@ export function listGitExtensions(agentDir, projectCwd, env = process.env) {
|
|
|
302
238
|
}
|
|
303
239
|
return out.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
304
240
|
}
|
|
305
|
-
/** Display form for git rows: `<version> (<short sha>)`, sha-only when the
|
|
306
|
-
* clone has no readable package.json version (issue #178 step 5). */
|
|
307
241
|
export function formatGitVersion(version, sha) {
|
|
308
242
|
const short = sha.slice(0, 7);
|
|
309
243
|
return version && version !== "?" ? `${version} (${short})` : short;
|
|
@@ -316,25 +250,12 @@ async function runGit(args, cwd) {
|
|
|
316
250
|
});
|
|
317
251
|
return stdout.trim();
|
|
318
252
|
}
|
|
319
|
-
/**
|
|
320
|
-
* Patterns to query via `git ls-remote` for a requested ref name.
|
|
321
|
-
* Full `refs/` paths are queried directly (with peeled tag fallback);
|
|
322
|
-
* shorthand names look up branches, tags, and peeled tags.
|
|
323
|
-
*/
|
|
324
253
|
export function buildLsRemotePatternsForRef(ref) {
|
|
325
254
|
if (ref.startsWith("refs/")) {
|
|
326
255
|
return [ref, `${ref}^{}`];
|
|
327
256
|
}
|
|
328
257
|
return [`refs/heads/${ref}`, `refs/tags/${ref}`, `refs/tags/${ref}^{}`, ref, `${ref}^{}`];
|
|
329
258
|
}
|
|
330
|
-
/**
|
|
331
|
-
* Pick the remote commit SHA corresponding to a requested ref from `git ls-remote` output.
|
|
332
|
-
*
|
|
333
|
-
* Precedence:
|
|
334
|
-
* 1. Full/explicit ref match (`refs/...^{}`, direct `refs/...`, or `HEAD`)
|
|
335
|
-
* 2. Branch ref: `refs/heads/<ref>`
|
|
336
|
-
* 3. Tag ref: peeled annotated tag (`refs/tags/<ref>^{}`) wins over lightweight tag (`refs/tags/<ref>`)
|
|
337
|
-
*/
|
|
338
259
|
export function pickRemoteShaForRef(output, ref) {
|
|
339
260
|
const map = new Map();
|
|
340
261
|
for (const line of output.split(/\r?\n/)) {
|
|
@@ -343,16 +264,13 @@ export function pickRemoteShaForRef(output, ref) {
|
|
|
343
264
|
map.set(match[2], match[1]);
|
|
344
265
|
}
|
|
345
266
|
}
|
|
346
|
-
// Full / explicit ref match
|
|
347
267
|
if (map.has(`${ref}^{}`))
|
|
348
268
|
return map.get(`${ref}^{}`);
|
|
349
269
|
if (map.has(ref))
|
|
350
270
|
return map.get(ref);
|
|
351
|
-
// Branch: refs/heads/<ref>
|
|
352
271
|
const branchRef = `refs/heads/${ref}`;
|
|
353
272
|
if (map.has(branchRef))
|
|
354
273
|
return map.get(branchRef);
|
|
355
|
-
// Tag: peeled tag wins over unpeeled tag
|
|
356
274
|
const peeledTagRef = `refs/tags/${ref}^{}`;
|
|
357
275
|
if (map.has(peeledTagRef))
|
|
358
276
|
return map.get(peeledTagRef);
|
|
@@ -361,13 +279,6 @@ export function pickRemoteShaForRef(output, ref) {
|
|
|
361
279
|
return map.get(tagRef);
|
|
362
280
|
return null;
|
|
363
281
|
}
|
|
364
|
-
/**
|
|
365
|
-
* Compare a clone's HEAD against its remote (lightweight: `ls-remote` fetches
|
|
366
|
-
* refs only, no objects). When a configured ref (`@...`) is given, the remote
|
|
367
|
-
* benchmark is resolved from that ref (branch, tag, or commit sha) instead of
|
|
368
|
-
* blindly comparing against the checked-out branch's upstream (issue #665).
|
|
369
|
-
* When ref is absent, upstream branch wins when configured, else origin HEAD.
|
|
370
|
-
*/
|
|
371
282
|
export async function defaultCheckGitExtension(installDir, ref) {
|
|
372
283
|
const localSha = await runGit(["rev-parse", "HEAD"], installDir);
|
|
373
284
|
if (!/^[0-9a-f]{40}$/i.test(localSha))
|
|
@@ -385,8 +296,6 @@ export async function defaultCheckGitExtension(installDir, ref) {
|
|
|
385
296
|
lsRemoteError = err;
|
|
386
297
|
}
|
|
387
298
|
if (!remoteSha && /^[0-9a-f]{7,40}$/i.test(targetRef)) {
|
|
388
|
-
// Commit SHA reference: if local HEAD already matches the requested SHA (prefix or exact),
|
|
389
|
-
// the clone is fully up to date.
|
|
390
299
|
if (localSha.toLowerCase().startsWith(targetRef.toLowerCase())) {
|
|
391
300
|
remoteSha = localSha;
|
|
392
301
|
}
|
|
@@ -396,9 +305,7 @@ export async function defaultCheckGitExtension(installDir, ref) {
|
|
|
396
305
|
if (/^[0-9a-f]{40}$/i.test(parsed))
|
|
397
306
|
remoteSha = parsed;
|
|
398
307
|
}
|
|
399
|
-
catch {
|
|
400
|
-
/* commit not present in local repo yet */
|
|
401
|
-
}
|
|
308
|
+
catch { }
|
|
402
309
|
if (!remoteSha)
|
|
403
310
|
remoteSha = targetRef;
|
|
404
311
|
}
|
|
@@ -419,9 +326,7 @@ export async function defaultCheckGitExtension(installDir, ref) {
|
|
|
419
326
|
remoteSha = out.match(/^([0-9a-f]{40})\s+/m)?.[1] ?? null;
|
|
420
327
|
}
|
|
421
328
|
}
|
|
422
|
-
catch {
|
|
423
|
-
/* no usable upstream — fall through to origin HEAD */
|
|
424
|
-
}
|
|
329
|
+
catch { }
|
|
425
330
|
if (!remoteSha) {
|
|
426
331
|
const out = await runGit(["ls-remote", "origin", "HEAD"], installDir);
|
|
427
332
|
remoteSha = out.match(/^([0-9a-f]{40})\s+HEAD$/m)?.[1] ?? null;
|
|
@@ -430,11 +335,8 @@ export async function defaultCheckGitExtension(installDir, ref) {
|
|
|
430
335
|
throw new Error("Failed to determine remote HEAD");
|
|
431
336
|
return { localSha, remoteSha };
|
|
432
337
|
}
|
|
433
|
-
/** How long a pi probe result stays hot (mirrors ClientSession.piCliProbe). */
|
|
434
338
|
const PI_PROBE_TTL_MS = 10_000;
|
|
435
339
|
let piCoreProbe = null;
|
|
436
|
-
/** Read a pi-core package.json's version, or null when absent, not ours, or
|
|
437
|
-
* unreadable. Shared by all resolution strategies below. */
|
|
438
340
|
function readPiCoreVersionAt(pkgPath) {
|
|
439
341
|
if (!existsSync(pkgPath))
|
|
440
342
|
return null;
|
|
@@ -443,9 +345,7 @@ function readPiCoreVersionAt(pkgPath) {
|
|
|
443
345
|
if (pkg.name === PI_CORE_PACKAGE && pkg.version)
|
|
444
346
|
return pkg.version;
|
|
445
347
|
}
|
|
446
|
-
catch {
|
|
447
|
-
/* unreadable package.json */
|
|
448
|
-
}
|
|
348
|
+
catch { }
|
|
449
349
|
return null;
|
|
450
350
|
}
|
|
451
351
|
/**
|
|
@@ -458,11 +358,6 @@ function readPiCoreVersionAt(pkgPath) {
|
|
|
458
358
|
function versionFromSiblingNodeModules(bin) {
|
|
459
359
|
return readPiCoreVersionAt(join(dirname(bin), "node_modules", ...PI_CORE_PACKAGE.split("/"), "package.json"));
|
|
460
360
|
}
|
|
461
|
-
/**
|
|
462
|
-
* POSIX: `pi` is a symlink into <prefix>/node_modules/<pkg>/dist/bundle/cli.js
|
|
463
|
-
* — realpath it and walk up (≤8 levels) until a package.json names our
|
|
464
|
-
* package. Functionally unchanged from the original probe.
|
|
465
|
-
*/
|
|
466
361
|
function versionFromSymlinkWalk(bin) {
|
|
467
362
|
try {
|
|
468
363
|
let dir = dirname(realpathSync(bin));
|
|
@@ -476,21 +371,13 @@ function versionFromSymlinkWalk(bin) {
|
|
|
476
371
|
dir = parent;
|
|
477
372
|
}
|
|
478
373
|
}
|
|
479
|
-
catch {
|
|
480
|
-
/* ignore */
|
|
481
|
-
}
|
|
374
|
+
catch { }
|
|
482
375
|
return null;
|
|
483
376
|
}
|
|
484
|
-
/**
|
|
485
|
-
* Attempt to resolve the installed @earendil-works/pi-coding-agent package version
|
|
486
|
-
* from a candidate `pi` executable/script path.
|
|
487
|
-
*/
|
|
488
377
|
function versionFromCandidate(bin) {
|
|
489
|
-
// 1. Sibling layout: <binDir>/node_modules/<pkg>/package.json
|
|
490
378
|
const sib = versionFromSiblingNodeModules(bin);
|
|
491
379
|
if (sib)
|
|
492
380
|
return sib;
|
|
493
|
-
// 2. .bin layout: if bin is inside a `.bin` folder, check sibling of `.bin` (which is node_modules)
|
|
494
381
|
const dir = dirname(bin);
|
|
495
382
|
const parent = dirname(dir);
|
|
496
383
|
if (dir.endsWith(".bin") || dir.endsWith(".bin\\") || dir.endsWith(".bin/")) {
|
|
@@ -498,7 +385,6 @@ function versionFromCandidate(bin) {
|
|
|
498
385
|
if (parentNm)
|
|
499
386
|
return parentNm;
|
|
500
387
|
}
|
|
501
|
-
// 3. Wrapper script content inspection (Windows .cmd / .ps1 or shell wrapper)
|
|
502
388
|
try {
|
|
503
389
|
const head = readFileSync(bin, "utf8").slice(0, 4096);
|
|
504
390
|
const m = head.match(/[^\r\n"']*@earendil-works[/\\]pi-coding-agent[^\r\n"']*/);
|
|
@@ -518,10 +404,7 @@ function versionFromCandidate(bin) {
|
|
|
518
404
|
}
|
|
519
405
|
}
|
|
520
406
|
}
|
|
521
|
-
catch {
|
|
522
|
-
/* ignore */
|
|
523
|
-
}
|
|
524
|
-
// 4. POSIX symlink walk
|
|
407
|
+
catch { }
|
|
525
408
|
const sym = versionFromSymlinkWalk(bin);
|
|
526
409
|
if (sym)
|
|
527
410
|
return sym;
|
|
@@ -590,13 +473,6 @@ export function readPiCoreVersionFromDisk(env = process.env) {
|
|
|
590
473
|
}
|
|
591
474
|
return bestVersion;
|
|
592
475
|
}
|
|
593
|
-
/**
|
|
594
|
-
* Default pi core probe: run the globally installed `pi --version`, memoized
|
|
595
|
-
* machine-wide for PI_PROBE_TTL_MS so repeated collectTargets calls never
|
|
596
|
-
* re-probe. Reads the version from disk (pi bin → realpath → package.json)
|
|
597
|
-
* instead of spawning `pi --version`. FORK-FREE by design — see the note on
|
|
598
|
-
* defaultProbePiCore.
|
|
599
|
-
*/
|
|
600
476
|
export function defaultProbePiCore(env = process.env) {
|
|
601
477
|
const now = Date.now();
|
|
602
478
|
const cached = piCoreProbe;
|
|
@@ -632,10 +508,6 @@ export function detectPiSdkSplit(runningVersion, probePiCore = defaultProbePiCor
|
|
|
632
508
|
return null;
|
|
633
509
|
return { running: runningVersion, installed };
|
|
634
510
|
}
|
|
635
|
-
/**
|
|
636
|
-
* Fallback when the CLI probe yields nothing: the version of the vendored pi
|
|
637
|
-
* core copy in <agentDir>/npm/node_modules, or null if that is absent too.
|
|
638
|
-
*/
|
|
639
511
|
function readVendoredPiCore(agentDir) {
|
|
640
512
|
try {
|
|
641
513
|
const pkg = JSON.parse(readFileSync(join(agentDir, "npm", "node_modules", ...PI_CORE_PACKAGE.split("/"), "package.json"), "utf8"));
|
|
@@ -647,11 +519,6 @@ function readVendoredPiCore(agentDir) {
|
|
|
647
519
|
return null;
|
|
648
520
|
}
|
|
649
521
|
}
|
|
650
|
-
/**
|
|
651
|
-
* 宿主 SDK 及其 peer/内部包(@earendil-works/* / @mariozechner/*):
|
|
652
|
-
* 属于宿主引擎随核心一同分发或由别名提供的 SDK 内部构件,非用户安装的独立扩展组件;
|
|
653
|
-
* 既不应在组件列表重复展示,也不能被 `pi update npm:<name>` 更新(会报 No matching package found,issue #393)。
|
|
654
|
-
*/
|
|
655
522
|
export function isHostProvidedPackage(name) {
|
|
656
523
|
return name === PI_CORE_PACKAGE || name.startsWith("@earendil-works/") || name.startsWith("@mariozechner/");
|
|
657
524
|
}
|
|
@@ -666,10 +533,7 @@ export function isHostProvidedPackage(name) {
|
|
|
666
533
|
export function collectTargets(agentDir, webuiVersion, probePiCore = defaultProbePiCore, opts) {
|
|
667
534
|
const targets = [{ name: "pi-web-ui", version: webuiVersion, kind: "webui" }];
|
|
668
535
|
const coreVersion = probePiCore() ?? readVendoredPiCore(agentDir);
|
|
669
|
-
// issue #533: keep the pi-core row even when the version is undetectable
|
|
670
536
|
// (e.g. unreadable global install) instead of silently dropping it — an
|
|
671
|
-
// honest "could not detect" row beats a missing one. checkAll resolves the
|
|
672
|
-
// key into the item's localized `error`.
|
|
673
537
|
targets.push({
|
|
674
538
|
name: PI_CORE_PACKAGE,
|
|
675
539
|
version: coreVersion ?? "unknown",
|
|
@@ -683,12 +547,7 @@ export function collectTargets(agentDir, webuiVersion, probePiCore = defaultProb
|
|
|
683
547
|
targets.push(...listGitExtensions(agentDir, opts?.projectCwd));
|
|
684
548
|
return targets;
|
|
685
549
|
}
|
|
686
|
-
/** Default fetcher (real network). Tests inject a fake. */
|
|
687
550
|
export const defaultFetcher = (url, init) => fetch(url, init);
|
|
688
|
-
/**
|
|
689
|
-
* 解析 .npmrc 文本里的全局 registry(`registry=<url>`,后出现的覆盖先出现的)。
|
|
690
|
-
* 找不到返回 null(调用方回落 NPM_DEFAULT_REGISTRY)。引号与行尾 `/` 会被清理。
|
|
691
|
-
*/
|
|
692
551
|
export function parseNpmrcRegistry(text) {
|
|
693
552
|
let registry = null;
|
|
694
553
|
for (const raw of text.split(/\r?\n/)) {
|
|
@@ -710,10 +569,6 @@ export function parseNpmrcRegistry(text) {
|
|
|
710
569
|
}
|
|
711
570
|
return registry;
|
|
712
571
|
}
|
|
713
|
-
/**
|
|
714
|
-
* 从 .npmrc 文本里找出与 registry 同源的认证头(`//host/path:_authToken=` 优先,
|
|
715
|
-
* 其次 `//host/path:_auth=`)。私有源检查更新时没有它会直接 401(issue #151)。
|
|
716
|
-
*/
|
|
717
572
|
export function parseNpmrcAuth(text, registry) {
|
|
718
573
|
let host;
|
|
719
574
|
try {
|
|
@@ -739,7 +594,6 @@ export function parseNpmrcAuth(text, registry) {
|
|
|
739
594
|
.trim();
|
|
740
595
|
if (!value)
|
|
741
596
|
continue;
|
|
742
|
-
// key 形如 //registry.example.com/:_authToken —— 取 // 与 : 之间的 host 比对
|
|
743
597
|
const keyHost = key.slice(2).split("/")[0].split(":")[0].toLowerCase();
|
|
744
598
|
if (keyHost !== host)
|
|
745
599
|
continue;
|
|
@@ -754,11 +608,6 @@ export function parseNpmrcAuth(text, registry) {
|
|
|
754
608
|
return `Basic ${basic}`;
|
|
755
609
|
return null;
|
|
756
610
|
}
|
|
757
|
-
/**
|
|
758
|
-
* 读取 <agentDir>/npm/.npmrc(`pi update --extensions` 经 npm 自动遵守的同一份),
|
|
759
|
-
* 解析出检查更新该用的 registry + 认证头。文件不存在/不可读/无 registry 行时
|
|
760
|
-
* 回落官方源(issue #151:镜像/私有源用户不再被卡在官方源上)。
|
|
761
|
-
*/
|
|
762
611
|
export function resolveNpmRegistry(agentDir) {
|
|
763
612
|
try {
|
|
764
613
|
const text = readFileSync(join(agentDir, "npm", ".npmrc"), "utf8");
|
|
@@ -769,11 +618,6 @@ export function resolveNpmRegistry(agentDir) {
|
|
|
769
618
|
return { registry: NPM_DEFAULT_REGISTRY, authHeader: null };
|
|
770
619
|
}
|
|
771
620
|
}
|
|
772
|
-
/**
|
|
773
|
-
* Look up one package's latest version + publish time in the npm registry.
|
|
774
|
-
* registry/authHeader 默认官方源;镜像/私有源用户经 resolveNpmRegistry 传入
|
|
775
|
-
* <agentDir>/npm/.npmrc 的配置(issue #151)。
|
|
776
|
-
*/
|
|
777
621
|
export async function fetchLatest(fetcher, name, registry = NPM_DEFAULT_REGISTRY, authHeader = null) {
|
|
778
622
|
const res = await fetcher(`${registry}/${encodeURIComponent(name)}`, {
|
|
779
623
|
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
|
|
@@ -788,20 +632,7 @@ export async function fetchLatest(fetcher, name, registry = NPM_DEFAULT_REGISTRY
|
|
|
788
632
|
latestPublishedAt: latest && data.time ? (data.time[latest] ?? null) : null,
|
|
789
633
|
};
|
|
790
634
|
}
|
|
791
|
-
|
|
792
|
-
* Check every target: npm kinds against the registry, git-extension kinds
|
|
793
|
-
* against their clone's remote (`ls-remote`, refs only). One failed lookup
|
|
794
|
-
* degrades to an error item (upToDate: false) without failing the rest.
|
|
795
|
-
* Results keep the input order. Bounded concurrency (CONCURRENCY) keeps
|
|
796
|
-
* registry/remote load polite. The git checker is injectable for tests.
|
|
797
|
-
*/
|
|
798
|
-
export async function checkAll(targets, fetcher = defaultFetcher,
|
|
799
|
-
/** 单项查询失败时的 error 文案语言(默认英文)。 */
|
|
800
|
-
lang,
|
|
801
|
-
/** 镜像/私有源配置(默认官方源;调用方经 resolveNpmRegistry 传入 .npmrc,issue #151)。 */
|
|
802
|
-
registryConfig,
|
|
803
|
-
/** git 源远端比较(默认真 git;单测注入 fake,issue #178)。 */
|
|
804
|
-
gitCheck = defaultCheckGitExtension) {
|
|
635
|
+
export async function checkAll(targets, fetcher = defaultFetcher, lang, registryConfig, gitCheck = defaultCheckGitExtension) {
|
|
805
636
|
const l = lang?.() ?? "en";
|
|
806
637
|
const registry = registryConfig?.registry ?? NPM_DEFAULT_REGISTRY;
|
|
807
638
|
const authHeader = registryConfig?.authHeader ?? null;
|
|
@@ -824,9 +655,6 @@ gitCheck = defaultCheckGitExtension) {
|
|
|
824
655
|
const i = cursor++;
|
|
825
656
|
const t = targets[i];
|
|
826
657
|
if (t.error) {
|
|
827
|
-
// Pre-flagged target (issue #533, e.g. undetectable pi-core
|
|
828
|
-
// version): `error` carries an i18n key resolved here so
|
|
829
|
-
// collectTargets stays language-free. No registry lookup.
|
|
830
658
|
results[i] = {
|
|
831
659
|
name: t.name,
|
|
832
660
|
kind: t.kind,
|
|
@@ -879,10 +707,6 @@ gitCheck = defaultCheckGitExtension) {
|
|
|
879
707
|
await Promise.all(Array.from({ length: Math.min(CONCURRENCY, targets.length) }, worker));
|
|
880
708
|
return results;
|
|
881
709
|
}
|
|
882
|
-
/** Display order for the Component Updates panel: pi-web-ui and pi-core
|
|
883
|
-
* pinned at the top regardless of state, then out-of-date packages, then
|
|
884
|
-
* up-to-date ones, errors last. Stable within each bucket (Array.sort is
|
|
885
|
-
* stable) so registry order survives ties. */
|
|
886
710
|
export function sortUpdateItems(items) {
|
|
887
711
|
const kindRank = (k) => k === "webui" ? 0 : k === "pi-core" ? 1 : k === "engine" ? 2 : k === "plugin" ? 3 : 4;
|
|
888
712
|
return [...items].sort((a, b) => {
|
package/dist/server/uploads.js
CHANGED
|
@@ -1,43 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* uploads — 文件对话上传的存储与清理。
|
|
3
|
-
*
|
|
4
|
-
* 上传文件落在 <dataDir>/uploads/<clientId>/<ts>-<uuid>-<name>(模型以绝对路径
|
|
5
|
-
* reference 读取)。此前这里硬编码 ~/.pi-web,不吃 PI_WEB_DATA_DIR —— 已改为
|
|
6
|
-
* 与 index.ts 相同的解析逻辑。清理策略:默认保留 14 天,启动时扫一次 +
|
|
7
|
-
* 每 6 小时扫一次;PI_WEB_UPLOAD_RETENTION_DAYS 覆盖保留天数,0 = 关闭清理。
|
|
8
|
-
* 全程 best-effort:清理失败绝不影响服务。
|
|
9
|
-
*/
|
|
10
1
|
import { readdir, rm, stat } from "node:fs/promises";
|
|
11
2
|
import { existsSync, mkdirSync, writeFileSync, linkSync, rmSync } from "node:fs";
|
|
12
3
|
import { randomUUID } from "node:crypto";
|
|
13
4
|
import { shellQuotePosix } from "./remote-ssh-service.js";
|
|
14
5
|
import { homedir } from "node:os";
|
|
15
6
|
import { join, resolve, posix } from "node:path";
|
|
16
|
-
/** Same resolution as index.ts DATA_DIR — kept in sync by env contract. */
|
|
17
7
|
export function resolveDataDir() {
|
|
18
8
|
return resolve(process.env.PI_WEB_DATA_DIR ?? join(homedir(), ".pi-web"));
|
|
19
9
|
}
|
|
20
10
|
export function uploadsRoot(dataDir = resolveDataDir()) {
|
|
21
11
|
return join(dataDir, "uploads");
|
|
22
12
|
}
|
|
23
|
-
/** Retention in days; 0 disables sweeping. */
|
|
24
13
|
export function uploadRetentionDays() {
|
|
25
14
|
const v = Number(process.env.PI_WEB_UPLOAD_RETENTION_DAYS);
|
|
26
15
|
return Number.isFinite(v) && v >= 0 ? v : 14;
|
|
27
16
|
}
|
|
28
|
-
/** clientId 白名单:clientId 来自浏览器自报(ws hello),却直接拼进上传目录
|
|
29
|
-
* 路径 —— 只允许安全的单段字符(字母数字、:、_、-,1-128 长),否则可
|
|
30
|
-
* "../" 遍历写任意目录。不匹配整条拒绝抛错:绝不能静默换 randomUUID,
|
|
31
|
-
* 上传目录必须与 ws 会话一一对应(编辑重问靠 uploadPath 按同一目录找回)。 */
|
|
32
17
|
export const CLIENT_ID_PATTERN = /^[A-Za-z0-9:_-]{1,128}$/;
|
|
33
|
-
/** Persist an uploaded buffer; returns the absolute path + sanitized display name.
|
|
34
|
-
* clientId 不匹配白名单、displayName 为空 / "." / ".." 时抛错,调用方负责报错。 */
|
|
35
18
|
export function saveUpload(clientId, name, buf, dataDir = resolveDataDir()) {
|
|
36
19
|
if (!CLIENT_ID_PATTERN.test(clientId)) {
|
|
37
20
|
throw new Error(`Invalid upload clientId: ${JSON.stringify(clientId.slice(0, 129))}`);
|
|
38
21
|
}
|
|
39
|
-
// displayName 只取 basename 并拒绝 "." / "..":防 ".." 与绝对路径拼接穿越
|
|
40
|
-
// (最终文件名带 <ts>- 前缀兜底,这里从源头收紧)。
|
|
41
22
|
const base = name.split(/[\\/]/).pop() ?? "";
|
|
42
23
|
if (!base || base === "." || base === "..") {
|
|
43
24
|
throw new Error(`Invalid upload name: ${JSON.stringify(name.slice(0, 129))}`);
|
|
@@ -49,8 +30,6 @@ export function saveUpload(clientId, name, buf, dataDir = resolveDataDir()) {
|
|
|
49
30
|
writeUploadExclusiveSync(abs, buf);
|
|
50
31
|
return { abs, displayName };
|
|
51
32
|
}
|
|
52
|
-
/** Publish only a complete file, using a same-volume hard link for atomic no-replace.
|
|
53
|
-
* NTFS and POSIX support this; unsupported filesystems fail without a destructive fallback. */
|
|
54
33
|
export function writeUploadExclusiveSync(dest, data) {
|
|
55
34
|
const temp = `${dest}.${randomUUID()}.upload`;
|
|
56
35
|
try {
|
|
@@ -61,8 +40,6 @@ export function writeUploadExclusiveSync(dest, data) {
|
|
|
61
40
|
rmSync(temp, { force: true });
|
|
62
41
|
}
|
|
63
42
|
}
|
|
64
|
-
/** SFTP accepts buffers only. Stage exclusively, then use portable POSIX ln
|
|
65
|
-
* without -f: a competing regular file can never be overwritten. */
|
|
66
43
|
export async function writeRemoteUploadExclusive(ssh, cwd, dest, data, signal) {
|
|
67
44
|
const temp = `${dest}.${randomUUID()}.upload`;
|
|
68
45
|
const operationSignal = signal ? AbortSignal.any([signal, AbortSignal.timeout(30_000)]) : AbortSignal.timeout(30_000);
|
|
@@ -77,8 +54,6 @@ export async function writeRemoteUploadExclusive(ssh, cwd, dest, data, signal) {
|
|
|
77
54
|
};
|
|
78
55
|
try {
|
|
79
56
|
operationSignal.throwIfAborted();
|
|
80
|
-
// Do not race cancellation against SFTP: HTTP reservations must remain
|
|
81
|
-
// held until the underlying write releases its buffered payload.
|
|
82
57
|
await ssh.sftpWriteFile(cwd, temp, data, {
|
|
83
58
|
createParents: true,
|
|
84
59
|
flag: "wx",
|
|
@@ -87,8 +62,6 @@ export async function writeRemoteUploadExclusive(ssh, cwd, dest, data, signal) {
|
|
|
87
62
|
});
|
|
88
63
|
operationSignal.throwIfAborted();
|
|
89
64
|
const target = shellQuotePosix(dest);
|
|
90
|
-
// POSIX ln treats a directory as a container. Guard it both before and
|
|
91
|
-
// after linking, removing only our unpredictable link if a directory raced.
|
|
92
65
|
const stray = shellQuotePosix(posix.join(dest, posix.basename(temp)));
|
|
93
66
|
const result = await ssh.execInWorkspace(cwd, `if test -e ${target} || test -L ${target}; then exit 17; fi; ln ${shellQuotePosix(temp)} ${target} || exit 17; if test -d ${target}; then rm -f ${stray}; exit 17; fi`, {
|
|
94
67
|
cwd: "/",
|
|
@@ -106,11 +79,6 @@ export async function writeRemoteUploadExclusive(ssh, cwd, dest, data, signal) {
|
|
|
106
79
|
await cleanup();
|
|
107
80
|
}
|
|
108
81
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Delete uploaded files older than the retention window, then prune client
|
|
111
|
-
* dirs left empty. Returns { files, bytes, dirs } removed (best-effort:
|
|
112
|
-
* individual failures are skipped).
|
|
113
|
-
*/
|
|
114
82
|
export async function cleanupUploads(dataDir = resolveDataDir(), retentionDays = uploadRetentionDays()) {
|
|
115
83
|
const out = { files: 0, bytes: 0, dirs: 0 };
|
|
116
84
|
if (retentionDays <= 0)
|
|
@@ -133,7 +101,7 @@ export async function cleanupUploads(dataDir = resolveDataDir(), retentionDays =
|
|
|
133
101
|
entries = await readdir(dir);
|
|
134
102
|
}
|
|
135
103
|
catch {
|
|
136
|
-
continue;
|
|
104
|
+
continue;
|
|
137
105
|
}
|
|
138
106
|
for (const entry of entries) {
|
|
139
107
|
const abs = join(dir, entry);
|
|
@@ -145,9 +113,7 @@ export async function cleanupUploads(dataDir = resolveDataDir(), retentionDays =
|
|
|
145
113
|
out.files++;
|
|
146
114
|
out.bytes += st.size;
|
|
147
115
|
}
|
|
148
|
-
catch {
|
|
149
|
-
// skip on any per-file failure
|
|
150
|
-
}
|
|
116
|
+
catch { }
|
|
151
117
|
}
|
|
152
118
|
try {
|
|
153
119
|
if ((await readdir(dir)).length === 0) {
|
|
@@ -155,9 +121,7 @@ export async function cleanupUploads(dataDir = resolveDataDir(), retentionDays =
|
|
|
155
121
|
out.dirs++;
|
|
156
122
|
}
|
|
157
123
|
}
|
|
158
|
-
catch {
|
|
159
|
-
// ignore
|
|
160
|
-
}
|
|
124
|
+
catch { }
|
|
161
125
|
}
|
|
162
126
|
return out;
|
|
163
127
|
}
|
|
@@ -165,11 +129,8 @@ async function rmdirSafe(dir) {
|
|
|
165
129
|
try {
|
|
166
130
|
await rm(dir, { recursive: false });
|
|
167
131
|
}
|
|
168
|
-
catch {
|
|
169
|
-
// non-empty or race — fine
|
|
170
|
-
}
|
|
132
|
+
catch { }
|
|
171
133
|
}
|
|
172
|
-
/** Startup sweep + periodic re-sweep. Timer is unref'd so it never blocks exit. */
|
|
173
134
|
export function scheduleUploadCleanup(intervalMs = 6 * 60 * 60 * 1000) {
|
|
174
135
|
void cleanupUploads().catch(() => { });
|
|
175
136
|
const timer = setInterval(() => {
|