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,21 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-client.ts — stdio JSON-RPC 2.0 客户端 for the pi-web-ui DSH runtime
|
|
3
|
-
* (server/dsh/runtime/launcher.mjs).
|
|
4
|
-
*
|
|
5
|
-
* 协议(每行一个紧凑 JSON 帧,见 dsh-sdk-jsonrpc-server):
|
|
6
|
-
* client→server initialize → { serverInfo }
|
|
7
|
-
* client→server session/prompt → { messageId }(持久化入队回执)
|
|
8
|
-
* client→server shutdown → {}(运行时有序释放后 exit 0)
|
|
9
|
-
* server→client session.event (每个会话,全量持久事件)
|
|
10
|
-
* server→client session.status (running/idle 转换)
|
|
11
|
-
* server→client subagent.started / subagent.finished
|
|
12
|
-
*
|
|
13
|
-
* 官方协议面限制(dsh 0.1.1-rc.2):无 per-session close、无 prompt 取消、
|
|
14
|
-
* 无 per-prompt 结果。因此:
|
|
15
|
-
* - 中止 = kill 进程树(会话 JSONL 在磁盘,进程重建不丢)
|
|
16
|
-
* - 换模型 = 重启运行时(model 在 initialize 固定)
|
|
17
|
-
* - 会话列表/回放 = 直读 JSONL(见 dsh-serialize.ts)
|
|
18
|
-
*/
|
|
19
1
|
import { createRequire } from "node:module";
|
|
20
2
|
import { spawn } from "node:child_process";
|
|
21
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -24,7 +6,6 @@ import { dirname, join, resolve } from "node:path";
|
|
|
24
6
|
import { fileURLToPath } from "node:url";
|
|
25
7
|
import { bilingual } from "../i18n.js";
|
|
26
8
|
import { resolveProviderCredential } from "../model-resolver.js";
|
|
27
|
-
/** 项目依赖解析(tsc 编译后 dist/server/dsh/ 里向上找 node_modules)。 */
|
|
28
9
|
const require = createRequire(import.meta.url);
|
|
29
10
|
export class DshRpcError extends Error {
|
|
30
11
|
code;
|
|
@@ -42,8 +23,6 @@ export class DshTransportError extends Error {
|
|
|
42
23
|
this.name = "DshTransportError";
|
|
43
24
|
}
|
|
44
25
|
}
|
|
45
|
-
/** 读取 DeepSeek API key:<agentDir>/auth.json 的 deepseek.key(ds-web-ui 同款)。
|
|
46
|
-
* agentDir 缺省为 ~/.pi/agent(尊重 PI_CODING_AGENT_DIR 由调用方传入)。 */
|
|
47
26
|
export function loadDeepSeekKey(agentDir) {
|
|
48
27
|
try {
|
|
49
28
|
const auth = JSON.parse(readFileSync(join(agentDir ?? join(homedir(), ".pi", "agent"), "auth.json"), "utf8"));
|
|
@@ -55,10 +34,6 @@ export function loadDeepSeekKey(agentDir) {
|
|
|
55
34
|
return undefined;
|
|
56
35
|
}
|
|
57
36
|
}
|
|
58
|
-
/**
|
|
59
|
-
* 一个 DSH 运行时子进程。start() 惰性 spawn + initialize 握手;
|
|
60
|
-
* prompt() 按需隐式建会话;kill() 强杀进程树(中止);restart() 换模型。
|
|
61
|
-
*/
|
|
62
37
|
export class DshRuntime {
|
|
63
38
|
cwd;
|
|
64
39
|
provider;
|
|
@@ -69,7 +44,6 @@ export class DshRuntime {
|
|
|
69
44
|
dataDir;
|
|
70
45
|
agentDir;
|
|
71
46
|
launcher;
|
|
72
|
-
/** 额外环境变量(可运行时修改:DSH_PERSONA 等由 launcher env 注入)。 */
|
|
73
47
|
env;
|
|
74
48
|
jsonrpcEntry;
|
|
75
49
|
proc = null;
|
|
@@ -84,17 +58,12 @@ export class DshRuntime {
|
|
|
84
58
|
closed = false;
|
|
85
59
|
disposed = false;
|
|
86
60
|
initialized = false;
|
|
87
|
-
/** PI_WEB_DSH_DEBUG=1 时把 RPC 帧/生命周期事件打到 stderr(诊断用,默认关)。 */
|
|
88
61
|
debugEnabled = process.env.PI_WEB_DSH_DEBUG === "1";
|
|
89
62
|
debug(...args) {
|
|
90
63
|
if (this.debugEnabled)
|
|
91
64
|
console.error("[dsh:client]", ...args);
|
|
92
65
|
}
|
|
93
|
-
/** 进程退出回调(kill/abort 后用于重 spawn 前清理)。
|
|
94
|
-
* intentional = 由 kill()/close() 主动触发(反之 = 意外崩溃,供 watchdog 判断)。 */
|
|
95
66
|
onExit = null;
|
|
96
|
-
/** 每次成功 initialize 后触发(含初次启动 / 换模型重启 / watchdog 重启)。
|
|
97
|
-
* 宿主用它重新注册一次性资源(如插件工具桥),因为重 spawn 后 ctx 是全新的。 */
|
|
98
67
|
onStarted = null;
|
|
99
68
|
constructor(opts) {
|
|
100
69
|
this.beforeStart = opts.beforeStart;
|
|
@@ -117,20 +86,17 @@ export class DshRuntime {
|
|
|
117
86
|
return require.resolve("@deepseek-ai/dsh-sdk-jsonrpc-server");
|
|
118
87
|
}
|
|
119
88
|
catch {
|
|
120
|
-
// 回退:相对源码/编译目录向上找项目 node_modules。
|
|
121
89
|
return join(resolve(dirname(fileURLToPath(import.meta.url)), "..", ".."), "node_modules", "@deepseek-ai", "dsh-sdk-jsonrpc-server", "lib", "index.js");
|
|
122
90
|
}
|
|
123
91
|
})();
|
|
124
92
|
this.env = opts.env ?? {};
|
|
125
93
|
}
|
|
126
|
-
/** 运行时子进程是否存活。 */
|
|
127
94
|
get alive() {
|
|
128
95
|
return !!this.proc && this.proc.exitCode === null;
|
|
129
96
|
}
|
|
130
97
|
get running() {
|
|
131
98
|
return this.alive;
|
|
132
99
|
}
|
|
133
|
-
/** 解析当前激活模型对应的运行环境(BaseURL、API Key、CWD 等)与 bare model ID。 */
|
|
134
100
|
resolveRuntimeConfig() {
|
|
135
101
|
let activeProvider = this.modelProvider;
|
|
136
102
|
let bareModelId = this.model;
|
|
@@ -144,8 +110,6 @@ export class DshRuntime {
|
|
|
144
110
|
if (!activeProvider) {
|
|
145
111
|
activeProvider = "deepseek";
|
|
146
112
|
}
|
|
147
|
-
// 根据当前激活模型所属的 Provider(通过 resolveProviderCredential)
|
|
148
|
-
// 将对应的 BaseURL 注入到 DEEPSEEK_BASE_URL,将 API Key 注入到 DEEPSEEK_API_KEY
|
|
149
113
|
const cred = resolveProviderCredential(this.agentDir, activeProvider);
|
|
150
114
|
const deepseekKey = loadDeepSeekKey(this.agentDir);
|
|
151
115
|
const resolvedKey = cred.apiKey || (activeProvider === "deepseek" ? deepseekKey : undefined);
|
|
@@ -171,7 +135,6 @@ export class DshRuntime {
|
|
|
171
135
|
getStderrTail() {
|
|
172
136
|
return this.stderrTail;
|
|
173
137
|
}
|
|
174
|
-
/** 启动子进程 + initialize 握手(幂等;并发调用共享同一个启动任务)。 */
|
|
175
138
|
start() {
|
|
176
139
|
this.beforeStart?.(this.cwd);
|
|
177
140
|
if (this.disposed) {
|
|
@@ -191,8 +154,6 @@ export class DshRuntime {
|
|
|
191
154
|
throw new DshTransportError(bilingual(`launcher missing: ${this.launcher}`, `launcher 不存在: ${this.launcher}`));
|
|
192
155
|
}
|
|
193
156
|
if (!existsSync(this.jsonrpcEntry)) {
|
|
194
|
-
// 不写死版本号:依赖版本会随 package.json 升(见 docs/dsh-engine.md §1
|
|
195
|
-
// 「版本族」),写死的提示迟早骗人。报当前实际解析到的路径即可。
|
|
196
157
|
throw new DshTransportError(bilingual(`dsh-sdk-jsonrpc-server is not installed (missing ${this.jsonrpcEntry}). Run npm i (see docs/dsh-engine.md for the pinned version family) first`, `dsh-sdk-jsonrpc-server 未安装(缺 ${this.jsonrpcEntry})。请先 npm i(版本族见 docs/dsh-engine.md)`));
|
|
197
158
|
}
|
|
198
159
|
const { env, bareModelId } = this.resolveRuntimeConfig();
|
|
@@ -204,8 +165,6 @@ export class DshRuntime {
|
|
|
204
165
|
env,
|
|
205
166
|
stdio: ["pipe", "pipe", "pipe"],
|
|
206
167
|
windowsHide: true,
|
|
207
|
-
// POSIX:独立进程组,硬中断时 SIGKILL(-pid) 一次带走运行时 + 它的
|
|
208
|
-
// bash/pwsh 子进程。
|
|
209
168
|
...(process.platform !== "win32" ? { detached: true } : {}),
|
|
210
169
|
});
|
|
211
170
|
const spawned = this.proc;
|
|
@@ -219,8 +178,6 @@ export class DshRuntime {
|
|
|
219
178
|
this.failPending(new DshTransportError(bilingual(`runtime failed to start: ${err.message}`, `runtime 启动失败: ${err.message}`)));
|
|
220
179
|
});
|
|
221
180
|
spawned.on("exit", (code, signal) => {
|
|
222
|
-
// 只处理当前 proc 的退出:kill/restart 后旧 proc 迟到的 exit 事件
|
|
223
|
-
// 不得 failPending(否则误伤新 initialize)也不得触发 watchdog。
|
|
224
181
|
if (this.proc !== spawned)
|
|
225
182
|
return;
|
|
226
183
|
const intentional = this.closed;
|
|
@@ -242,7 +199,6 @@ export class DshRuntime {
|
|
|
242
199
|
catch (err) {
|
|
243
200
|
console.error(`[dsh] initialize 失败 (model=${bareModelId} cwd=${this.cwd}): ${err.message}` +
|
|
244
201
|
(this.stderrTail ? `\n launcher stderr: ${this.stderrTail.slice(-600)}` : ""));
|
|
245
|
-
// initialize 失败:确认子进程已被清理,避免半死进程占着 stdin。
|
|
246
202
|
void this.kill();
|
|
247
203
|
throw err;
|
|
248
204
|
}
|
|
@@ -267,7 +223,7 @@ export class DshRuntime {
|
|
|
267
223
|
msg = JSON.parse(line);
|
|
268
224
|
}
|
|
269
225
|
catch {
|
|
270
|
-
continue;
|
|
226
|
+
continue;
|
|
271
227
|
}
|
|
272
228
|
if (msg.id !== undefined && msg.id !== null) {
|
|
273
229
|
const p = this.pending.get(msg.id);
|
|
@@ -319,10 +275,6 @@ export class DshRuntime {
|
|
|
319
275
|
this.debug("stdin buffer full, backpressure triggered");
|
|
320
276
|
}
|
|
321
277
|
}
|
|
322
|
-
/**
|
|
323
|
-
* 向一个会话排队 prompt。返回持久化收据 messageId(运行时接受即 resolve)。
|
|
324
|
-
* 会话不存在时按需隐式创建。
|
|
325
|
-
*/
|
|
326
278
|
async prompt(sessionId, contentBlocks) {
|
|
327
279
|
await this.start();
|
|
328
280
|
const res = (await this._request("session/prompt", {
|
|
@@ -334,14 +286,9 @@ export class DshRuntime {
|
|
|
334
286
|
}
|
|
335
287
|
return res.messageId;
|
|
336
288
|
}
|
|
337
|
-
/** 设置通知处理器(session.event / session.status / subagent.*)。 */
|
|
338
289
|
onNotification(handler) {
|
|
339
290
|
this.notificationHandler = handler;
|
|
340
291
|
}
|
|
341
|
-
// -----------------------------------------------------------------------
|
|
342
|
-
// goal RPC(goal-rpc.mjs wrapper 插件直连 DSH 原生 goal 域)
|
|
343
|
-
// -----------------------------------------------------------------------
|
|
344
|
-
/** 创建(或替换已完成的)目标并 arm;round-driver 自动续轮。返回原生 view。 */
|
|
345
292
|
async goalSet(sessionId, objective, maxGoalRounds) {
|
|
346
293
|
await this.start();
|
|
347
294
|
return this._request("goal/set", {
|
|
@@ -350,30 +297,22 @@ export class DshRuntime {
|
|
|
350
297
|
...(maxGoalRounds && maxGoalRounds > 0 ? { maxGoalRounds } : {}),
|
|
351
298
|
});
|
|
352
299
|
}
|
|
353
|
-
/** 当前目标视图({goal|null, activation})。 */
|
|
354
300
|
async goalGet(sessionId) {
|
|
355
301
|
await this.start();
|
|
356
302
|
return this._request("goal/get", { sessionId });
|
|
357
303
|
}
|
|
358
|
-
/** 清除当前目标(保留 durable 墓碑与历史)。 */
|
|
359
304
|
async goalClear(sessionId) {
|
|
360
305
|
await this.start();
|
|
361
306
|
return this._request("goal/clear", { sessionId });
|
|
362
307
|
}
|
|
363
|
-
/** 恢复被 disarm 的目标(abort 重启运行时后轮次驱动停止)。 */
|
|
364
308
|
async goalResume(sessionId) {
|
|
365
309
|
await this.start();
|
|
366
310
|
return this._request("goal/resume", { sessionId });
|
|
367
311
|
}
|
|
368
|
-
/** P2-17 查询运行时模型目录(adapter 真实清单,含 inputModalities)。 */
|
|
369
312
|
async listModels(provider = "deepseek-official") {
|
|
370
313
|
await this.start();
|
|
371
314
|
return this._request("model/list", { provider });
|
|
372
315
|
}
|
|
373
|
-
// -----------------------------------------------------------------------
|
|
374
|
-
// 附件 RPC(视觉桥):base64 图片 ↔ durable ImageAttachmentRef
|
|
375
|
-
// -----------------------------------------------------------------------
|
|
376
|
-
/** 保存 base64 图片 → ImageAttachmentRef(供 prompt 的 image 块引用)。 */
|
|
377
316
|
async attachmentSave(mediaType, data, name) {
|
|
378
317
|
await this.start();
|
|
379
318
|
return this._request("attachment/save", {
|
|
@@ -382,86 +321,62 @@ export class DshRuntime {
|
|
|
382
321
|
...(name ? { name } : {}),
|
|
383
322
|
});
|
|
384
323
|
}
|
|
385
|
-
/** 按 ref 回读图片字节(base64),回放时补全前端显示。 */
|
|
386
324
|
async attachmentRead(ref) {
|
|
387
325
|
await this.start();
|
|
388
326
|
return this._request("attachment/read", { ref });
|
|
389
327
|
}
|
|
390
|
-
/** 回答模型提问(question.pending 通知的 id)。cancelled = 用户取消。 */
|
|
391
328
|
async answerQuestion(id, answers, cancelled) {
|
|
392
329
|
await this.start();
|
|
393
330
|
return this._request("question/answer", { id, answers, ...(cancelled ? { cancelled: true } : {}) });
|
|
394
331
|
}
|
|
395
|
-
// -----------------------------------------------------------------------
|
|
396
|
-
// 工具桥 RPC(#15 插件注入点):sync 注册插件工具 / list 校验 / call-result 回传
|
|
397
|
-
// -----------------------------------------------------------------------
|
|
398
|
-
/** 把一批插件工具(name/description/parameters)注册为 DSH 原生工具。返回注册清单。 */
|
|
399
332
|
async syncTools(tools) {
|
|
400
333
|
await this.start();
|
|
401
334
|
return this._request("tools/sync", { tools });
|
|
402
335
|
}
|
|
403
|
-
/** 列出运行时当前可见的工具 schema(零 key 校验/调试用)。 */
|
|
404
336
|
async listTools() {
|
|
405
337
|
await this.start();
|
|
406
338
|
return this._request("tools/list", {});
|
|
407
339
|
}
|
|
408
|
-
/** 检查并获取运行时当前的组装系统提示词、sections 明细和工具 schemas。 */
|
|
409
340
|
async inspectPrompt(sessionId) {
|
|
410
341
|
await this.start();
|
|
411
342
|
return this._request("prompt/inspect", sessionId ? { sessionId } : {});
|
|
412
343
|
}
|
|
413
|
-
/** 回传一个桥接工具的执行结果(isError=true 时 result 为错误信息)。 */
|
|
414
344
|
async toolsCallResult(id, result, isError) {
|
|
415
345
|
await this.start();
|
|
416
346
|
return this._request("tools/call-result", { id, result, ...(isError ? { isError: true } : {}) });
|
|
417
347
|
}
|
|
418
|
-
/** 调试/probe 用:触发一个桥接工具的完整往返(需运行时 PI_WEB_DSH_DEBUG=1)。 */
|
|
419
348
|
async invokeTool(name, args) {
|
|
420
349
|
await this.start();
|
|
421
350
|
return this._request("tools/invoke", { name, args });
|
|
422
351
|
}
|
|
423
|
-
// -----------------------------------------------------------------------
|
|
424
|
-
// 技能 RPC(#18 技能启停 UI):skills/list + skills/set-disabled
|
|
425
|
-
// -----------------------------------------------------------------------
|
|
426
|
-
/** 列出运行时当前可见技能(SkillRegistry.list)。 */
|
|
427
352
|
async listSkills() {
|
|
428
353
|
await this.start();
|
|
429
354
|
return this._request("skills/list", {});
|
|
430
355
|
}
|
|
431
|
-
/** 设置禁用技能集合(供晚 pre-step 钩子过滤 skill-catalog 消息)。 */
|
|
432
356
|
async setDisabledSkills(skills) {
|
|
433
357
|
await this.start();
|
|
434
358
|
return this._request("skills/set-disabled", { skills });
|
|
435
359
|
}
|
|
436
|
-
// -----------------------------------------------------------------------
|
|
437
|
-
// Agent 预设 RPC(dsh-web 四模式;roster 缺失 = legacy,list 报 unavailable)
|
|
438
|
-
// -----------------------------------------------------------------------
|
|
439
|
-
/** 列出预设名录(字段以运行时树为准;unavailable = 回落 legacy 单组合)。 */
|
|
440
360
|
async listPresets() {
|
|
441
361
|
await this.start();
|
|
442
362
|
return this._request("preset/list", {});
|
|
443
363
|
}
|
|
444
|
-
/** 登记创建期预设(新会话首个 prompt 前调用;创建时消费)。 */
|
|
445
364
|
async assignPreset(sessionId, preset) {
|
|
446
365
|
await this.start();
|
|
447
366
|
return this._request("preset/assign", { sessionId, preset });
|
|
448
367
|
}
|
|
449
|
-
/** 空白会话切换预设(首轮后锁;走 {ok:false,code,message} 信封,不抛 domain 错)。 */
|
|
450
368
|
async selectPreset(sessionId, preset) {
|
|
451
369
|
await this.start();
|
|
452
370
|
return this._request("preset/select", { sessionId, preset });
|
|
453
371
|
}
|
|
454
|
-
/** 读一个会话的权限预设(官方 permissions projection 同源:options + currentValue)。 */
|
|
455
372
|
async getPermission(sessionId) {
|
|
456
373
|
await this.start();
|
|
457
374
|
return this._request("permission/get", { sessionId });
|
|
458
375
|
}
|
|
459
|
-
/** 按会话热切换权限预设(写会话日志,无需重启;走 {ok:false,code,message} 信封)。 */
|
|
460
376
|
async setPermission(sessionId, preset) {
|
|
461
377
|
await this.start();
|
|
462
378
|
return this._request("permission/set", { sessionId, preset });
|
|
463
379
|
}
|
|
464
|
-
/** 优雅关闭:shutdown 握手 → stdin EOF → SIGTERM → SIGKILL 阶梯。 */
|
|
465
380
|
async close() {
|
|
466
381
|
this.onStopping?.();
|
|
467
382
|
if (this.disposed)
|
|
@@ -476,15 +391,11 @@ export class DshRuntime {
|
|
|
476
391
|
try {
|
|
477
392
|
await this._request("shutdown", {}, 2000);
|
|
478
393
|
}
|
|
479
|
-
catch {
|
|
480
|
-
/* fall through to kill ladder */
|
|
481
|
-
}
|
|
394
|
+
catch { }
|
|
482
395
|
try {
|
|
483
396
|
proc.stdin.end();
|
|
484
397
|
}
|
|
485
|
-
catch {
|
|
486
|
-
/* ignore */
|
|
487
|
-
}
|
|
398
|
+
catch { }
|
|
488
399
|
await new Promise((r) => {
|
|
489
400
|
const t = setTimeout(r, 1500);
|
|
490
401
|
proc.once("exit", () => {
|
|
@@ -496,18 +407,14 @@ export class DshRuntime {
|
|
|
496
407
|
try {
|
|
497
408
|
proc.kill("SIGTERM");
|
|
498
409
|
}
|
|
499
|
-
catch {
|
|
500
|
-
/* ignore */
|
|
501
|
-
}
|
|
410
|
+
catch { }
|
|
502
411
|
await this._waitExit(proc, 1500);
|
|
503
412
|
}
|
|
504
413
|
if (proc.exitCode === null) {
|
|
505
414
|
try {
|
|
506
415
|
proc.kill("SIGKILL");
|
|
507
416
|
}
|
|
508
|
-
catch {
|
|
509
|
-
/* ignore */
|
|
510
|
-
}
|
|
417
|
+
catch { }
|
|
511
418
|
}
|
|
512
419
|
this.proc = null;
|
|
513
420
|
}
|
|
@@ -520,10 +427,6 @@ export class DshRuntime {
|
|
|
520
427
|
});
|
|
521
428
|
});
|
|
522
429
|
}
|
|
523
|
-
/**
|
|
524
|
-
* 强杀运行时子进程 + 整棵进程树,无 shutdown 握手(硬中止)。
|
|
525
|
-
* win32: taskkill /pid X /T /F;posix: SIGKILL(-pid)(detached 进程组)。
|
|
526
|
-
*/
|
|
527
430
|
async kill() {
|
|
528
431
|
this.onStopping?.();
|
|
529
432
|
const proc = this.proc;
|
|
@@ -591,9 +494,7 @@ export class DshRuntime {
|
|
|
591
494
|
try {
|
|
592
495
|
proc.kill("SIGKILL");
|
|
593
496
|
}
|
|
594
|
-
catch {
|
|
595
|
-
/* already dead */
|
|
596
|
-
}
|
|
497
|
+
catch { }
|
|
597
498
|
}
|
|
598
499
|
}
|
|
599
500
|
}
|
|
@@ -601,19 +502,15 @@ export class DshRuntime {
|
|
|
601
502
|
try {
|
|
602
503
|
proc.kill("SIGKILL");
|
|
603
504
|
}
|
|
604
|
-
catch {
|
|
605
|
-
/* already dead */
|
|
606
|
-
}
|
|
505
|
+
catch { }
|
|
607
506
|
}
|
|
608
507
|
}
|
|
609
|
-
/** 换模型:关掉当前运行时(若活着),下次 start() 用新 model 重新 spawn。 */
|
|
610
508
|
async restart(newModel, newProvider, cwd) {
|
|
611
509
|
this.beforeStart?.(cwd ? resolve(cwd) : this.cwd);
|
|
612
510
|
const wasAlive = this.alive;
|
|
613
511
|
this.debug("restart", { newModel, newProvider, wasAlive });
|
|
614
512
|
if (wasAlive) {
|
|
615
513
|
await this.kill();
|
|
616
|
-
// 等旧进程真正退出(避免 pid 复用竞态)。
|
|
617
514
|
await new Promise((r) => setTimeout(r, 150));
|
|
618
515
|
}
|
|
619
516
|
if (newModel) {
|
|
@@ -636,7 +533,6 @@ export class DshRuntime {
|
|
|
636
533
|
if (wasAlive || cwd)
|
|
637
534
|
await this.start();
|
|
638
535
|
}
|
|
639
|
-
/** stderr 尾部(诊断用)。 */
|
|
640
536
|
get stderr() {
|
|
641
537
|
return this.stderrTail;
|
|
642
538
|
}
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DSH 插件市场数据服务(对接 awesome-dsh-plugin / dsh-market 数据源)。
|
|
3
|
-
*
|
|
4
|
-
* 数据源:https://awesome-dsh-plugin.com/plugins.json
|
|
5
|
-
* 缓存:<dataDir>/dsh-market-cache.json(默认 12 小时有效)
|
|
6
|
-
* 离线兜底:内置热门精选插件列表,避免断网或首屏拉取受阻时白屏。
|
|
7
|
-
*/
|
|
8
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
2
|
import { join } from "node:path";
|
|
10
3
|
const DSH_MARKET_URL = "https://awesome-dsh-plugin.com/plugins.json";
|
|
11
|
-
const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
|
|
12
|
-
/** 内置精选种子插件列表(离线/首屏保底用)。 */
|
|
4
|
+
const CACHE_TTL_MS = 12 * 60 * 60 * 1000;
|
|
13
5
|
const SEED_CATEGORIES = {
|
|
14
6
|
model: { en: "Models & Providers", zh: "模型与账号接入" },
|
|
15
7
|
ui: { en: "UI Enhancements", zh: "UI 增强" },
|
|
@@ -126,10 +118,8 @@ const SEED_PLUGINS = [
|
|
|
126
118
|
capabilities: ["llm"],
|
|
127
119
|
},
|
|
128
120
|
];
|
|
129
|
-
/** 读取或拉取 DSH 市场插件清单。 */
|
|
130
121
|
export async function loadDshMarketData(dataDir, force = false) {
|
|
131
122
|
const cachePath = join(dataDir, "dsh-market-cache.json");
|
|
132
|
-
// 1. 若无需强制刷新,尝试读取有效本地缓存
|
|
133
123
|
if (!force && existsSync(cachePath)) {
|
|
134
124
|
try {
|
|
135
125
|
const raw = readFileSync(cachePath, "utf8");
|
|
@@ -143,11 +133,8 @@ export async function loadDshMarketData(dataDir, force = false) {
|
|
|
143
133
|
};
|
|
144
134
|
}
|
|
145
135
|
}
|
|
146
|
-
catch {
|
|
147
|
-
/* 缓存损坏,继续走网络拉取 */
|
|
148
|
-
}
|
|
136
|
+
catch { }
|
|
149
137
|
}
|
|
150
|
-
// 2. 尝试从远程 awesome-dsh-plugin 获取
|
|
151
138
|
try {
|
|
152
139
|
const controller = new AbortController();
|
|
153
140
|
const timeoutId = setTimeout(() => controller.abort(), 10000);
|
|
@@ -185,7 +172,6 @@ export async function loadDshMarketData(dataDir, force = false) {
|
|
|
185
172
|
});
|
|
186
173
|
}
|
|
187
174
|
}
|
|
188
|
-
// 默认按热度降序排序:综合 Star 与下载量
|
|
189
175
|
pluginList.sort((a, b) => (b.downloads ?? 0) + (b.stars ?? 0) * 10 - ((a.downloads ?? 0) + (a.stars ?? 0) * 10));
|
|
190
176
|
const result = {
|
|
191
177
|
count: pluginList.length,
|
|
@@ -193,20 +179,16 @@ export async function loadDshMarketData(dataDir, force = false) {
|
|
|
193
179
|
categories,
|
|
194
180
|
plugins: pluginList,
|
|
195
181
|
};
|
|
196
|
-
// 写入缓存
|
|
197
182
|
try {
|
|
198
183
|
writeFileSync(cachePath, JSON.stringify({ ...result, savedAt: Date.now() }), "utf8");
|
|
199
184
|
}
|
|
200
|
-
catch {
|
|
201
|
-
/* ignore write failure */
|
|
202
|
-
}
|
|
185
|
+
catch { }
|
|
203
186
|
return result;
|
|
204
187
|
}
|
|
205
188
|
}
|
|
206
189
|
catch (err) {
|
|
207
190
|
console.warn(`[dsh-market] 拉取远程市场失败: ${err.message},使用缓存或种子数据`);
|
|
208
191
|
}
|
|
209
|
-
// 3. 远程拉取失败时:使用过期缓存
|
|
210
192
|
if (existsSync(cachePath)) {
|
|
211
193
|
try {
|
|
212
194
|
const cached = JSON.parse(readFileSync(cachePath, "utf8"));
|
|
@@ -219,11 +201,8 @@ export async function loadDshMarketData(dataDir, force = false) {
|
|
|
219
201
|
};
|
|
220
202
|
}
|
|
221
203
|
}
|
|
222
|
-
catch {
|
|
223
|
-
/* ignore */
|
|
224
|
-
}
|
|
204
|
+
catch { }
|
|
225
205
|
}
|
|
226
|
-
// 4. 终极回退:使用内置种子数据
|
|
227
206
|
return {
|
|
228
207
|
count: SEED_PLUGINS.length,
|
|
229
208
|
updated: new Date().toISOString().slice(0, 10),
|
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-serialize.ts — DSH 会话事件/消息 → pi-web-ui 协议的 UiMessage[]。
|
|
3
|
-
*
|
|
4
|
-
* 事件面 ground truth(dsh 0.1.1-rc.2,实测 dump,见 docs/dsh-engine.md §2.1):
|
|
5
|
-
* session.event 通知 params = { sessionId, event: { type, seq, time, data } }
|
|
6
|
-
* 持久事件类型(全量 append-only,按 seq 排序):
|
|
7
|
-
* user/message data: { content[], source, role, id }
|
|
8
|
-
* assistant/message data: { turn, step, message: { role, content[], id, time } }
|
|
9
|
-
* tool/result data: { turn, step, message: { role:"user",
|
|
10
|
-
* content:[{type:"tool-result", toolCallId, content[], isError}] },
|
|
11
|
-
* meta, sourceEventSeqs, surfaceOp }
|
|
12
|
-
* assistant/chunk data: { turn, step, chunk: {…} }
|
|
13
|
-
* chunk: block-start {index, blockType: reasoning|text|tool-call}
|
|
14
|
-
* reasoning-delta {index, text} text-delta {index, text}
|
|
15
|
-
* tool-call-delta {index, id, name, argumentsDelta}
|
|
16
|
-
* block-end {index, block} usage {usage} finish {reason}
|
|
17
|
-
* turn/start step/start step/end turn/end session/title …
|
|
18
|
-
* session.status 通知 params = { sessionId, status: running|idle }
|
|
19
|
-
*
|
|
20
|
-
* 序列化策略(对齐 pi 引擎 serialize.ts 的 UiMessage 形状):
|
|
21
|
-
* - 持久消息:user/message、assistant/message、tool/result 三个事件各产一条;
|
|
22
|
-
* id 稳定:u-<msgId> / a-<msgId> / t-<toolCallId>(前端 React key 稳定)。
|
|
23
|
-
* - streamingMessage:由 assistant/chunk 增量累积(reasoning→thinking、
|
|
24
|
-
* text→text、tool-call→toolCall),id 用 stream-<会话seq> 稳定跨快照。
|
|
25
|
-
*/
|
|
26
1
|
import { parseTextQuote } from "../text-quote.js";
|
|
27
2
|
import { ARGS_CAP, TEXT_CAP, TOOL_OUTPUT_CAP, truncate } from "../serialize.js";
|
|
28
3
|
import { stripMarkers } from "../markers/index.js";
|
|
29
|
-
/** DSH user-role content blocks → UiContentBlock[]。 */
|
|
30
4
|
function serializeUserBlocks(blocks) {
|
|
31
5
|
if (!Array.isArray(blocks) || blocks.length === 0) {
|
|
32
6
|
return [{ type: "text", text: "" }];
|
|
@@ -39,8 +13,6 @@ function serializeUserBlocks(blocks) {
|
|
|
39
13
|
return { type: "text", text: String(b?.text ?? "") };
|
|
40
14
|
});
|
|
41
15
|
}
|
|
42
|
-
/** 提取 DSH assistant 事件中的原始未剥离文本(供 MarkerService 解析内联标记)。
|
|
43
|
-
* 同时包含正文 (text) 与思考链 (reasoning),确保模型在思考开头输出的 marker 也被捕获执行。 */
|
|
44
16
|
export function extractDshAssistantRawText(data) {
|
|
45
17
|
const blocks = data.message?.content;
|
|
46
18
|
if (!Array.isArray(blocks))
|
|
@@ -50,7 +22,6 @@ export function extractDshAssistantRawText(data) {
|
|
|
50
22
|
.map((b) => b.text)
|
|
51
23
|
.join("\n");
|
|
52
24
|
}
|
|
53
|
-
/** DSH assistant-role content blocks → UiContentBlock[]。 */
|
|
54
25
|
export function serializeAssistantBlocks(blocks) {
|
|
55
26
|
if (!Array.isArray(blocks))
|
|
56
27
|
return [];
|
|
@@ -84,10 +55,6 @@ export function serializeAssistantBlocks(blocks) {
|
|
|
84
55
|
}
|
|
85
56
|
});
|
|
86
57
|
}
|
|
87
|
-
// ---------------------------------------------------------------------------
|
|
88
|
-
// 事件 → UiMessage
|
|
89
|
-
// ---------------------------------------------------------------------------
|
|
90
|
-
/** tool/result 事件 data → UiMessage(role toolResult)。 */
|
|
91
58
|
export function toolResultEventToUiMessage(data) {
|
|
92
59
|
const blocks = Array.isArray(data.message?.content) ? data.message.content : [];
|
|
93
60
|
const tr = blocks.find((b) => b?.type === "tool-result");
|
|
@@ -107,7 +74,6 @@ export function toolResultEventToUiMessage(data) {
|
|
|
107
74
|
timestamp: data.message?.time,
|
|
108
75
|
};
|
|
109
76
|
}
|
|
110
|
-
/** user/message 事件 data → UiMessage。 */
|
|
111
77
|
export function userMessageEventToUiMessage(data) {
|
|
112
78
|
const quotes = [];
|
|
113
79
|
const content = (data.content ?? []).filter((block) => {
|
|
@@ -125,7 +91,6 @@ export function userMessageEventToUiMessage(data) {
|
|
|
125
91
|
timestamp: data.time,
|
|
126
92
|
};
|
|
127
93
|
}
|
|
128
|
-
/** assistant/message 事件 data → UiMessage。 */
|
|
129
94
|
export function assistantMessageEventToUiMessage(data) {
|
|
130
95
|
const m = data.message;
|
|
131
96
|
if (!m || !m.id)
|
|
@@ -141,18 +106,8 @@ export function assistantMessageEventToUiMessage(data) {
|
|
|
141
106
|
errorMessage: m.errorMessage,
|
|
142
107
|
};
|
|
143
108
|
}
|
|
144
|
-
// ---------------------------------------------------------------------------
|
|
145
|
-
// streaming 累积
|
|
146
|
-
// ---------------------------------------------------------------------------
|
|
147
|
-
/**
|
|
148
|
-
* assistant/chunk 增量累积器:reasoning/text/tool-call 三轨按 chunk.index
|
|
149
|
-
* 归位,产出与持久 assistant 消息同构的 content[]。
|
|
150
|
-
* id 必须跨快照稳定 —— 用会话级单调 seq 作时间戳锚(chunk 事件按 seq 到达,
|
|
151
|
-
* 首个 chunk 的 seq 恒定)。
|
|
152
|
-
*/
|
|
153
109
|
export class DshStreamAccumulator {
|
|
154
110
|
turn;
|
|
155
|
-
/** 稳定 id(stream-<首个 chunk seq>)。 */
|
|
156
111
|
id;
|
|
157
112
|
blocks = new Map();
|
|
158
113
|
started = false;
|
|
@@ -163,7 +118,6 @@ export class DshStreamAccumulator {
|
|
|
163
118
|
get isEmpty() {
|
|
164
119
|
return this.blocks.size === 0;
|
|
165
120
|
}
|
|
166
|
-
/** 处理一个 chunk,返回是否产生了内容变化。 */
|
|
167
121
|
apply(chunk) {
|
|
168
122
|
switch (chunk.type) {
|
|
169
123
|
case "block-start": {
|
|
@@ -212,7 +166,6 @@ export class DshStreamAccumulator {
|
|
|
212
166
|
return false;
|
|
213
167
|
}
|
|
214
168
|
case "block-end": {
|
|
215
|
-
// 完整 block 到达:直接替换(内容与 delta 拼接一致,且带截断语义)。
|
|
216
169
|
const block = chunk.block;
|
|
217
170
|
if (block) {
|
|
218
171
|
const index = chunk.index;
|
|
@@ -238,11 +191,9 @@ export class DshStreamAccumulator {
|
|
|
238
191
|
return false;
|
|
239
192
|
}
|
|
240
193
|
default:
|
|
241
|
-
// usage / finish 等不改变内容。
|
|
242
194
|
return false;
|
|
243
195
|
}
|
|
244
196
|
}
|
|
245
|
-
/** 按 index 升序输出 content[](toolCall 空参数时省略 argumentsText)。 */
|
|
246
197
|
content() {
|
|
247
198
|
const out = [];
|
|
248
199
|
for (const index of [...this.blocks.keys()].sort((a, b) => a - b)) {
|