pi-web-ui 0.116.0 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -3
- package/README.md +69 -138
- package/README.zh-CN.md +70 -179
- package/README.zh-TW.md +3 -1
- package/bin/device-hub-cli.mjs +163 -36
- package/bin/frp-manager.mjs +4 -80
- package/bin/hub-upgrade.mjs +561 -0
- package/bin/pi-device-hub.mjs +0 -1
- package/bin/pi-web-ui.mjs +184 -504
- package/deploy/nginx-subpath.conf +0 -33
- package/deploy/pi-web-ui.service +0 -20
- package/dist/server/agent-formatters.js +4 -38
- package/dist/server/agent-service-daemon.js +203 -371
- package/dist/server/agent-service.js +1281 -3030
- package/dist/server/approval-audit.js +2 -23
- package/dist/server/approval-default-rules.js +0 -6
- package/dist/server/approval-rules.js +7 -105
- package/dist/server/ask-user-question-tool.js +1 -12
- package/dist/server/atomic-file.js +33 -5
- package/dist/server/attachment-store.js +0 -36
- package/dist/server/attachments.js +3 -112
- package/dist/server/auth-cookie.js +0 -21
- package/dist/server/bash-tool.js +1 -32
- package/dist/server/bg-servers.js +0 -96
- package/dist/server/browser-page-tool.js +11 -62
- package/dist/server/builtin-modules.js +7 -0
- package/dist/server/canvas/canvas-agent-tool.js +58 -47
- package/dist/server/canvas/canvas-cards.js +0 -14
- package/dist/server/canvas/canvas-dispatch.js +7 -4
- package/dist/server/canvas/canvas-orchestrator.js +167 -181
- package/dist/server/canvas/canvas-runtime-messages.js +30 -0
- package/dist/server/canvas/canvas-scheduled-task.js +0 -3
- package/dist/server/canvas/canvas-scheduler.js +5 -7
- package/dist/server/canvas/canvas-store.js +24 -35
- package/dist/server/canvas/canvas-validation.js +17 -14
- package/dist/server/canvas/canvas-workspace.js +42 -114
- package/dist/server/canvas/pstack-skills-data.js +0 -5
- package/dist/server/claim-files-tool.js +1 -15
- package/dist/server/claim-store.js +5 -49
- package/dist/server/client-id-utils.js +0 -16
- package/dist/server/client-state.js +36 -214
- package/dist/server/communicate-tool.js +0 -3
- package/dist/server/compact-context-tool.js +0 -30
- package/dist/server/compacted-history.js +0 -35
- package/dist/server/compaction-instructions.js +0 -13
- package/dist/server/compaction-markers.js +38 -92
- package/dist/server/compaction-state.js +0 -21
- package/dist/server/composer-drafts.js +0 -34
- package/dist/server/context-budget-runner.js +0 -11
- package/dist/server/context-budget.js +1 -70
- package/dist/server/context-evidence.js +0 -14
- package/dist/server/context-usage.js +0 -12
- package/dist/server/control-socket.js +4 -48
- package/dist/server/conversation-communication.js +0 -10
- package/dist/server/conversation-identity.js +0 -1
- package/dist/server/conversation-read-tool.js +0 -58
- package/dist/server/conversation-tool-names.js +0 -1
- package/dist/server/conversation-tool.js +0 -1
- package/dist/server/conversation-touches.js +4 -75
- package/dist/server/dangling-tools.js +142 -68
- package/dist/server/delegate-mode.js +0 -36
- package/dist/server/delegate-task.js +2 -28
- package/dist/server/device-center/approval-summary.js +0 -1
- package/dist/server/device-center/bot-catalog.js +0 -3
- package/dist/server/device-center/bot-execution.js +48 -9
- package/dist/server/device-center/bot-presets.js +0 -1
- package/dist/server/device-center/bots.js +0 -1
- package/dist/server/device-center/collab-service.js +27 -11
- package/dist/server/device-center/collab-tool.js +393 -27
- package/dist/server/device-center/connector.js +128 -48
- package/dist/server/device-center/delivery-authority.js +95 -0
- package/dist/server/device-center/delivery-subject.js +29 -0
- package/dist/server/device-center/desktop-linux.js +3 -15
- package/dist/server/device-center/desktop-native.js +1 -10
- package/dist/server/device-center/desktop-page.js +2 -3
- package/dist/server/device-center/desktop-setup.js +1 -3
- package/dist/server/device-center/desktop.js +1 -7
- package/dist/server/device-center/device-integration.js +452 -208
- package/dist/server/device-center/device-lan-access.js +403 -0
- package/dist/server/device-center/device-lan.js +484 -0
- package/dist/server/device-center/device-portals.js +0 -3
- package/dist/server/device-center/execution-failure.js +0 -2
- package/dist/server/device-center/execution-guides.js +15 -6
- package/dist/server/device-center/execution-instructions.js +0 -1
- package/dist/server/device-center/execution-settings.js +0 -1
- package/dist/server/device-center/execution-system-prompt.js +0 -3
- package/dist/server/device-center/execution-workspace.js +1 -4
- package/dist/server/device-center/executor.js +46 -31
- package/dist/server/device-center/file-sync-paths.js +0 -5
- package/dist/server/device-center/file-sync.js +0 -10
- package/dist/server/device-center/group-context-delta.js +0 -8
- package/dist/server/device-center/group-context-message.js +0 -14
- package/dist/server/device-center/group-context.js +0 -19
- package/dist/server/device-center/group-events.js +0 -2
- package/dist/server/device-center/group-plan-guard.js +1 -35
- package/dist/server/device-center/group-router-runtime.js +182 -0
- package/dist/server/device-center/group-router-worker.js +178 -0
- package/dist/server/device-center/group-router.js +359 -0
- package/dist/server/device-center/hub-auth.js +24 -2
- package/dist/server/device-center/hub-conversations.js +13 -15
- package/dist/server/device-center/hub-deliveries.js +119 -15
- package/dist/server/device-center/hub-integration.js +647 -334
- package/dist/server/device-center/hub-locks.js +1 -5
- package/dist/server/device-center/hub-mobile.js +147 -0
- package/dist/server/device-center/hub-orchestration.js +400 -0
- package/dist/server/device-center/hub-page.js +28 -9
- package/dist/server/device-center/hub-setup.js +23 -7
- package/dist/server/device-center/hub-transaction-log.js +175 -0
- package/dist/server/device-center/hub-upgrade.js +162 -0
- package/dist/server/device-center/hub-webhooks.js +1 -3
- package/dist/server/device-center/hub.js +946 -404
- package/dist/server/device-center/human-interaction.js +1 -4
- package/dist/server/device-center/integration-errors.js +0 -2
- package/dist/server/device-center/integration-verification.js +111 -0
- package/dist/server/device-center/local-hub.js +6 -4
- package/dist/server/device-center/local-publication.js +416 -0
- package/dist/server/device-center/local-verification-job.js +95 -0
- package/dist/server/device-center/local-verification.js +273 -0
- package/dist/server/device-center/local.js +341 -18
- package/dist/server/device-center/main.js +18 -2
- package/dist/server/device-center/mobile-notification-forwarder.js +292 -0
- package/dist/server/device-center/native-desktop/macos.js +0 -1
- package/dist/server/device-center/native-desktop/windows.js +0 -1
- package/dist/server/device-center/partition-log.js +52 -46
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +305 -0
- package/dist/server/device-center/publish-intent.js +374 -0
- package/dist/server/device-center/relay.js +217 -52
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +419 -52
- package/dist/server/device-center/store.js +223 -65
- package/dist/server/device-center/task-context-budget.js +0 -3
- package/dist/server/device-center/task-error.js +0 -1
- package/dist/server/device-center/task-journal.js +6 -23
- package/dist/server/device-center/task-outcome.js +68 -0
- package/dist/server/device-center/task-plan.js +0 -1
- package/dist/server/device-center/task-progress.js +0 -16
- package/dist/server/device-center/task-recovery.js +569 -227
- package/dist/server/device-center/task-report-outbox.js +0 -4
- package/dist/server/device-center/task-report.js +2 -10
- package/dist/server/device-center/task-scheduler.js +1 -35
- package/dist/server/device-center/task-settlement.js +335 -0
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +393 -0
- package/dist/server/device-center/transfer-stream.js +5 -45
- package/dist/server/device-center/transfers.js +2 -10
- package/dist/server/device-center/verification-limits.js +9 -0
- package/dist/server/device-center/work-contract.js +923 -0
- package/dist/server/device-center/work-items.js +317 -0
- package/dist/server/device-center/workspaces.js +0 -1
- package/dist/server/dispatch-domain-handlers.js +202 -29
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +78 -601
- package/dist/server/dsh/dsh-client.js +7 -111
- package/dist/server/dsh/dsh-market-service.js +4 -25
- package/dist/server/dsh/dsh-serialize.js +0 -49
- package/dist/server/dsh/dsh-sessions.js +0 -37
- package/dist/server/dsh/dsh-usage.js +0 -37
- package/dist/server/dsh/preset-clones.js +1 -65
- package/dist/server/dsh/runtime/custom-prompt.mjs +0 -14
- package/dist/server/dsh/runtime/goal-rpc.mjs +7 -176
- package/dist/server/dsh/runtime/launcher.mjs +2 -53
- package/dist/server/dsh/runtime/override.patch.yml +0 -29
- package/dist/server/dsh/runtime/runtime-root.mjs +0 -54
- package/dist/server/durable/durable-agent-service.js +5 -23
- package/dist/server/durable/durable-driver.js +12 -73
- package/dist/server/durable/durable-event-projector.js +1 -50
- package/dist/server/durable/durable-loader.js +0 -12
- package/dist/server/durable/durable-models.js +11 -80
- package/dist/server/durable/durable-storage.js +1 -17
- package/dist/server/durable/durable-tools.js +2 -20
- package/dist/server/durable/index.js +0 -3
- package/dist/server/edit-soft-tool.js +2 -81
- package/dist/server/engine-capabilities.js +0 -13
- package/dist/server/engine-catalog.js +74 -0
- package/dist/server/engine-cli.js +89 -0
- package/dist/server/engine-probe.js +35 -217
- package/dist/server/ensure-bash.js +2 -28
- package/dist/server/eval-tool.js +1 -50
- package/dist/server/evidence-tool-hooks.js +0 -2
- package/dist/server/file-archives.js +0 -10
- package/dist/server/file-save.js +1 -12
- package/dist/server/file-transfer-routes.js +0 -11
- package/dist/server/files-service.js +18 -271
- package/dist/server/global-loader.js +9 -89
- package/dist/server/goal-evidence.js +1 -35
- package/dist/server/goal-review-gate.js +0 -58
- package/dist/server/goal-service.js +19 -422
- package/dist/server/hashline-engine.js +8 -112
- package/dist/server/host-guard.js +0 -24
- package/dist/server/host-metrics.js +0 -6
- package/dist/server/http-proxy.js +1 -7
- package/dist/server/i18n.js +5 -72
- package/dist/server/icon-svg.js +0 -15
- package/dist/server/index.js +199 -677
- package/dist/server/json-utils.js +0 -12
- package/dist/server/launch-origin.js +0 -44
- package/dist/server/left-panel-running.js +0 -9
- package/dist/server/load-timing.js +1 -4
- package/dist/server/load-tools-tool.js +0 -20
- package/dist/server/locales.js +1 -46
- package/dist/server/lsp-tool.js +13 -126
- package/dist/server/managed.js +0 -48
- package/dist/server/marker-service.js +1 -22
- package/dist/server/markers/builtins/action.js +0 -19
- package/dist/server/markers/builtins/notify.js +1 -9
- package/dist/server/markers/builtins/rename.js +0 -13
- package/dist/server/markers/index.js +0 -3
- package/dist/server/markers/marker.js +0 -13
- package/dist/server/markers/registry.js +0 -3
- package/dist/server/markers/store.js +1 -12
- package/dist/server/market-service.js +7 -43
- package/dist/server/mcp-agent-tool.js +0 -10
- package/dist/server/mcp-bridge.js +6 -138
- package/dist/server/mcp-hot-reload.js +0 -25
- package/dist/server/mcp-manager.js +2 -44
- package/dist/server/mcp-oauth-login.js +0 -2
- package/dist/server/mcp-oauth-ui.js +1 -4
- package/dist/server/mcp-oauth.js +5 -79
- package/dist/server/mcp-project-runtime.js +0 -4
- package/dist/server/message-deletion.js +0 -2
- package/dist/server/message-entry-resolver.js +0 -8
- package/dist/server/message-window.js +0 -71
- package/dist/server/mobile-notification-events.js +16 -0
- package/dist/server/mobile-origin.js +79 -0
- package/dist/server/mobile-push.js +523 -0
- package/dist/server/model-admin.js +19 -358
- package/dist/server/model-enrich.js +0 -19
- package/dist/server/model-resolver.js +2 -61
- package/dist/server/native-cli-discovery.js +115 -0
- package/dist/server/native-cli-model.js +71 -0
- package/dist/server/native-cli-references.js +214 -0
- package/dist/server/native-cli-remote-cleanup.js +58 -0
- package/dist/server/native-cli-remote-files.js +282 -0
- package/dist/server/native-cli-routes.js +68 -0
- package/dist/server/native-cli-runtime.js +1 -0
- package/dist/server/native-cli-session-hooks.js +170 -0
- package/dist/server/native-cli-session.js +585 -0
- package/dist/server/native-cli-state.js +82 -0
- package/dist/server/native-cli.js +210 -0
- package/dist/server/net-guard.js +9 -71
- package/dist/server/office-parse.js +0 -50
- package/dist/server/orphan-manager.js +0 -18
- package/dist/server/patch-bash-process.js +0 -4
- package/dist/server/patch-executable-lookup.js +0 -77
- package/dist/server/patch-node-pty.js +6 -45
- package/dist/server/patch-remote-catalog.js +4 -34
- package/dist/server/patch-tool.js +0 -15
- package/dist/server/payload-limits.js +0 -5
- package/dist/server/pending-question.js +0 -5
- package/dist/server/permission-preset.js +4 -33
- package/dist/server/persona-chain.js +0 -26
- package/dist/server/pkg-info.js +1 -17
- package/dist/server/plan-manager.js +2 -49
- package/dist/server/plan-mode.js +0 -97
- package/dist/server/plan-update-tool.js +1 -15
- package/dist/server/plugin-api-catalog.js +6 -4
- package/dist/server/plugin-assets.js +1 -35
- package/dist/server/plugin-bundled.js +68 -0
- package/dist/server/plugin-catalog-sync.js +0 -37
- package/dist/server/plugin-catalog.js +13 -67
- package/dist/server/plugin-chat-attachments.js +0 -1
- package/dist/server/plugin-conversation-view.js +0 -20
- package/dist/server/plugin-dom.js +1 -23
- package/dist/server/plugin-facilities.js +4 -115
- package/dist/server/plugin-grants.js +2 -90
- package/dist/server/plugin-install-spec.js +0 -43
- package/dist/server/plugin-installer.js +34 -75
- package/dist/server/plugin-llm.js +4 -38
- package/dist/server/plugin-manifest-validate.js +0 -31
- package/dist/server/plugin-permissions.js +1 -24
- package/dist/server/plugin-project.js +7 -129
- package/dist/server/plugin-removal.js +1 -8
- package/dist/server/plugin-schedule.js +1 -38
- package/dist/server/plugin-secrets.js +3 -16
- package/dist/server/plugin-tool-guard.js +1 -28
- package/dist/server/plugin-ui-slots.js +0 -4
- package/dist/server/plugin-updater.js +15 -90
- package/dist/server/plugins.js +71 -619
- package/dist/server/present-files-tool.js +0 -57
- package/dist/server/preset-fields.js +24 -61
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +4 -172
- package/dist/server/process-utils.js +4 -80
- package/dist/server/prompt-assembler.js +2 -30
- package/dist/server/prompt-base-store.js +0 -47
- package/dist/server/prompt-composer.js +21 -98
- package/dist/server/prompt-templates.js +0 -2
- package/dist/server/protocol-version.js +1 -11
- package/dist/server/protocol.js +0 -5
- package/dist/server/queue-modes.js +0 -3
- package/dist/server/queue-utils.js +0 -40
- package/dist/server/quick-ask-context.js +384 -0
- package/dist/server/quick-ask-settings.js +61 -0
- package/dist/server/quick-ask.js +260 -0
- package/dist/server/read-tool.js +0 -65
- package/dist/server/reasoning-registry.js +1 -29
- package/dist/server/remote-cli-persistence.js +373 -0
- package/dist/server/remote-native-cli.js +78 -0
- package/dist/server/remote-ssh-service.js +481 -190
- package/dist/server/request-context.js +0 -9
- package/dist/server/resolve-global-sdk.js +55 -31
- package/dist/server/sandbox-data.js +0 -1
- package/dist/server/sandbox-engines.js +0 -1
- package/dist/server/sandbox-runtime-gate.js +0 -3
- package/dist/server/sandbox-service.js +0 -41
- package/dist/server/sandbox-tool.js +0 -20
- package/dist/server/schedule-agent-tool.js +2 -31
- package/dist/server/scheduler-tasks.js +32 -56
- package/dist/server/scm-commitmsg.js +0 -53
- package/dist/server/scm.js +3 -48
- package/dist/server/sdk-builtin-extensions.js +2 -29
- package/dist/server/sdk-origin.js +0 -45
- package/dist/server/serialize.js +2 -92
- package/dist/server/server-config.js +0 -11
- package/dist/server/session-branch.js +1 -87
- package/dist/server/session-list-scan.js +215 -0
- package/dist/server/session-open.js +69 -0
- package/dist/server/session-parser.js +4 -54
- package/dist/server/session-scan.js +81 -45
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +19 -126
- package/dist/server/setup-config.js +0 -2
- package/dist/server/setup-page.js +0 -9
- package/dist/server/skill-content-filler.js +0 -17
- package/dist/server/skill-discovery.js +5 -92
- package/dist/server/skill-maintenance.js +1 -28
- package/dist/server/skill-tool.js +0 -30
- package/dist/server/slash-commands.js +5 -50
- package/dist/server/soft-cap.js +3 -40
- package/dist/server/startup-banner.js +0 -8
- package/dist/server/subagent-handoff.js +0 -11
- package/dist/server/subagent-helpers.js +2 -17
- package/dist/server/subagent-notify.js +0 -19
- package/dist/server/subagent-security-gate.js +0 -50
- package/dist/server/subagent-task.js +0 -9
- package/dist/server/subagent-templates-hant.js +0 -10
- package/dist/server/subagent-templates.js +3 -103
- package/dist/server/subagents.js +1 -87
- package/dist/server/system-screenshot-windows.js +259 -0
- package/dist/server/system-screenshot.js +77 -0
- package/dist/server/tabs.js +3 -48
- package/dist/server/terminals.js +559 -586
- package/dist/server/text-quote.js +0 -12
- package/dist/server/text-sniff.js +2 -52
- package/dist/server/themes.js +2 -41
- package/dist/server/tool-approval.js +0 -47
- package/dist/server/tool-guards.js +0 -90
- package/dist/server/tool-host-factories.js +1 -16
- package/dist/server/tool-info.js +0 -13
- package/dist/server/tool-manager.js +1 -229
- package/dist/server/tool-overrides.js +1 -46
- package/dist/server/tool-prompt-overrides.js +1 -30
- package/dist/server/tool-prompts.js +0 -14
- package/dist/server/tool-signature.js +0 -25
- package/dist/server/transcript-prepare.js +55 -0
- package/dist/server/tts-routes.js +58 -0
- package/dist/server/tts-service.js +106 -0
- package/dist/server/tts-system.js +160 -0
- package/dist/server/turn-timing.js +0 -1
- package/dist/server/unauthorized-page.js +0 -8
- package/dist/server/universal/driver-base.js +2 -31
- package/dist/server/universal/drivers/claude-code.js +98 -194
- package/dist/server/universal/drivers/codex.js +12 -35
- package/dist/server/universal/drivers/mock-driver.js +1 -11
- package/dist/server/universal/index.js +0 -3
- package/dist/server/universal/session-store.js +4 -21
- package/dist/server/universal/universal-attachments.js +2 -36
- package/dist/server/universal/universal-service.js +5 -24
- package/dist/server/universal/universal-session.js +30 -148
- package/dist/server/universal/universal-types.js +0 -3
- package/dist/server/update-check.js +6 -182
- package/dist/server/uploads.js +4 -43
- package/dist/server/virtual-tui.js +2 -27
- package/dist/server/vision-bridge.js +0 -27
- package/dist/server/wait-subscription-scan.js +13 -115
- package/dist/server/webui-context.js +2 -87
- package/dist/server/workspace-handle.js +373 -0
- package/dist/server/workspace-snapshot.js +7 -113
- package/dist/server/worktree-service.js +2 -53
- package/dist/server/worktree-tool.js +0 -11
- package/dist/server/ws-client-id.js +0 -18
- package/dist/server/ws-pending-queue.js +0 -7
- package/dist/server/ws-unknown-types.js +0 -17
- package/docs/README.md +24 -17
- package/docs/architecture-plugins.md +55 -6
- package/docs/device-center.md +57 -23
- package/docs/device-desktop.md +3 -3
- package/docs/group-orchestration.md +142 -0
- package/docs/hub-upgrade-release-testing.md +46 -0
- package/extensions/webui.ts +3 -74
- package/package.json +9 -6
- package/plugin-sdk/README.md +22 -8
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +26 -0
- package/plugin-sdk/client.mjs +52 -0
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +128 -117
- package/plugin-sdk/index.mjs +2 -687
- package/plugin-sdk/package.json +15 -4
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +9 -0
- package/plugin-sdk/testing.mjs +511 -0
- package/plugins/catalog.json +52 -4
- package/plugins/superagent/README.md +110 -0
- package/plugins/superagent/client/entry.mjs +21 -0
- package/plugins/superagent/index.mjs +8 -0
- package/plugins/superagent/main.mjs +218 -0
- package/plugins/superagent/manifest.json +15 -0
- package/plugins/superagent/server.mjs +572 -0
- package/plugins/superagent/style.css +167 -0
- package/themes/aetheris.css +1 -31
- package/themes/ayu-light.css +0 -1
- package/themes/bases/flow-base.css +2 -83
- package/themes/bases/obsidian-base.css +2 -37
- package/themes/bases/statusbar-flat-base.css +0 -1
- package/themes/bases/zhujian-base.css +0 -63
- package/themes/bases/zhupi-base.css +0 -64
- package/themes/catppuccin-latte.css +0 -1
- package/themes/catppuccin.css +0 -1
- package/themes/claude-code-dark.css +0 -1
- package/themes/codex.css +0 -1
- package/themes/dark-teal.css +22 -54
- package/themes/everforest-light.css +0 -1
- package/themes/flow-cristallo.css +160 -0
- package/themes/flow-ink.css +160 -0
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +160 -0
- package/themes/flow-zurich.css +160 -0
- package/themes/flow.css +1 -9
- package/themes/geist.css +0 -1
- package/themes/gruvbox-light.css +0 -1
- package/themes/kanagawa-lotus.css +0 -1
- package/themes/md-preview.css +1 -2
- package/themes/mist.css +0 -1
- package/themes/nord.css +0 -1
- package/themes/one-dark.css +0 -1
- package/themes/paper.css +0 -1
- package/themes/rose-pine-dawn.css +0 -1
- package/themes/sakura.css +0 -1
- package/themes/solarized-light.css +0 -1
- package/themes/tokyo-night.css +0 -1
- package/themes/translucent.css +4 -35
- package/themes/transparent.css +4 -41
- package/themes/vs-code-dark.css +0 -1
- package/themes/wallpaper-flow.css +3 -17
- package/themes/wallpaper-obsidian.css +1 -4
- package/themes/white.css +0 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BDoOpj-F.js → BgTasksModal-D-x7kA63.js} +1 -1
- package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
- package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
- package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
- package/web/dist/assets/{Dropdown-C4LIhshN.js → Dropdown-CTgVLUbp.js} +1 -1
- package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
- package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
- package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
- package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
- package/web/dist/assets/{HintTip-c6d0TJoh.js → HintTip-Da6qc566.js} +1 -1
- package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
- package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
- package/web/dist/assets/{PiSetupModal-BmMrrgB9.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/SCMPanel-CuEgzAlO.js +2 -0
- package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
- package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
- package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
- package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
- package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
- package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
- package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
- package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
- package/web/dist/assets/index-CQc3VrWa.css +1 -0
- package/web/dist/assets/index-D_AGu4Zv.js +404 -0
- package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
- package/web/dist/assets/{remote-ssh-client-CfYSMEZg.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +12 -11
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/dist/gh-comment-781.md +0 -5
- package/dist/server/device-center/local-page.js +0 -17
- package/dist/server/device-center/smoke-preview.js +0 -3
- package/dist/server/durable/durable-capabilities.js +0 -11
- package/dist/server/markers/builtins/services.js +0 -123
- package/dist/server/markers/builtins/todo.js +0 -189
- package/dist/server/markers-list-tool.js +0 -34
- package/dist/server/orchestrator.js +0 -109
- package/dist/server/patch-turn-end-boundary.js +0 -77
- package/dist/server/system-prompt-soul.js +0 -41
- package/dist/server/univer-service.js +0 -448
- package/dist/server/universal/drivers/dsh-driver.js +0 -379
- package/dist/test-artifact.md +0 -9
- package/dist/test-preview-modal.md +0 -11
- package/dist/test-report.html +0 -20
- package/web/dist/assets/BgTasksModal-C0i3O1FT.js +0 -1
- package/web/dist/assets/CanvasStudio-B8thymBN.js +0 -1579
- package/web/dist/assets/CanvasStudio-zSxyIx1R.js +0 -1579
- package/web/dist/assets/DeviceCenter-DfAHKcid.js +0 -3
- package/web/dist/assets/DeviceCenter-ydvOTlzE.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-q5Ik8oXg.js +0 -1
- package/web/dist/assets/DeviceGroups-CI14_SRb.js +0 -1
- package/web/dist/assets/DeviceGroups-DvsB5IEU.js +0 -1
- package/web/dist/assets/FilePreview-BgGongmv.js +0 -2
- package/web/dist/assets/FilePreview-D4NrhF-U.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BWgU8yPd.js +0 -1
- package/web/dist/assets/GlobalSearchModal-F7fNimKk.js +0 -1
- package/web/dist/assets/GroupConversation-Dh71Pdb-.js +0 -17
- package/web/dist/assets/GroupConversation-ZK3nRmNm.js +0 -17
- package/web/dist/assets/ModelConfigModal-YVEgyy34.js +0 -2
- package/web/dist/assets/ModelConfigModal-vWtg3srp.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-BGSBIKD7.js +0 -1
- package/web/dist/assets/SCMPanel-B8_EDxNr.js +0 -2
- package/web/dist/assets/SCMPanel-BU58qk3T.js +0 -2
- package/web/dist/assets/SettingsModal-CMUybq3J.js +0 -32
- package/web/dist/assets/SettingsModal-OBmGTh-5.js +0 -32
- package/web/dist/assets/TerminalPanel-0CYvD72B.js +0 -3
- package/web/dist/assets/TerminalPanel-DDavKvFr.js +0 -3
- package/web/dist/assets/TuiOverlayModal-BsA-QTvN.js +0 -1
- package/web/dist/assets/TuiOverlayModal-DzoVQBuG.js +0 -1
- package/web/dist/assets/app-globals-CZxzGvIo.js +0 -123
- package/web/dist/assets/canvas-client-CUnXlQYX.js +0 -1
- package/web/dist/assets/desktop-aAKpvKJV.js +0 -1
- package/web/dist/assets/index-C6DwztqE.css +0 -1
- package/web/dist/assets/index-CuN802Sj.js +0 -93
- package/web/dist/assets/index-EH5Fw9fa.js +0 -93
- package/web/dist/assets/plugin-host-BRWib9DF.js +0 -1
- package/web/dist/assets/theme-D2l_mLNo.js +0 -1
|
@@ -1,39 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* plugin-installer — 插件的后台安装作业(安装 / 更新 / 卸载)。
|
|
3
|
-
*
|
|
4
|
-
* 设置面板里的插件操作原本开一个**可见终端 tab** 跑 CLI:过程看得见,但每次操作
|
|
5
|
-
* 都切主视图 + 关掉设置弹窗 —— 连装几个插件就是「装一个、重开设置、再导航回市场」
|
|
6
|
-
* (issue #152)。这里把同一件事搬到服务端后台:
|
|
7
|
-
*
|
|
8
|
-
* - 真正执行者仍是 CLI(`pi-web-ui install|uninstall`,bin/pi-web-ui.mjs)——
|
|
9
|
-
* 单一实现,界面与终端行为永不漂移(`--build` 之类新选项自动同步);
|
|
10
|
-
* - 输出按行回传(`plugin_job` 的 log 段),结束时回 `done`(成功与否 + 输出尾部),
|
|
11
|
-
* 前端就地显示,弹窗不关;
|
|
12
|
-
* - 完成后由调用方(index.ts)重扫插件 + 重推市场列表;
|
|
13
|
-
* - **同一时刻只跑一个作业**:安装要动 `<dataDir>/plugins/<id>`,两个作业写同一
|
|
14
|
-
* 目录必出半装状态,所以第二个请求直接被拒(提示等它结束);
|
|
15
|
-
* - 看门狗:超时杀掉整棵进程树,绝不留一个卡死的 install 占着锁。
|
|
16
|
-
*
|
|
17
|
-
* 它不决定「谁能装」:managed 实例与 tabs 闸门在 index.ts 的 dispatch 上做(见
|
|
18
|
-
* managed.ts 的「服务端拒绝,客户端只是隐藏」);这里只兜一层,防止别的调用路径绕过。
|
|
19
|
-
*/
|
|
20
1
|
import { spawn } from "node:child_process";
|
|
21
|
-
import { existsSync } from "node:fs";
|
|
22
|
-
import { join } from "node:path";
|
|
2
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
3
|
+
import { basename, join, resolve } from "node:path";
|
|
4
|
+
import { isBuiltinModule } from "./builtin-modules.js";
|
|
23
5
|
import { pick } from "./i18n.js";
|
|
24
6
|
import { isValidSource } from "./plugin-catalog.js";
|
|
25
|
-
import { inspectLocalInstallSpec, manifestCandidateUrls, readLocalManifest, suggestPluginId, } from "./plugin-install-spec.js";
|
|
7
|
+
import { inspectLocalInstallSpec, manifestCandidateUrls, parseInstallSpec, readLocalManifest, suggestPluginId, } from "./plugin-install-spec.js";
|
|
26
8
|
import { killPidTree } from "./process-utils.js";
|
|
27
|
-
/** 插件 id 字符集(与 server/plugins.ts、plugin-catalog.ts 一致,防路径穿越)。 */
|
|
28
9
|
const ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
29
|
-
|
|
10
|
+
function isBuiltinModulePath(path) {
|
|
11
|
+
let canonical = resolve(path);
|
|
12
|
+
try {
|
|
13
|
+
canonical = realpathSync(canonical);
|
|
14
|
+
}
|
|
15
|
+
catch { }
|
|
16
|
+
return isBuiltinModule(basename(canonical).toLowerCase());
|
|
17
|
+
}
|
|
18
|
+
function builtinModuleError(lang) {
|
|
19
|
+
return pick(lang, "内置模块由宿主管理,不能通过插件入口安装、更新或卸载。", "Built-in modules are managed by the host and cannot be installed, updated or uninstalled as plugins.");
|
|
20
|
+
}
|
|
30
21
|
const DEFAULT_TIMEOUT_MS = 15 * 60_000;
|
|
31
|
-
/** 回传给前端的输出尾部上限(失败时展开排障用,别把整个 build 日志塞进消息)。 */
|
|
32
22
|
const MAX_OUTPUT_CHARS = 8000;
|
|
33
|
-
/** 单行上限:某些工具会吐超长单行(进度条),截断后再回传。 */
|
|
34
23
|
const MAX_LINE_CHARS = 2000;
|
|
35
|
-
/** 纯函数:把作业规格翻成 CLI argv(含安全校验),便于单测。
|
|
36
|
-
* 返回 `{ args }` 或 `{ error }`(文案按 lang 本地化)。 */
|
|
37
24
|
export function buildPluginJobArgs(spec, dataDir, lang) {
|
|
38
25
|
const l = lang?.() ?? "en";
|
|
39
26
|
const id = String(spec?.id ?? "").trim();
|
|
@@ -41,6 +28,8 @@ export function buildPluginJobArgs(spec, dataDir, lang) {
|
|
|
41
28
|
return {
|
|
42
29
|
error: pick(l, `非法插件 id "${id}"(仅限字母数字-_)`, `Invalid plugin id "${id}" (letters/digits/-/_ only)`, "plugininstaller.id.invalid", { id }),
|
|
43
30
|
};
|
|
31
|
+
if (isBuiltinModule(id.toLowerCase()) || isBuiltinModulePath(join(dataDir, "plugins", id)))
|
|
32
|
+
return { error: builtinModuleError(l) };
|
|
44
33
|
if (spec.action === "uninstall")
|
|
45
34
|
return { args: ["uninstall", id, "--data-dir", dataDir] };
|
|
46
35
|
const source = String(spec?.source ?? "").trim();
|
|
@@ -48,6 +37,8 @@ export function buildPluginJobArgs(spec, dataDir, lang) {
|
|
|
48
37
|
return {
|
|
49
38
|
error: pick(l, "安装源需为 owner/repo 或 owner/repo/子目录(本地路径请用命令行安装)", "Install source must be owner/repo or owner/repo/subdir (local paths are CLI-only)", "plugininstaller.source.invalid"),
|
|
50
39
|
};
|
|
40
|
+
if (isBuiltinModule(suggestPluginId(parseInstallSpec(source)).toLowerCase()))
|
|
41
|
+
return { error: builtinModuleError(l) };
|
|
51
42
|
const args = ["install", source, "--name", id, "--data-dir", dataDir];
|
|
52
43
|
if (spec.action === "update")
|
|
53
44
|
args.push("--force");
|
|
@@ -61,21 +52,17 @@ export function buildPluginJobArgs(spec, dataDir, lang) {
|
|
|
61
52
|
args.push("--no-build");
|
|
62
53
|
return { args };
|
|
63
54
|
}
|
|
64
|
-
/** 安装前的 spec 检查(DSH P0-3 引导式安装)。
|
|
65
|
-
*
|
|
66
|
-
* 三层:① 形状分类(parseInstallSpec)+ 本地已装判定(inspectLocalInstallSpec);
|
|
67
|
-
* ② 本地路径源:直接读它的 manifest.json;
|
|
68
|
-
* ③ 远端 GitHub 源:一次 raw.githubusercontent 探测(超时 6s,失败不阻断)——
|
|
69
|
-
* 拿到 manifest 就归到 not-found / not-a-package / not-a-bundle 之一,
|
|
70
|
-
* 拿不到(网络/代理问题)回 network 但**不阻塞安装**(problem 只作提示)。
|
|
71
|
-
*
|
|
72
|
-
* 通一不联网:测试时传 fetchImpl 替身;生产走全局 fetch。
|
|
73
|
-
*/
|
|
74
55
|
export async function inspectInstallSpec(rawSpec, deps) {
|
|
75
56
|
const local = inspectLocalInstallSpec(rawSpec, deps);
|
|
76
|
-
|
|
57
|
+
const rejectBuiltin = () => ({ ...local, problem: "invalid-spec", detail: builtinModuleError("en") });
|
|
58
|
+
const isBuiltinId = (id) => !!id && isBuiltinModule(id.trim().toLowerCase());
|
|
59
|
+
if (isBuiltinId(deps.explicitId) ||
|
|
60
|
+
isBuiltinId(local.suggestedId) ||
|
|
61
|
+
isBuiltinId(suggestPluginId(local.spec)) ||
|
|
62
|
+
isBuiltinModulePath(join(deps.pluginsDir, local.suggestedId)) ||
|
|
63
|
+
(local.spec.kind === "path" && isBuiltinModulePath(local.spec.normalized)))
|
|
64
|
+
return rejectBuiltin();
|
|
77
65
|
if (local.problem || local.spec.kind === "npm" || local.spec.kind === "url") {
|
|
78
|
-
// npm/url 不在本检查的覆盖范围(CLI/注册表自己会报)——原样返回,让 CLI 说话。
|
|
79
66
|
return local;
|
|
80
67
|
}
|
|
81
68
|
if (local.spec.kind === "path") {
|
|
@@ -86,9 +73,10 @@ export async function inspectInstallSpec(rawSpec, deps) {
|
|
|
86
73
|
problem: "not-a-package",
|
|
87
74
|
detail: `No manifest.json found in ${local.spec.normalized} — this is not a pi-web-ui plugin.`,
|
|
88
75
|
};
|
|
76
|
+
if (isBuiltinId(manifest.id))
|
|
77
|
+
return rejectBuiltin();
|
|
89
78
|
return { ...local, manifest, suggestedId: suggestPluginId(local.spec, deps.explicitId ?? manifest.id) };
|
|
90
79
|
}
|
|
91
|
-
// github 简写:远端探测 best-effort(失败只补一条提示,不挡安装)。
|
|
92
80
|
for (const url of manifestCandidateUrls(local.spec)) {
|
|
93
81
|
try {
|
|
94
82
|
const res = await (deps.fetchImpl ?? fetch)(url, { signal: AbortSignal.timeout(deps.timeoutMs ?? 6000) });
|
|
@@ -103,13 +91,14 @@ export async function inspectInstallSpec(rawSpec, deps) {
|
|
|
103
91
|
problem: "not-a-bundle",
|
|
104
92
|
detail: "The remote manifest.json is not a valid plugin manifest (missing id/name).",
|
|
105
93
|
};
|
|
94
|
+
if (isBuiltinId(manifest.id))
|
|
95
|
+
return rejectBuiltin();
|
|
106
96
|
return { ...local, manifest, suggestedId: suggestPluginId(local.spec, deps.explicitId ?? manifest.id) };
|
|
107
97
|
}
|
|
108
98
|
catch {
|
|
109
99
|
return { ...local, problem: "network", detail: "Could not reach the remote repository to verify the plugin." };
|
|
110
100
|
}
|
|
111
101
|
}
|
|
112
|
-
// 连 manifest 都没探到 —— 仓库/子目录/分支不存在,或根本不是插件包。
|
|
113
102
|
return {
|
|
114
103
|
...local,
|
|
115
104
|
problem: "not-found",
|
|
@@ -140,11 +129,9 @@ export class PluginInstaller {
|
|
|
140
129
|
constructor(deps) {
|
|
141
130
|
this.deps = deps;
|
|
142
131
|
}
|
|
143
|
-
/** 正在跑的作业 id(null = 空闲)。 */
|
|
144
132
|
get busyJobId() {
|
|
145
133
|
return this.currentJobId;
|
|
146
134
|
}
|
|
147
|
-
/** 启动一个作业;返回 `{ ok: true }` 或 `{ error }`(拒绝原因,已本地化)。 */
|
|
148
135
|
start(spec, hooks) {
|
|
149
136
|
const l = hooks.lang?.() ?? "en";
|
|
150
137
|
if (this.deps.managed)
|
|
@@ -171,16 +158,10 @@ export class PluginInstaller {
|
|
|
171
158
|
try {
|
|
172
159
|
hooks.emit(msg);
|
|
173
160
|
}
|
|
174
|
-
catch {
|
|
175
|
-
/* socket 已死:作业继续跑,只是没人看进度 */
|
|
176
|
-
}
|
|
161
|
+
catch { }
|
|
177
162
|
};
|
|
178
163
|
const child = spawn(process.execPath, [binPath, ...built.args], {
|
|
179
164
|
windowsHide: true,
|
|
180
|
-
// POSIX 下自成进程组:取消/看门狗要杀的是整棵树,killPidTree 用 -pid
|
|
181
|
-
// 干活需要这一点(与 plugin-project.ts 同一写法)。缺了它,Linux/macOS
|
|
182
|
-
// 上 kill(-pid) 指向不存在的组而静默失败,作业杀不掉、锁一直占着
|
|
183
|
-
// (CI 的 busy 单测在 Linux 上 5 秒超时,Windows 走 taskkill 不受影响)。
|
|
184
165
|
detached: process.platform !== "win32",
|
|
185
166
|
env: {
|
|
186
167
|
...process.env,
|
|
@@ -241,9 +222,7 @@ export class PluginInstaller {
|
|
|
241
222
|
...(error ? { error } : {}),
|
|
242
223
|
output: out,
|
|
243
224
|
});
|
|
244
|
-
void Promise.resolve(hooks.done(ok, { error, output: out })).catch(() => {
|
|
245
|
-
/* 后处理(重扫/重推)失败不该影响已经结束的作业本身 */
|
|
246
|
-
});
|
|
225
|
+
void Promise.resolve(hooks.done(ok, { error, output: out })).catch(() => { });
|
|
247
226
|
};
|
|
248
227
|
child.stdout?.on("data", onChunk);
|
|
249
228
|
child.stderr?.on("data", onChunk);
|
|
@@ -259,20 +238,12 @@ export class PluginInstaller {
|
|
|
259
238
|
finish(code === 0, code === 0 ? undefined : `exit code ${code}${diagnostic ? `: ${diagnostic}` : ""}`);
|
|
260
239
|
});
|
|
261
240
|
emit({ type: "plugin_job", jobId, action, pluginId, phase: "start" });
|
|
262
|
-
// cancel 需要拿到 cancelled 标志:挂在实例上由 cancel() 设置。
|
|
263
241
|
this.cancelFlags.set(jobId, () => {
|
|
264
242
|
cancelled = true;
|
|
265
243
|
});
|
|
266
244
|
return { ok: true };
|
|
267
245
|
}
|
|
268
|
-
/** cancel 时置位的标志(jobId → setter),作业结束后清理。 */
|
|
269
246
|
cancelFlags = new Map();
|
|
270
|
-
/**
|
|
271
|
-
* 同步跑一个作业并等它结束(目录同步的自动安装用,见 plugin-catalog-sync.ts)。
|
|
272
|
-
*
|
|
273
|
-
* 与 start() 同一条路径、同一把锁:只是把「结束后 resolve」包成 Promise。若已有
|
|
274
|
-
* 别的作业在跑,会直接返回拒绝原因(不排队)——安装器不是队列,调用方自己决定重试。
|
|
275
|
-
*/
|
|
276
247
|
run(spec, opts) {
|
|
277
248
|
return new Promise((resolve) => {
|
|
278
249
|
const started = this.start(spec, {
|
|
@@ -287,7 +258,6 @@ export class PluginInstaller {
|
|
|
287
258
|
resolve({ ok: false, error: started.error, output: "" });
|
|
288
259
|
});
|
|
289
260
|
}
|
|
290
|
-
/** 取消指定作业(杀掉整棵进程树)。返回是否命中。 */
|
|
291
261
|
cancel(jobId) {
|
|
292
262
|
if (!this.currentJobId || this.currentJobId !== jobId || !this.child)
|
|
293
263
|
return false;
|
|
@@ -295,7 +265,6 @@ export class PluginInstaller {
|
|
|
295
265
|
this.killTree(this.child);
|
|
296
266
|
return true;
|
|
297
267
|
}
|
|
298
|
-
/** 杀进程树:Windows 走 taskkill /T,POSIX 走进程组(见 process-utils)。 */
|
|
299
268
|
killTree(child) {
|
|
300
269
|
const pid = child.pid;
|
|
301
270
|
if (!pid)
|
|
@@ -307,12 +276,9 @@ export class PluginInstaller {
|
|
|
307
276
|
try {
|
|
308
277
|
child.kill("SIGKILL");
|
|
309
278
|
}
|
|
310
|
-
catch {
|
|
311
|
-
/* 已经退出了 */
|
|
312
|
-
}
|
|
279
|
+
catch { }
|
|
313
280
|
}
|
|
314
281
|
}
|
|
315
|
-
/** 关机:杀掉在跑的作业(不留孤儿 install 进程)。 */
|
|
316
282
|
dispose() {
|
|
317
283
|
const child = this.child;
|
|
318
284
|
if (child) {
|
|
@@ -323,13 +289,6 @@ export class PluginInstaller {
|
|
|
323
289
|
this.currentJobId = null;
|
|
324
290
|
}
|
|
325
291
|
}
|
|
326
|
-
/**
|
|
327
|
-
* 插件安装的用户确认门(P0):plugin_catalog_sync 的 install:true 与 plugin_job
|
|
328
|
-
* 的 install/update 在真正动安装器之前必须拿到用户确认。
|
|
329
|
-
*
|
|
330
|
-
* 用户若选择「记住并允许」,授权存入 plugin-permissions.json(后续同类操作自动放行,
|
|
331
|
-
* 设置面板「能力授权」页可审计与撤销)。拒绝 / 超时 / 未接弹窗设施(无头 DSH)一律 fail-closed。
|
|
332
|
-
*/
|
|
333
292
|
export async function confirmPluginInstall(items, deps) {
|
|
334
293
|
if (deps.permGrants?.has("plugin-installer", "net", { host: "github.com" })) {
|
|
335
294
|
return true;
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 插件直调模型(host.llm.complete 的底层):一次性的孤立无工具会话。
|
|
3
|
-
*
|
|
4
|
-
* 与审查循环的 reviewer 同一条 SDK 链路(createAgentSessionServices +
|
|
5
|
-
* ModelRuntime.create + createAgentSessionFromServices + prompt +
|
|
6
|
-
* getLastAssistantText + dispose),区别:
|
|
7
|
-
* - `noTools: true` + skills 全剥:纯补全,无副作用、可预测花费;
|
|
8
|
-
* - 调用方(agent-service.completeForPlugins)只给 cwd/agentDir/回落模型,
|
|
9
|
-
* 并发与预算门在本文件内收敛。
|
|
10
|
-
*
|
|
11
|
-
* 约束(fail-closed,一律结构化返回、绝不抛错):
|
|
12
|
-
* - 输入封顶:prompt ≤ 8000 字、system ≤ 4000 字;
|
|
13
|
-
* - 输出截断:maxChars 缺省 8000、上限 32000;
|
|
14
|
-
* - 超时:缺省 90s、范围 5s–5min,超时即 dispose 掉会话;
|
|
15
|
-
* - 并发:全局最多 4 路在飞,超了直接回 {ok:false}(插件侧重试,不排队——
|
|
16
|
-
* 排队会把插件的 await 变成不定等待,调用方超时兜底更难写)。
|
|
17
|
-
*/
|
|
18
1
|
import { join } from "node:path";
|
|
19
2
|
import { createAgentSessionFromServices, createAgentSessionServices, ModelRuntime, SessionManager, } from "@earendil-works/pi-coding-agent";
|
|
20
3
|
import { parseModelSpec } from "./attachments.js";
|
|
@@ -27,7 +10,6 @@ const MIN_TIMEOUT_MS = 5_000;
|
|
|
27
10
|
const MAX_TIMEOUT_MS = 300_000;
|
|
28
11
|
const MAX_INFLIGHT = 4;
|
|
29
12
|
let inflight = 0;
|
|
30
|
-
/** 当前在飞的孤立调用数(单测/诊断用)。 */
|
|
31
13
|
export function llmInflight() {
|
|
32
14
|
return inflight;
|
|
33
15
|
}
|
|
@@ -106,9 +88,7 @@ export async function completeWithIsolatedSession(env, req) {
|
|
|
106
88
|
try {
|
|
107
89
|
void abort?.().catch(() => { });
|
|
108
90
|
}
|
|
109
|
-
catch {
|
|
110
|
-
/* best effort */
|
|
111
|
-
}
|
|
91
|
+
catch { }
|
|
112
92
|
dispose?.();
|
|
113
93
|
resolveStop(result);
|
|
114
94
|
};
|
|
@@ -130,7 +110,6 @@ export async function completeWithIsolatedSession(env, req) {
|
|
|
130
110
|
const services = await createAgentSessionServices({
|
|
131
111
|
cwd: env.cwd,
|
|
132
112
|
agentDir: env.agentDir,
|
|
133
|
-
// 技能全剥:纯补全不需要技能上下文(省 token,结果可预测)。
|
|
134
113
|
resourceLoaderOptions: {
|
|
135
114
|
skillsOverride: (res) => ({ ...res, skills: [] }),
|
|
136
115
|
},
|
|
@@ -138,7 +117,6 @@ export async function completeWithIsolatedSession(env, req) {
|
|
|
138
117
|
});
|
|
139
118
|
if (stopped)
|
|
140
119
|
return stopped;
|
|
141
|
-
// 模型:显式指定 > 主会话回落 > 会话默认(与 reviewer 同优先级)。
|
|
142
120
|
let model;
|
|
143
121
|
let modelName = "default";
|
|
144
122
|
const spec = parseModelSpec(req?.model);
|
|
@@ -157,7 +135,6 @@ export async function completeWithIsolatedSession(env, req) {
|
|
|
157
135
|
services,
|
|
158
136
|
sessionManager: SessionManager.inMemory(env.cwd),
|
|
159
137
|
...(model ? { model } : {}),
|
|
160
|
-
// 全部工具关闭("all"):纯补全,无副作用(SDK 的 noTools 是 "builtin"|"all" 枚举)。
|
|
161
138
|
noTools: "all",
|
|
162
139
|
});
|
|
163
140
|
let disposed = false;
|
|
@@ -169,9 +146,7 @@ export async function completeWithIsolatedSession(env, req) {
|
|
|
169
146
|
try {
|
|
170
147
|
srv.session.dispose();
|
|
171
148
|
}
|
|
172
|
-
catch {
|
|
173
|
-
/* dispose 尽力而为 */
|
|
174
|
-
}
|
|
149
|
+
catch { }
|
|
175
150
|
};
|
|
176
151
|
if (stopped) {
|
|
177
152
|
dispose();
|
|
@@ -189,25 +164,16 @@ export async function completeWithIsolatedSession(env, req) {
|
|
|
189
164
|
const stats = srv.session.getSessionStats();
|
|
190
165
|
usage = { input: stats.tokens.input, output: stats.tokens.output };
|
|
191
166
|
}
|
|
192
|
-
catch {
|
|
193
|
-
/* usage 尽力而为 */
|
|
194
|
-
}
|
|
167
|
+
catch { }
|
|
195
168
|
return { ok: true, text: raw.slice(0, maxChars), model: modelName, ...(usage ? { usage } : {}) };
|
|
196
169
|
}
|
|
197
170
|
finally {
|
|
198
|
-
// 正常结束与异常均回收;中断路径会提前 abort/dispose,迟到的会话也在这里回收。
|
|
199
171
|
try {
|
|
200
172
|
dispose?.();
|
|
201
173
|
}
|
|
202
|
-
catch {
|
|
203
|
-
/* dispose 尽力而为 */
|
|
204
|
-
}
|
|
174
|
+
catch { }
|
|
205
175
|
}
|
|
206
176
|
})();
|
|
207
|
-
// 并发计数跟**真实 run** 走,而不是外层函数的 finally:超时竞速返回后 run 还在飞,
|
|
208
|
-
// 计数必须继续占着 MAX_INFLIGHT 的位 —— 否则每次超时都「腾出」一路并发,
|
|
209
|
-
// 连续超时的插件能把在飞会话越堆越多,护栏失效。catch 挂在分支上兜住 run 的
|
|
210
|
-
// 拒绝(竞速已由 timer 赢时,外层 catch 不会再收到它)。
|
|
211
177
|
void run
|
|
212
178
|
.catch(() => { })
|
|
213
179
|
.finally(() => {
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* manifest 本体校验:schema 失败即拒(DSH 对照 P1-6)。
|
|
3
|
-
*
|
|
4
|
-
* 与 `parseUiItem` / `parseSettingsSchema` 的"宽容丢弃"正交:
|
|
5
|
-
* 那些是字段级容错(坏条目跳过、文本截断),这里是**结构级否决**
|
|
6
|
-
* (坏 manifest 不该变成运行时 `undefined` 再在远处 nổ)。
|
|
7
|
-
*
|
|
8
|
-
* 语义对齐既有契约:
|
|
9
|
-
* - 旧插件(无 `permissions` 且 `apiVersion<2`)走宽容通道:只拦
|
|
10
|
-
* JSON 坏 / 非对象 / apiVersion 非法这类"连启动都不该启动"的;
|
|
11
|
-
* 未知能力族、v2 必填缺失等只在严格模式下才算 error。
|
|
12
|
-
* - `errors` 非空 → 拒绝激活(scan 置 error + activate 首行回卷);
|
|
13
|
-
* `warnings` 永不阻断,只进 `diagnostics` 供设置面板查看。
|
|
14
|
-
*/
|
|
15
1
|
const ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
16
|
-
/** 与 `plugin-sdk/index.d.ts#PluginPermissionFamily` + 运行时 `requestPermission` 同口径。 */
|
|
17
2
|
export const KNOWN_PERMISSION_FAMILIES = new Set([
|
|
18
3
|
"fs",
|
|
19
4
|
"fs:read",
|
|
@@ -33,7 +18,6 @@ export const KNOWN_PERMISSION_FAMILIES = new Set([
|
|
|
33
18
|
function isRecord(v) {
|
|
34
19
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
35
20
|
}
|
|
36
|
-
/** 能力串是否已知:完整串或冒号前族名命中其一即算(如 "ui:read" 归 ui 族)。 */
|
|
37
21
|
export function isKnownPermission(v) {
|
|
38
22
|
return KNOWN_PERMISSION_FAMILIES.has(v) || KNOWN_PERMISSION_FAMILIES.has(v.split(":")[0]);
|
|
39
23
|
}
|
|
@@ -49,10 +33,8 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
49
33
|
return { errors, warnings, apiVersion: 1, permissions: [], strict: false };
|
|
50
34
|
}
|
|
51
35
|
const o = raw;
|
|
52
|
-
// id:缺省回落目录名(向后兼容,只警告);写了就必须合法且与目录一致。
|
|
53
36
|
const idRaw = o.id;
|
|
54
37
|
if (idRaw === undefined) {
|
|
55
|
-
// 旧插件大量不写 id,不警告(避免全仓黄灯),仅回落。
|
|
56
38
|
}
|
|
57
39
|
else if (typeof idRaw !== "string" || !idRaw.trim()) {
|
|
58
40
|
warnings.push({
|
|
@@ -75,7 +57,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
75
57
|
messageEn: `"id" does not match directory name "${dirName}"`,
|
|
76
58
|
});
|
|
77
59
|
}
|
|
78
|
-
// apiVersion:缺省 1(旧插件常态,不警告);写了必须是 1..2 整数。
|
|
79
60
|
let apiVersion = 1;
|
|
80
61
|
const av = o.apiVersion;
|
|
81
62
|
if (av === undefined) {
|
|
@@ -92,7 +73,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
92
73
|
else {
|
|
93
74
|
apiVersion = av;
|
|
94
75
|
}
|
|
95
|
-
// permissions:非数组即错;条目逐个校验。
|
|
96
76
|
let permissions = [];
|
|
97
77
|
const perms = o.permissions;
|
|
98
78
|
if (perms === undefined) {
|
|
@@ -122,7 +102,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
122
102
|
}
|
|
123
103
|
const v = p.trim();
|
|
124
104
|
if (!isKnownPermission(v)) {
|
|
125
|
-
// 未知族:拼写错了就永远授权失败,与静默丢弃同源 —— 直接拒。
|
|
126
105
|
errors.push({
|
|
127
106
|
path,
|
|
128
107
|
message: `未知能力「${v.slice(0, 32)}」(可选 ${[...KNOWN_PERMISSION_FAMILIES].join("/")})`,
|
|
@@ -134,8 +113,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
134
113
|
}
|
|
135
114
|
}
|
|
136
115
|
const strict = permissions.length > 0 || apiVersion >= 2;
|
|
137
|
-
// v2 必须声明 permissions(与 §2.5 严格模式同口径)。只对宿主认识的版本强制:
|
|
138
|
-
// apiVersion > 2 交给版本门出“请升级”(见 activate/scan),这里不抢它的错误信息。
|
|
139
116
|
if (apiVersion === 2 && permissions.length === 0 && perms === undefined) {
|
|
140
117
|
errors.push({
|
|
141
118
|
path: "permissions",
|
|
@@ -143,7 +120,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
143
120
|
messageEn: 'apiVersion 2 plugins must declare "permissions"',
|
|
144
121
|
});
|
|
145
122
|
}
|
|
146
|
-
// engines:只收字符串映射;坏形状即错(否则约束被静默吞掉)。
|
|
147
123
|
if (o.engines !== undefined) {
|
|
148
124
|
if (!isRecord(o.engines)) {
|
|
149
125
|
errors.push({ path: "engines", message: "engines 必须是对象", messageEn: '"engines" must be an object' });
|
|
@@ -160,7 +136,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
160
136
|
}
|
|
161
137
|
}
|
|
162
138
|
}
|
|
163
|
-
// requires(P2-8 硬依赖):坏形状即错(依赖判定错不得,静默吞掉等于回到 peerPlugins 的老路)。
|
|
164
139
|
if (o.requires !== undefined) {
|
|
165
140
|
if (!isRecord(o.requires)) {
|
|
166
141
|
errors.push({ path: "requires", message: "requires 必须是对象", messageEn: '"requires" must be an object' });
|
|
@@ -237,7 +212,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
237
212
|
}
|
|
238
213
|
}
|
|
239
214
|
}
|
|
240
|
-
// view / preload:坏类型只警告(不影响安全语义,回落缺省)。
|
|
241
215
|
for (const key of ["view", "preload"]) {
|
|
242
216
|
if (o[key] !== undefined && typeof o[key] !== "boolean") {
|
|
243
217
|
warnings.push({
|
|
@@ -247,7 +221,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
247
221
|
});
|
|
248
222
|
}
|
|
249
223
|
}
|
|
250
|
-
// 文本字段:坏类型只警告(回落缺省,不阻断)。
|
|
251
224
|
for (const key of ["name", "version", "description", "icon"]) {
|
|
252
225
|
if (o[key] !== undefined && typeof o[key] !== "string") {
|
|
253
226
|
warnings.push({
|
|
@@ -257,7 +230,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
257
230
|
});
|
|
258
231
|
}
|
|
259
232
|
}
|
|
260
|
-
// 数组型声明:坏形状只警告(解析层已按"过滤+截断"处理)。
|
|
261
233
|
for (const key of [
|
|
262
234
|
"netAllowlist",
|
|
263
235
|
"peerPlugins",
|
|
@@ -288,8 +260,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
288
260
|
messageEn: '"fileHandlers" must be an array, ignored',
|
|
289
261
|
});
|
|
290
262
|
}
|
|
291
|
-
// ui:有声明却无 ui 能力(严格模式)= 整份不会生效 —— 算 error 而不是等解析层那条英文诊断。
|
|
292
|
-
// 同样只对宿主认识的版本(apiVersion<=2)强制,未来版本交给版本门。
|
|
293
263
|
if (o.ui !== undefined && strict && apiVersion <= 2 && !permissions.some((x) => x.split(":")[0] === "ui")) {
|
|
294
264
|
errors.push({
|
|
295
265
|
path: "ui",
|
|
@@ -302,7 +272,6 @@ export function validatePluginManifest(raw, dirName) {
|
|
|
302
272
|
}
|
|
303
273
|
return { errors, warnings, apiVersion, permissions, strict };
|
|
304
274
|
}
|
|
305
|
-
/** 诊断行渲染(scan/activate 共用):`path: 中文(en)`。 */
|
|
306
275
|
export function formatManifestIssue(i) {
|
|
307
276
|
return `${i.path}: ${i.message} (${i.messageEn})`;
|
|
308
277
|
}
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 插件能力动态授权表(host.requestPermission 的底层)。
|
|
3
|
-
*
|
|
4
|
-
* 定位:manifest.permissions 管“有没有这个能力族”(静态、装时定),这张表管
|
|
5
|
-
* “运行时的具体范围”(动态、用户随时批):
|
|
6
|
-
* - net:在 manifest netAllowlist 之外,用户额外批准的主机(免改 manifest 重装);
|
|
7
|
-
* - llm:用户批准的模型作用域(空 = 不限模型),花 token 前插件可主动来问一次。
|
|
8
|
-
* 基础族未声明时 requestPermission 直接回 false(不弹框)——与 requestAccess
|
|
9
|
-
* 要求 fs:read 同口径,fail-closed。
|
|
10
|
-
*
|
|
11
|
-
* 两层存储:
|
|
12
|
-
* - 磁盘 `<dataDir>/plugin-permissions.json`(记住的授权,设置面板可审计/撤销);
|
|
13
|
-
* - 内存 session 授权(仅本次运行,进程结束即失)。
|
|
14
|
-
* 读坏/形状不对当空表,且不在读路径回写;只有真正变更的写才落盘(tmp+rename 原子写)。
|
|
15
|
-
*/
|
|
16
1
|
import { readFileSync } from "node:fs";
|
|
17
2
|
import { join } from "node:path";
|
|
18
3
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
19
|
-
/** 主机匹配(与 manifest netAllowlist 同口径):全等或点号后缀。纯函数,单测覆盖。 */
|
|
20
4
|
export function permissionHostMatches(hostname, entry) {
|
|
21
5
|
const h = String(hostname ?? "").toLowerCase();
|
|
22
6
|
const e = String(entry ?? "")
|
|
@@ -73,7 +57,6 @@ export class PluginPermissionStore {
|
|
|
73
57
|
static validId(id) {
|
|
74
58
|
return /^[A-Za-z0-9_-]+$/.test(id);
|
|
75
59
|
}
|
|
76
|
-
/** 是否有有效授权(磁盘 + 内存;host/model 命中才算)。 */
|
|
77
60
|
has(pluginId, family, scope) {
|
|
78
61
|
if (!PluginPermissionStore.validId(pluginId))
|
|
79
62
|
return false;
|
|
@@ -89,13 +72,12 @@ export class PluginPermissionStore {
|
|
|
89
72
|
}
|
|
90
73
|
if (family === "llm" && scope?.model) {
|
|
91
74
|
if (!g.models || g.models.length === 0)
|
|
92
|
-
return true;
|
|
75
|
+
return true;
|
|
93
76
|
return g.models.includes(scope.model);
|
|
94
77
|
}
|
|
95
78
|
return true;
|
|
96
79
|
});
|
|
97
80
|
}
|
|
98
|
-
/** 写入一条授权(remember=true 落盘,false 只记内存)。同插件同族同范围覆盖旧条。 */
|
|
99
81
|
grant(pluginId, family, opts) {
|
|
100
82
|
if (!PluginPermissionStore.validId(pluginId))
|
|
101
83
|
throw new Error(`非法插件 id:${pluginId}`);
|
|
@@ -119,7 +101,6 @@ export class PluginPermissionStore {
|
|
|
119
101
|
this.sessionGrants.push(grant);
|
|
120
102
|
}
|
|
121
103
|
}
|
|
122
|
-
/** 撤销:都不给 = 清空整表;返回删掉的条数(磁盘 + 内存)。 */
|
|
123
104
|
revoke(pluginId, family, scope) {
|
|
124
105
|
let removed = 0;
|
|
125
106
|
const drop = (g) => {
|
|
@@ -144,8 +125,6 @@ export class PluginPermissionStore {
|
|
|
144
125
|
removed += before - this.sessionGrants.length;
|
|
145
126
|
return removed;
|
|
146
127
|
}
|
|
147
|
-
/** 模型是否在批准作用域内:无 llm 授权 → 不限(调用方先判声明);有授权时,
|
|
148
|
-
* 至少一条「不限模型」或命中模型才放行。空 model(走默认模型)不卡。 */
|
|
149
128
|
modelAllowed(pluginId, model) {
|
|
150
129
|
if (!PluginPermissionStore.validId(pluginId))
|
|
151
130
|
return false;
|
|
@@ -156,7 +135,6 @@ export class PluginPermissionStore {
|
|
|
156
135
|
return true;
|
|
157
136
|
return scoped.some((g) => !g.models || g.models.length === 0 || g.models.includes(model));
|
|
158
137
|
}
|
|
159
|
-
/** 全量快照(设置面板审计用;session 授权带 session:true 标记)。 */
|
|
160
138
|
list() {
|
|
161
139
|
return [
|
|
162
140
|
...this.read().grants.map((g) => ({ ...g })),
|
|
@@ -164,7 +142,6 @@ export class PluginPermissionStore {
|
|
|
164
142
|
];
|
|
165
143
|
}
|
|
166
144
|
}
|
|
167
|
-
/** 同范围判定(撤销/覆盖时去重用;范围字段都为空 = 同族整单)。 */
|
|
168
145
|
function sameScope(a, b) {
|
|
169
146
|
const ah = [...(a.hosts ?? [])].sort().join(",");
|
|
170
147
|
const bh = [...(b.hosts ?? [])].sort().join(",");
|