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,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sdk-origin — 本进程实际加载的是哪一份 pi SDK,以及被它遮蔽的副本(issue #260)。
|
|
3
|
-
*
|
|
4
|
-
* 背景:npm 全局安装会把依赖**嵌在** `<npm root -g>/pi-web-ui/node_modules/`(不 hoist,
|
|
5
|
-
* 实测),而 Node 的解析顺序是「嵌套优先于祖先」。于是用户按更新面板/README 的提示
|
|
6
|
-
* `npm i -g @earendil-works/pi-coding-agent@latest` 升级全局那份时,服务实际加载的
|
|
7
|
-
* 仍是自带副本 —— 表现为「升了 0.86.1,横幅和 /api/health 还显示 0.85.1」。
|
|
8
|
-
*
|
|
9
|
-
* 这里把「所有能被解析到的副本」按 Node 的顺序算出来([0] = 生效的那份),
|
|
10
|
-
* 让启动横幅与健康检查说实话,而不是让用户去猜。
|
|
11
|
-
*
|
|
12
|
-
* 纯函数 + 零副作用,便于单测(见 tests/unit/sdk-origin.test.ts)。
|
|
13
|
-
*/
|
|
14
1
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
15
2
|
import { dirname, join, delimiter, isAbsolute } from "node:path";
|
|
16
3
|
import { fileURLToPath } from "node:url";
|
|
@@ -32,7 +19,6 @@ function addCopy(pjPath, out, requireName = false) {
|
|
|
32
19
|
}
|
|
33
20
|
catch { }
|
|
34
21
|
}
|
|
35
|
-
/** 探测 PATH 上的 pi 可执行文件反推其包根(issue #559, #562)。 */
|
|
36
22
|
function scanPathForPi(out, env = process.env) {
|
|
37
23
|
const rawPath = env.PATH || "";
|
|
38
24
|
if (!rawPath)
|
|
@@ -45,7 +31,6 @@ function scanPathForPi(out, env = process.env) {
|
|
|
45
31
|
const candidate = join(dir, name);
|
|
46
32
|
if (!existsSync(candidate))
|
|
47
33
|
continue;
|
|
48
|
-
// 1. 尝试 realpathSync 解析符号链接(Unix 下 npm/pnpm 全局 bin 标准布局)
|
|
49
34
|
try {
|
|
50
35
|
const real = realpathSync(candidate);
|
|
51
36
|
let cur = dirname(real);
|
|
@@ -59,11 +44,9 @@ function scanPathForPi(out, env = process.env) {
|
|
|
59
44
|
}
|
|
60
45
|
}
|
|
61
46
|
catch { }
|
|
62
|
-
// 2. 检查常见同级/相对 node_modules 目录(Windows npm 全局 bin 同级 node_modules 等)
|
|
63
47
|
addCopy(join(dir, "node_modules", PKG, "package.json"), out);
|
|
64
48
|
addCopy(join(dir, "..", "lib", "node_modules", PKG, "package.json"), out);
|
|
65
49
|
addCopy(join(dir, "..", "node_modules", PKG, "package.json"), out);
|
|
66
|
-
// 3. 脚本包装内容解析(Windows 下 .cmd / .ps1 或 Unix 下 shell 包装脚本)
|
|
67
50
|
try {
|
|
68
51
|
const head = readFileSync(candidate, "utf8").slice(0, 4096);
|
|
69
52
|
const m = head.match(/[^\r\n"']*@earendil-works[/\\]pi-coding-agent[^\r\n"']*/);
|
|
@@ -84,16 +67,13 @@ function scanPathForPi(out, env = process.env) {
|
|
|
84
67
|
}
|
|
85
68
|
}
|
|
86
69
|
}
|
|
87
|
-
/** 探测 npm / pnpm 全局 prefix 目录(issue #559)。 */
|
|
88
70
|
function scanGlobalPrefixes(out, env = process.env) {
|
|
89
71
|
const home = env.HOME || env.USERPROFILE || "";
|
|
90
|
-
// 1. NPM_CONFIG_PREFIX / npm_config_prefix / PREFIX
|
|
91
72
|
const prefix = env.NPM_CONFIG_PREFIX || env.npm_config_prefix || env.PREFIX;
|
|
92
73
|
if (prefix) {
|
|
93
74
|
addCopy(join(prefix, "lib", "node_modules", PKG, "package.json"), out);
|
|
94
75
|
addCopy(join(prefix, "node_modules", PKG, "package.json"), out);
|
|
95
76
|
}
|
|
96
|
-
// 2. 用户级 npm 全局 (~/.npm-global, %APPDATA%\npm)
|
|
97
77
|
if (home) {
|
|
98
78
|
addCopy(join(home, ".npm-global", "lib", "node_modules", PKG, "package.json"), out);
|
|
99
79
|
addCopy(join(home, ".npm-global", "node_modules", PKG, "package.json"), out);
|
|
@@ -101,12 +81,10 @@ function scanGlobalPrefixes(out, env = process.env) {
|
|
|
101
81
|
if (env.APPDATA) {
|
|
102
82
|
addCopy(join(env.APPDATA, "npm", "node_modules", PKG, "package.json"), out);
|
|
103
83
|
}
|
|
104
|
-
// 3. POSIX 系统级 npm 全局
|
|
105
84
|
if (process.platform !== "win32") {
|
|
106
85
|
addCopy(join("/usr", "local", "lib", "node_modules", PKG, "package.json"), out);
|
|
107
86
|
addCopy(join("/usr", "lib", "node_modules", PKG, "package.json"), out);
|
|
108
87
|
}
|
|
109
|
-
// 4. pnpm 全局目录 (PNPM_HOME, ~/.local/share/pnpm/global, %LOCALAPPDATA%\pnpm\global)
|
|
110
88
|
if (env.PNPM_HOME) {
|
|
111
89
|
addCopy(join(env.PNPM_HOME, "node_modules", PKG, "package.json"), out);
|
|
112
90
|
addCopy(join(env.PNPM_HOME, "global", "node_modules", PKG, "package.json"), out);
|
|
@@ -118,9 +96,6 @@ function scanGlobalPrefixes(out, env = process.env) {
|
|
|
118
96
|
addCopy(join(env.LOCALAPPDATA, "pnpm", "global", "node_modules", PKG, "package.json"), out);
|
|
119
97
|
}
|
|
120
98
|
}
|
|
121
|
-
/** 从某个文件出发,逐级向上查找 `<dir>/node_modules/<pkg>/package.json`,
|
|
122
|
-
* 并探测系统/全局已安装的 pi SDK 副本(issue #260, #321, #559, #562)。
|
|
123
|
-
* `fromFile` 收 URL(`import.meta.url`)或普通文件路径(便于单测)。 */
|
|
124
99
|
export function sdkCopies(fromFile = import.meta.url, options = {}) {
|
|
125
100
|
const env = options.env ?? process.env;
|
|
126
101
|
const includeGlobal = options.includeGlobal ?? (options.env ? true : !process.env.VITEST);
|
|
@@ -134,24 +109,19 @@ export function sdkCopies(fromFile = import.meta.url, options = {}) {
|
|
|
134
109
|
break;
|
|
135
110
|
dir = parent;
|
|
136
111
|
}
|
|
137
|
-
// 显式透传的宿主 SDK 路径(如 extensions/webui.ts 宿主传递,issue #482)
|
|
138
112
|
if (env.PI_WEB_SDK_DIR) {
|
|
139
113
|
addCopy(join(env.PI_WEB_SDK_DIR, "package.json"), out);
|
|
140
114
|
}
|
|
141
|
-
// 宿主 Pi Node 路径探测(~/.local/share/pi-node/current/...,issue #482)
|
|
142
115
|
const home = env.HOME || env.USERPROFILE;
|
|
143
116
|
if (home) {
|
|
144
117
|
addCopy(join(home, ".local", "share", "pi-node", "current", "lib", "node_modules", PKG, "package.json"), out);
|
|
145
118
|
}
|
|
146
119
|
if (includeGlobal) {
|
|
147
|
-
// PATH 上的 pi 可执行文件反推(issue #559)
|
|
148
120
|
scanPathForPi(out, env);
|
|
149
|
-
// npm / pnpm 全局 prefix 目录探测(issue #559)
|
|
150
121
|
scanGlobalPrefixes(out, env);
|
|
151
122
|
}
|
|
152
123
|
return out;
|
|
153
124
|
}
|
|
154
|
-
/** 点分版本号比较(够用即可:只比数字段,缺位当 0)。 */
|
|
155
125
|
export function compareVersions(a, b) {
|
|
156
126
|
const pa = a.split(".");
|
|
157
127
|
const pb = b.split(".");
|
|
@@ -163,27 +133,12 @@ export function compareVersions(a, b) {
|
|
|
163
133
|
}
|
|
164
134
|
return 0;
|
|
165
135
|
}
|
|
166
|
-
/**
|
|
167
|
-
* 本进程实际加载的是否为**随包自带**的那份(未被钩子重定向到祖先链副本)。
|
|
168
|
-
* 判据:自带副本是解析顺序上的第一份,且钩子只在祖先副本**严格更新**时才重定向
|
|
169
|
-
* (同版本继续用自带),所以 running == copies[0] ⟺ 自带在用。copies 为空
|
|
170
|
-
* (如部分桌面/容器布局)时按自带算 —— 那本来就是唯一能加载的份。
|
|
171
|
-
* UI 用它决定是否亮「安装全局引擎并切换」入口(issue #321)。
|
|
172
|
-
*/
|
|
173
136
|
export function isBundledInUse(copies, effectiveVersion, bundledCopy) {
|
|
174
137
|
if (bundledCopy !== undefined) {
|
|
175
138
|
return bundledCopy !== null && effectiveVersion === bundledCopy.version;
|
|
176
139
|
}
|
|
177
140
|
return copies.length === 0 || effectiveVersion === copies[0].version;
|
|
178
141
|
}
|
|
179
|
-
/**
|
|
180
|
-
* 启动横幅要打印的一行(不含前缀),以及是否需要提示「本进程在用的不是最新的那份」。
|
|
181
|
-
* `effective` 为空时(没找到副本)返回空串,调用方照旧只打印版本号。
|
|
182
|
-
*
|
|
183
|
-
* #321 起默认会自动跟随更新的那份(resolve-global-sdk),所以这条提示出现即意味着:
|
|
184
|
-
* 进程启动时没跟上(升级发生在启动后 / 旧构建没注入钩子),或用户显式
|
|
185
|
-
* PI_WEB_SDK=bundled 钉死了自带副本 —— 文案把两种出路都写明。
|
|
186
|
-
*/
|
|
187
142
|
export function sdkOriginNote(copies, effectiveVersion) {
|
|
188
143
|
const shadowed = copies.slice(1);
|
|
189
144
|
const newer = shadowed.filter((c) => compareVersions(c.version, effectiveVersion) > 0);
|
package/dist/server/serialize.js
CHANGED
|
@@ -4,27 +4,9 @@ import { stripMarkers } from "./markers/index.js";
|
|
|
4
4
|
export const TEXT_CAP = 200_000;
|
|
5
5
|
export const TOOL_OUTPUT_CAP = 100_000;
|
|
6
6
|
export const ARGS_CAP = 200_000;
|
|
7
|
-
/**
|
|
8
|
-
* toolResult 里单张图片进快照的上限(dataUrl 字符数 ≈ 1.5MB 二进制)。
|
|
9
|
-
* 视口/元素截图随便过;超大整页截图回落成占位文本(模型侧不受影响 —— 图它
|
|
10
|
-
* 已经看过,只是浏览器这边的缩略图不带)。超限截断 base64 会得到一张坏图,
|
|
11
|
-
* 所以是整张丢、不是截一半。
|
|
12
|
-
*/
|
|
13
7
|
const TOOL_RESULT_IMAGE_CAP = 2_000_000;
|
|
14
|
-
/** 单条 toolResult 最多带几张图进快照(防图片刷屏把快照撑爆)。 */
|
|
15
8
|
const TOOL_RESULT_IMAGE_MAX = 8;
|
|
16
|
-
/**
|
|
17
|
-
* toolResult.details 的体积上限。details 是给 UI 用的结构化元数据(如
|
|
18
|
-
* present_files 的卡片数据、ask_user_question 的答案),快照每 60ms 推一次,
|
|
19
|
-
* 不能无节制。超过上限时**整个丢掉**(而不是截断 —— 截断后的 JSON 不可解析,
|
|
20
|
-
* 前端还得写容错);工具作者应自己封顶(见 present-files-tool.ts 的摘录预算)。
|
|
21
|
-
*/
|
|
22
9
|
const TOOL_DETAILS_CAP = 64_000;
|
|
23
|
-
/**
|
|
24
|
-
* 对带有嵌套调用列表(如 codemode 的 details.calls)的 details 做安全预算裁剪。
|
|
25
|
-
* 当 JSON 体积超过 TOOL_DETAILS_CAP(64KB)时,不直接丢弃整包,而是保留首尾
|
|
26
|
-
* 关键调用并精简单项 args/error 长度,保证 UI 仍能渲染出调用树。
|
|
27
|
-
*/
|
|
28
10
|
export function pruneCallsDetails(details, cap) {
|
|
29
11
|
const rawCalls = details.calls;
|
|
30
12
|
if (!Array.isArray(rawCalls))
|
|
@@ -88,13 +70,6 @@ export function truncate(s, cap) {
|
|
|
88
70
|
return { text: str, truncated: false };
|
|
89
71
|
return { text: `${str.slice(0, cap)}\n\n… [truncated]`, truncated: true };
|
|
90
72
|
}
|
|
91
|
-
/**
|
|
92
|
-
* SDK/工具的图片块 → 前端可直接 <img> 的 UiImageBlock。
|
|
93
|
-
* Canonical ImageContent shape is { type, data, mimeType }; tolerate the
|
|
94
|
-
* legacy { source } wrapper too.
|
|
95
|
-
* cap: dataUrl 超过该字符数回 undefined(调用方按占位文本处理);默认不限
|
|
96
|
-
* (用户粘贴图走 image-paste 的缩放管线,尺寸本来就有界)。
|
|
97
|
-
*/
|
|
98
73
|
function imageBlockToUi(b, cap = Number.POSITIVE_INFINITY) {
|
|
99
74
|
const img = b;
|
|
100
75
|
const src = img.source;
|
|
@@ -152,9 +127,6 @@ function serializeAssistantContent(content, streaming = false) {
|
|
|
152
127
|
return { type: "text", text, truncated };
|
|
153
128
|
}
|
|
154
129
|
if (b.type === "thinking") {
|
|
155
|
-
// thinking 也走 TEXT_CAP:思维链没有长度保证(长任务能刷出远超正文的
|
|
156
|
-
// 体量),不截断会把快照推送撑爆。UiThinkingBlock 没有 truncated 字段
|
|
157
|
-
// (protocol 不动),截断语义靠 truncate 自带的 "… [truncated]" 尾标。
|
|
158
130
|
const { text } = truncate(b.thinking, TEXT_CAP);
|
|
159
131
|
return { type: "thinking", thinking: text };
|
|
160
132
|
}
|
|
@@ -174,17 +146,6 @@ function serializeAssistantContent(content, streaming = false) {
|
|
|
174
146
|
return { type: "unknown", ...b };
|
|
175
147
|
});
|
|
176
148
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Hide transient LLM failures while an auto-retry is pending.
|
|
179
|
-
*
|
|
180
|
-
* The SDK finalizes the failed assistant message (message_end, then agent_end
|
|
181
|
-
* with willRetry) BEFORE it slices the message out of state and backs off, so
|
|
182
|
-
* a snapshot taken in between would paint a red error that vanishes one frame
|
|
183
|
-
* later. While `retryActive` the trailing stopReason=error assistant messages
|
|
184
|
-
* are intermediate state: dropped here (retry success → the user never sees
|
|
185
|
-
* them; exhaustion → auto_retry_end clears the flag and the message renders
|
|
186
|
-
* red permanently). Non-trailing content is never touched.
|
|
187
|
-
*/
|
|
188
149
|
export function stripTransientRetryErrors(messages, retryActive) {
|
|
189
150
|
if (!retryActive)
|
|
190
151
|
return messages;
|
|
@@ -198,12 +159,6 @@ export function stripTransientRetryErrors(messages, retryActive) {
|
|
|
198
159
|
}
|
|
199
160
|
return end === messages.length ? messages : messages.slice(0, end);
|
|
200
161
|
}
|
|
201
|
-
/**
|
|
202
|
-
* Single source for rendered message ids. Both serializeMessage (下发) and
|
|
203
|
-
* resolveMessageEntry (解析) must derive ids through this function — recomputing
|
|
204
|
-
* the format anywhere else is how the two sides drifted apart and fork/rollback
|
|
205
|
-
* on assistant bubbles stopped resolving (issue #381).
|
|
206
|
-
*/
|
|
207
162
|
export function uiMessageId(m, seq) {
|
|
208
163
|
switch (m.role) {
|
|
209
164
|
case "user":
|
|
@@ -224,13 +179,6 @@ export function uiMessageId(m, seq) {
|
|
|
224
179
|
return `x-${seq}`;
|
|
225
180
|
}
|
|
226
181
|
}
|
|
227
|
-
/**
|
|
228
|
-
* Find the session entry a rendered message id points at, by re-deriving each
|
|
229
|
-
* entry's rendered id through uiMessageId() — the same function serializeMessage
|
|
230
|
-
* used to hand ids to the browser. `seqOf` supplies the per-message seq; the
|
|
231
|
-
* caller injects its counter there (agent-service passes uiMessageKey().n, which
|
|
232
|
-
* is exactly the counter serialization drew from — issue #381).
|
|
233
|
-
*/
|
|
234
182
|
export function findEntryByUiId(entries, messageId, seqOf) {
|
|
235
183
|
const userSeqByTs = new Map();
|
|
236
184
|
for (const entry of entries) {
|
|
@@ -240,8 +188,6 @@ export function findEntryByUiId(entries, messageId, seqOf) {
|
|
|
240
188
|
const m = entry.message;
|
|
241
189
|
let seq;
|
|
242
190
|
if (m.role === "user") {
|
|
243
|
-
// User ids count messages sharing a timestamp — mirrors the
|
|
244
|
-
// special-case in serializeCachedFor() (see its comment).
|
|
245
191
|
const ts = m.timestamp ?? 0;
|
|
246
192
|
seq = (userSeqByTs.get(ts) ?? 0) + 1;
|
|
247
193
|
userSeqByTs.set(ts, seq);
|
|
@@ -253,9 +199,6 @@ export function findEntryByUiId(entries, messageId, seqOf) {
|
|
|
253
199
|
return entry;
|
|
254
200
|
}
|
|
255
201
|
else if (entry.type === "custom_message" && entry.display !== false) {
|
|
256
|
-
// Custom messages carry content/timestamp on the entry itself (no
|
|
257
|
-
// message object); rebuild the shape uiMessageId()/seqOf() key on —
|
|
258
|
-
// the same conversion createCustomMessage() uses on reload.
|
|
259
202
|
const m = {
|
|
260
203
|
role: "custom",
|
|
261
204
|
content: entry.content,
|
|
@@ -292,13 +235,6 @@ function serializeAssistantMessage(m, id, streaming = false) {
|
|
|
292
235
|
};
|
|
293
236
|
}
|
|
294
237
|
export function serializeMessage(m, seq) {
|
|
295
|
-
// SDK 的 system 消息是 prompt sections 的内部差量
|
|
296
|
-
// (content 空串 + sections 结构化内存)、compaction 的
|
|
297
|
-
// systemMessage 等——从来不面向用户。不过滤的话
|
|
298
|
-
// 会掉进 default 分支被序列化成 content: []
|
|
299
|
-
// 的空气泡、前端顶着 system 标题白显示一条
|
|
300
|
-
// (对话结束后底部冒出的空 SYSTEM 气泡就是它)。
|
|
301
|
-
// LLM 上下文不受影响——这里只决定浏览器看到什么。
|
|
302
238
|
if (m.role === "system") {
|
|
303
239
|
return null;
|
|
304
240
|
}
|
|
@@ -333,9 +269,6 @@ export function serializeMessage(m, seq) {
|
|
|
333
269
|
case "assistant":
|
|
334
270
|
return serializeAssistantMessage(m, id);
|
|
335
271
|
case "toolResult": {
|
|
336
|
-
// 工具结果里的图片(web_shot 截图、read 读到的图……)要下发浏览器:
|
|
337
|
-
// 卡片里直接显示缩略图、点开放大(见 ToolCallBlock)。以前这里统一丢成
|
|
338
|
-
// "[image result]",用户只能看到占位文本。超限/超数的图仍回落占位文本。
|
|
339
272
|
const textParts = [];
|
|
340
273
|
let textLength = 0;
|
|
341
274
|
let hasTextPart = false;
|
|
@@ -356,7 +289,6 @@ export function serializeMessage(m, seq) {
|
|
|
356
289
|
}
|
|
357
290
|
};
|
|
358
291
|
const appendText = (part) => {
|
|
359
|
-
// Empty parts still contribute join separators, even at the cap.
|
|
360
292
|
if (hasTextPart)
|
|
361
293
|
appendChunk("\n");
|
|
362
294
|
hasTextPart = true;
|
|
@@ -389,9 +321,6 @@ export function serializeMessage(m, seq) {
|
|
|
389
321
|
isError: m.isError,
|
|
390
322
|
timestamp: m.timestamp,
|
|
391
323
|
};
|
|
392
|
-
// 结构化元数据(tool result details)也要下发:present_files 的预览卡片
|
|
393
|
-
// 就靠它拿 kind/size/excerpt(前端不能靠再打一次 HTTP 才知类型),
|
|
394
|
-
// ask_user_question 同理。体积封顶,超限整丢(见 TOOL_DETAILS_CAP)。
|
|
395
324
|
if (m.details !== undefined) {
|
|
396
325
|
try {
|
|
397
326
|
const json = JSON.stringify(m.details);
|
|
@@ -404,9 +333,7 @@ export function serializeMessage(m, seq) {
|
|
|
404
333
|
msg.details = pruned;
|
|
405
334
|
}
|
|
406
335
|
}
|
|
407
|
-
catch {
|
|
408
|
-
// 循环引用等序列化不了的值:details 是附加信息,丢掉不影响消息本体。
|
|
409
|
-
}
|
|
336
|
+
catch { }
|
|
410
337
|
}
|
|
411
338
|
return msg;
|
|
412
339
|
}
|
|
@@ -429,8 +356,6 @@ export function serializeMessage(m, seq) {
|
|
|
429
356
|
};
|
|
430
357
|
}
|
|
431
358
|
case "custom": {
|
|
432
|
-
// Third-party extension messages with display:false are UI-hidden
|
|
433
|
-
// (they still go into LLM context — the SDK handles that).
|
|
434
359
|
if (m.display === false) {
|
|
435
360
|
return null;
|
|
436
361
|
}
|
|
@@ -442,18 +367,13 @@ export function serializeMessage(m, seq) {
|
|
|
442
367
|
customType: m.customType,
|
|
443
368
|
timestamp: m.timestamp,
|
|
444
369
|
};
|
|
445
|
-
// custom details 与 toolResult 的 details 同一闸门(TOOL_DETAILS_CAP):
|
|
446
|
-
// details 随每 60ms 一发的快照推送,扩展塞进来的大对象不能无节制;
|
|
447
|
-
// 超限/序列化失败整丢(截断后的 JSON 不可解析,前端还得写容错)。
|
|
448
370
|
const rawDetails = m.details;
|
|
449
371
|
if (rawDetails !== undefined) {
|
|
450
372
|
try {
|
|
451
373
|
if (JSON.stringify(rawDetails).length <= TOOL_DETAILS_CAP)
|
|
452
374
|
msg.details = rawDetails;
|
|
453
375
|
}
|
|
454
|
-
catch {
|
|
455
|
-
// 循环引用等序列化不了的值:details 是附加信息,丢掉不影响消息本体。
|
|
456
|
-
}
|
|
376
|
+
catch { }
|
|
457
377
|
}
|
|
458
378
|
return msg;
|
|
459
379
|
}
|
|
@@ -485,18 +405,8 @@ export function serializeMessage(m, seq) {
|
|
|
485
405
|
};
|
|
486
406
|
}
|
|
487
407
|
}
|
|
488
|
-
/**
|
|
489
|
-
* Serialize the in-progress assistant message (agent.state.streamingMessage).
|
|
490
|
-
*
|
|
491
|
-
* Unlike persisted messages, the id must be STABLE across snapshots: the SDK
|
|
492
|
-
* replaces the partial object on every stream event, so a seq-based id would
|
|
493
|
-
* remount the React component (and collapse open thinking/tool blocks) every
|
|
494
|
-
* 60ms. The timestamp is fixed at message creation, so `stream-<ts>` stays
|
|
495
|
-
* constant for the whole stream.
|
|
496
|
-
*/
|
|
497
408
|
export function serializeStreamingMessage(m) {
|
|
498
409
|
const id = `stream-${m.timestamp ?? 0}`;
|
|
499
|
-
// Streamed assistant blocks must be converted only once per snapshot.
|
|
500
410
|
if (m.role === "assistant")
|
|
501
411
|
return serializeAssistantMessage(m, id, true);
|
|
502
412
|
const msg = serializeMessage(m, 0);
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 本地配置页的持久化后端。
|
|
3
|
-
*
|
|
4
|
-
* `GET /setup` 与 `/api/setup/*` 只允许回环地址访问(见 isLoopbackAddress),
|
|
5
|
-
* 因此忘记 token 也能进——这正是它的存在意义。配置落在
|
|
6
|
-
* `<dataDir>/server-config.json`,优先级:命令行旗标 > 环境变量 > 本文件 > 默认值。
|
|
7
|
-
* 改 host/port/allowlist 需要重启服务生效;token 支持热旋转(index.ts 里 AUTH_TOKEN 是 let)。
|
|
8
|
-
*/
|
|
9
1
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
2
|
import { join } from "node:path";
|
|
11
3
|
const FILE_NAME = "server-config.json";
|
|
@@ -42,7 +34,6 @@ export function saveServerFileConfig(dataDir, cfg) {
|
|
|
42
34
|
mkdirSync(dataDir, { recursive: true });
|
|
43
35
|
writeFileSync(configFilePath(dataDir), `${JSON.stringify(cfg, null, "\t")}\n`, "utf8");
|
|
44
36
|
}
|
|
45
|
-
/** 回环判定:IPv4 127/8、IPv6 ::1(含 IPv4 映射)都算本地。 */
|
|
46
37
|
export function isLoopbackAddress(remoteAddress) {
|
|
47
38
|
if (!remoteAddress)
|
|
48
39
|
return false;
|
|
@@ -51,12 +42,10 @@ export function isLoopbackAddress(remoteAddress) {
|
|
|
51
42
|
return true;
|
|
52
43
|
if (ip === "127.0.0.1" || ip.startsWith("127."))
|
|
53
44
|
return true;
|
|
54
|
-
// ::ffff:127.x.x.x 映射形
|
|
55
45
|
if (ip.startsWith("::ffff:127."))
|
|
56
46
|
return true;
|
|
57
47
|
return false;
|
|
58
48
|
}
|
|
59
|
-
/** token 强度小建议(不硬拦,只提示):空=不清/不设,短于 8 字符警告。 */
|
|
60
49
|
export function tokenWarning(token) {
|
|
61
50
|
if (!token)
|
|
62
51
|
return "";
|
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session branch evaluation, leaf calibration, and transcript topological reordering.
|
|
3
|
-
*
|
|
4
|
-
* Background (issue #567):
|
|
5
|
-
* When multiple devices access the same session, or when extensions append metadata
|
|
6
|
-
* (e.g. type: "custom" such as plannotator entries) pointing to an older ancestor node,
|
|
7
|
-
* the appended entries appear at the physical tail of the JSONL file.
|
|
8
|
-
*
|
|
9
|
-
* In the SDK's SessionManager._buildIndex():
|
|
10
|
-
* for (const entry of this.fileEntries) {
|
|
11
|
-
* if (entry.type === "session") continue;
|
|
12
|
-
* this.byId.set(entry.id, entry);
|
|
13
|
-
* this.leafId = entry.id; // file tail becomes the active leaf!
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* If metadata was appended to an older branch (e.g. node 292 while the main branch
|
|
17
|
-
* continued to 557), reopening the session or restarting the backend will restore
|
|
18
|
-
* the older branch (292), making later task history (293..557) invisible even though
|
|
19
|
-
* it is still safely stored in the JSONL file.
|
|
20
|
-
*
|
|
21
|
-
* This module provides:
|
|
22
|
-
* 1. selectBestSessionLeaf: Evaluates branch candidates by message count, freshness,
|
|
23
|
-
* and depth, detecting metadata-only hijacking or stale branch reversion.
|
|
24
|
-
* 2. calibrateSessionLeaf: In-memory leaf calibration for any SessionManager instance.
|
|
25
|
-
* 3. reorderEntriesForMainBranch: Topological reordering of session entries to ensure
|
|
26
|
-
* the active main branch leaf resides at the physical tail of the transcript file
|
|
27
|
-
* without losing or modifying any custom/metadata entries.
|
|
28
|
-
*/
|
|
29
1
|
function parseEntryTimestamp(ts) {
|
|
30
2
|
if (typeof ts === "string") {
|
|
31
3
|
const parsed = Date.parse(ts);
|
|
@@ -37,9 +9,6 @@ function parseEntryTimestamp(ts) {
|
|
|
37
9
|
}
|
|
38
10
|
return 0;
|
|
39
11
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Identify all branch leaves and compute branch metrics (from root to leaf).
|
|
42
|
-
*/
|
|
43
12
|
export function findBranchCandidates(entries) {
|
|
44
13
|
const validEntries = [];
|
|
45
14
|
const byId = new Map();
|
|
@@ -68,9 +37,6 @@ export function findBranchCandidates(entries) {
|
|
|
68
37
|
if (leaves.length === 0)
|
|
69
38
|
return [];
|
|
70
39
|
const candidates = [];
|
|
71
|
-
// Shared ancestors are visited for every leaf. Cache by object (not ID, which
|
|
72
|
-
// may be duplicated), and only for this call so later entry edits stay visible.
|
|
73
|
-
// Path traversal and pathIds output still cost the sum of all branch depths.
|
|
74
40
|
const timestamps = new WeakMap();
|
|
75
41
|
const timestampOf = (entry) => {
|
|
76
42
|
const cached = timestamps.get(entry);
|
|
@@ -91,7 +57,7 @@ export function findBranchCandidates(entries) {
|
|
|
91
57
|
path.push(node);
|
|
92
58
|
cur = typeof node.parentId === "string" ? node.parentId : null;
|
|
93
59
|
}
|
|
94
|
-
path.reverse();
|
|
60
|
+
path.reverse();
|
|
95
61
|
let messageCount = 0;
|
|
96
62
|
let lastMessageTimestamp = 0;
|
|
97
63
|
for (const node of path) {
|
|
@@ -116,9 +82,6 @@ export function findBranchCandidates(entries) {
|
|
|
116
82
|
}
|
|
117
83
|
return candidates;
|
|
118
84
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Find the lowest common ancestor (LCA) entry ID of two branches.
|
|
121
|
-
*/
|
|
122
85
|
function findLowestCommonAncestor(branchA, branchB) {
|
|
123
86
|
const setA = new Set(branchA.pathIds);
|
|
124
87
|
let lca = null;
|
|
@@ -132,20 +95,10 @@ function findLowestCommonAncestor(branchA, branchB) {
|
|
|
132
95
|
}
|
|
133
96
|
return lca;
|
|
134
97
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Select the best branch leaf from all branch candidates.
|
|
137
|
-
*
|
|
138
|
-
* If multiple leaves exist, compares the currently selected leaf against the candidate
|
|
139
|
-
* pool. If the current leaf is on an abandoned metadata-only branch (e.g. extension
|
|
140
|
-
* wrote to an older node after a completed task) or significantly lags behind the main
|
|
141
|
-
* conversation in message count, selects the main branch leaf.
|
|
142
|
-
*/
|
|
143
98
|
export function selectBestSessionLeaf(entries, currentLeafId) {
|
|
144
99
|
let candidates = findBranchCandidates(entries);
|
|
145
100
|
if (candidates.length === 0)
|
|
146
101
|
return null;
|
|
147
|
-
// An edit/reask explicitly discards the later history in this same file.
|
|
148
|
-
// Honor the latest durable selection, even when abandoned history is longer.
|
|
149
102
|
const reask = [...entries]
|
|
150
103
|
.reverse()
|
|
151
104
|
.find((entry) => entry.type === "custom" && entry.customType === "pi-web-ui:reask");
|
|
@@ -162,11 +115,6 @@ export function selectBestSessionLeaf(entries, currentLeafId) {
|
|
|
162
115
|
changed: currentLeafId !== undefined && currentLeafId !== null && currentLeafId !== single.leafId,
|
|
163
116
|
};
|
|
164
117
|
}
|
|
165
|
-
// Sort candidates by preference:
|
|
166
|
-
// 1. Message count (descending)
|
|
167
|
-
// 2. Last message timestamp (descending)
|
|
168
|
-
// 3. Total entry depth (descending)
|
|
169
|
-
// 4. Leaf timestamp (descending)
|
|
170
118
|
const sorted = [...candidates].sort((a, b) => {
|
|
171
119
|
if (b.messageCount !== a.messageCount)
|
|
172
120
|
return b.messageCount - a.messageCount;
|
|
@@ -201,7 +149,6 @@ export function selectBestSessionLeaf(entries, currentLeafId) {
|
|
|
201
149
|
changed: false,
|
|
202
150
|
};
|
|
203
151
|
}
|
|
204
|
-
// Check if current leaf is a hijacked/stale branch:
|
|
205
152
|
const lca = findLowestCommonAncestor(currentCandidate, bestCandidate);
|
|
206
153
|
const lcaIndexCurrent = lca ? currentCandidate.pathIds.indexOf(lca) : -1;
|
|
207
154
|
const currentEntriesAfterLca = lcaIndexCurrent >= 0 ? currentCandidate.pathIds.slice(lcaIndexCurrent + 1) : [];
|
|
@@ -224,9 +171,6 @@ export function selectBestSessionLeaf(entries, currentLeafId) {
|
|
|
224
171
|
if (node?.type === "message")
|
|
225
172
|
bestMessagesAfterLca += 1;
|
|
226
173
|
}
|
|
227
|
-
// Pattern A: Metadata-only branch hijacking (issue #567)
|
|
228
|
-
// Current branch has 0 messages after LCA (only custom / extension metadata),
|
|
229
|
-
// while best branch has real messages after LCA.
|
|
230
174
|
if (currentMessagesAfterLca === 0 && bestMessagesAfterLca > 0) {
|
|
231
175
|
return {
|
|
232
176
|
bestLeafId: bestCandidate.leafId,
|
|
@@ -235,7 +179,6 @@ export function selectBestSessionLeaf(entries, currentLeafId) {
|
|
|
235
179
|
reason: `Current branch has no messages after divergence (LCA=${lca}), while main branch has ${bestMessagesAfterLca} messages`,
|
|
236
180
|
};
|
|
237
181
|
}
|
|
238
|
-
// Pattern B: Substantial message gap (stale branch restored after task completed elsewhere)
|
|
239
182
|
if (bestCandidate.messageCount > currentCandidate.messageCount) {
|
|
240
183
|
return {
|
|
241
184
|
bestLeafId: bestCandidate.leafId,
|
|
@@ -244,16 +187,12 @@ export function selectBestSessionLeaf(entries, currentLeafId) {
|
|
|
244
187
|
reason: `Main branch has ${bestCandidate.messageCount} messages vs current branch's ${currentCandidate.messageCount}`,
|
|
245
188
|
};
|
|
246
189
|
}
|
|
247
|
-
// Otherwise, current branch has equal or valid intentional message history
|
|
248
190
|
return {
|
|
249
191
|
bestLeafId: currentCandidate.leafId,
|
|
250
192
|
currentLeafId,
|
|
251
193
|
changed: false,
|
|
252
194
|
};
|
|
253
195
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Calibrate the active leaf of a SessionManager in memory.
|
|
256
|
-
*/
|
|
257
196
|
export function calibrateSessionLeaf(sessionManager) {
|
|
258
197
|
try {
|
|
259
198
|
const entries = sessionManager.getEntries();
|
|
@@ -274,13 +213,6 @@ export function calibrateSessionLeaf(sessionManager) {
|
|
|
274
213
|
return { changed: false, calibratedLeafId: sessionManager.getLeafId() ?? undefined, reason: String(err) };
|
|
275
214
|
}
|
|
276
215
|
}
|
|
277
|
-
/**
|
|
278
|
-
* Reorder entries topologically so that the main branch's leaf is at the tail of the transcript.
|
|
279
|
-
*
|
|
280
|
-
* Preserves all entries and valid parent-child relationships (every node still appears after
|
|
281
|
-
* its parent). Side-branch metadata attached to older nodes is placed before the main branch's
|
|
282
|
-
* continuing path so SDK SessionManager's sequential scan lands on the main branch leaf.
|
|
283
|
-
*/
|
|
284
216
|
export function reorderEntriesForMainBranch(entries) {
|
|
285
217
|
if (entries.length <= 1)
|
|
286
218
|
return { entries, changed: false };
|
|
@@ -298,10 +230,6 @@ export function reorderEntriesForMainBranch(entries) {
|
|
|
298
230
|
if (!bestCandidate)
|
|
299
231
|
return { entries, changed: false };
|
|
300
232
|
const bestPathSet = new Set(bestCandidate.pathIds);
|
|
301
|
-
// Separate entries into:
|
|
302
|
-
// 1. Header (type === "session")
|
|
303
|
-
// 2. Entries on the best path
|
|
304
|
-
// 3. Entries on side branches
|
|
305
233
|
const headerEntries = [];
|
|
306
234
|
const sideEntries = [];
|
|
307
235
|
const mainEntries = [];
|
|
@@ -316,21 +244,12 @@ export function reorderEntriesForMainBranch(entries) {
|
|
|
316
244
|
sideEntries.push(e);
|
|
317
245
|
}
|
|
318
246
|
}
|
|
319
|
-
// If no side entries exist or main entries are empty, nothing to reorder
|
|
320
247
|
if (sideEntries.length === 0 || mainEntries.length === 0) {
|
|
321
248
|
return { entries, changed: false };
|
|
322
249
|
}
|
|
323
|
-
// We want to interleave side entries after their respective parent in main entries,
|
|
324
|
-
// BUT ensure that the continuation of the main branch ends with bestCandidate.leafId.
|
|
325
|
-
// A robust topological sort:
|
|
326
|
-
// Each side entry must come after its parent.
|
|
327
|
-
// Since side branches branched off an ancestor in mainEntries, we can place side entries
|
|
328
|
-
// as early as possible (immediately after their parent) so that the deep main branch entries
|
|
329
|
-
// remain at the end of the file.
|
|
330
250
|
const result = [...headerEntries];
|
|
331
251
|
const placedIds = new Set();
|
|
332
252
|
const placedRefs = new Set(headerEntries);
|
|
333
|
-
// Helper to place a side entry and its side descendants
|
|
334
253
|
const sideChildrenOf = new Map();
|
|
335
254
|
for (const s of sideEntries) {
|
|
336
255
|
const pid = typeof s.parentId === "string" ? s.parentId : "";
|
|
@@ -377,12 +296,9 @@ export function reorderEntriesForMainBranch(entries) {
|
|
|
377
296
|
placeSideDescendants(m.id);
|
|
378
297
|
}
|
|
379
298
|
}
|
|
380
|
-
// Any dangling side entries (including valid JSON entries without an `id` field, #601)
|
|
381
|
-
// are placed before the final main entry so that ZERO transcript lines are ever dropped.
|
|
382
299
|
for (const s of sideEntries) {
|
|
383
300
|
if (!placedRefs.has(s)) {
|
|
384
301
|
markPlaced(s);
|
|
385
|
-
// Insert before the last entry (which is the best leaf)
|
|
386
302
|
if (result.length > headerEntries.length + 1) {
|
|
387
303
|
result.splice(result.length - 1, 0, s);
|
|
388
304
|
}
|
|
@@ -391,7 +307,6 @@ export function reorderEntriesForMainBranch(entries) {
|
|
|
391
307
|
}
|
|
392
308
|
}
|
|
393
309
|
}
|
|
394
|
-
// Verify that no entries were lost (#601) and the new last non-header entry with id is bestLeafId
|
|
395
310
|
if (result.length !== entries.length) {
|
|
396
311
|
return { entries, changed: false };
|
|
397
312
|
}
|
|
@@ -399,7 +314,6 @@ export function reorderEntriesForMainBranch(entries) {
|
|
|
399
314
|
const newTail = newNonHeader[newNonHeader.length - 1];
|
|
400
315
|
const successfullyReordered = newTail?.id === bestLeafId;
|
|
401
316
|
if (!successfullyReordered) {
|
|
402
|
-
// Fallback: don't alter if topological sort couldn't guarantee tail
|
|
403
317
|
return { entries, changed: false };
|
|
404
318
|
}
|
|
405
319
|
return {
|