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
package/dist/server/lsp-tool.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* lsp-tool.ts — 导出给 AI Agent 的原生 LSP 语言服务器工具(Native Opt-in LSP Tool)。
|
|
3
|
-
*
|
|
4
|
-
* 核心设计:
|
|
5
|
-
* - 零重型外部依赖:基于 Node.js 标准流与原生 JSON-RPC 2.0 实现轻量级 LSP 客户端。
|
|
6
|
-
* - 多会话共享池(Project-level Pool):同项目多会话与并发子代理复用同一个后台语言服务器实例,
|
|
7
|
-
* 避免多子代理重复拉起语言服务器导致内存爆炸(参考 omp 的 lspmux 理念)。
|
|
8
|
-
* - 支持 4 大核心语义动作:
|
|
9
|
-
* 1. definition:跳转到符号定义位置(支持展示定义代码片段);
|
|
10
|
-
* 2. references:列出工作区内所有引用/调用处;
|
|
11
|
-
* 3. hover:获取类型签名与文档说明(Docstring/Markdown);
|
|
12
|
-
* 4. diagnostics:获取文件或项目的实时编译与类型检查错误。
|
|
13
|
-
* - 闲置自动回收:15 分钟无请求自动休眠退出,释放系统内存。
|
|
14
|
-
*/
|
|
15
1
|
import { spawn } from "node:child_process";
|
|
16
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
17
3
|
import { homedir } from "node:os";
|
|
@@ -132,12 +118,10 @@ function getLanguageForPath(filePath) {
|
|
|
132
118
|
return { langKey: "cpp", config: LANGUAGE_SERVER_CATALOG.cpp };
|
|
133
119
|
return null;
|
|
134
120
|
}
|
|
135
|
-
/** 二进制探测结果的内存缓存(cwd + cmd 为 key;用户态安装成功后按包失效) */
|
|
136
121
|
const resolveBinaryCache = new Map();
|
|
137
122
|
export function clearResolveBinaryCache() {
|
|
138
123
|
resolveBinaryCache.clear();
|
|
139
124
|
}
|
|
140
|
-
/** 探测二进制是否可在当前系统执行(优先项目本地、Pi 生态共享目录、用户态托管目录、系统 PATH) */
|
|
141
125
|
export function resolveBinary(cmd, cwd) {
|
|
142
126
|
const cacheKey = `${cwd}::${cmd}`;
|
|
143
127
|
const cached = resolveBinaryCache.get(cacheKey);
|
|
@@ -161,14 +145,12 @@ function resolveBinaryUncached(cmd, cwd) {
|
|
|
161
145
|
}
|
|
162
146
|
return null;
|
|
163
147
|
}
|
|
164
|
-
// 1. 本地 workspace node_modules/.bin 优先
|
|
165
148
|
const localBinDir = resolve(cwd, "node_modules", ".bin");
|
|
166
149
|
for (const ext of exts) {
|
|
167
150
|
const target = join(localBinDir, cmd + ext);
|
|
168
151
|
if (existsSync(target))
|
|
169
152
|
return target;
|
|
170
153
|
}
|
|
171
|
-
// 2. Pi 生态工具与用户态目录(pi-lens / pi-web 用户态托管,零权限直接复用)
|
|
172
154
|
const home = homedir();
|
|
173
155
|
const sharedDirs = [
|
|
174
156
|
join(home, ".pi-lens", "tools", "node_modules", ".bin"),
|
|
@@ -182,7 +164,6 @@ function resolveBinaryUncached(cmd, cwd) {
|
|
|
182
164
|
return target;
|
|
183
165
|
}
|
|
184
166
|
}
|
|
185
|
-
// 3. 遍历系统 PATH 目录(纯文件系统检查,零子进程开销、杜绝 Windows cmd.exe 引号卡死)
|
|
186
167
|
const pathDirs = (process.env.PATH || "").split(delimiter);
|
|
187
168
|
for (const dir of pathDirs) {
|
|
188
169
|
if (!dir)
|
|
@@ -196,13 +177,8 @@ function resolveBinaryUncached(cmd, cwd) {
|
|
|
196
177
|
return null;
|
|
197
178
|
}
|
|
198
179
|
const installTasks = new Map();
|
|
199
|
-
/** 安装失败的负缓存(pkg -> 失败时间戳):失败后 5 分钟内不再重复执行 120s 的 npm install */
|
|
200
180
|
const installFailedAt = new Map();
|
|
201
181
|
const INSTALL_FAIL_NEGATIVE_CACHE_MS = 5 * 60 * 1000;
|
|
202
|
-
/**
|
|
203
|
-
* 在用户专属目录(~/.pi-web/lsp-servers)执行无侵入、免 sudo/root 的语言服务包按需安装。
|
|
204
|
-
* 注意:必须经用户显式授权(lsp 工具的 allowInstall 参数)后才能调用,不得静默触发。
|
|
205
|
-
*/
|
|
206
182
|
export async function autoInstallLanguageServer(pkg) {
|
|
207
183
|
const existing = installTasks.get(pkg);
|
|
208
184
|
if (existing)
|
|
@@ -237,7 +213,6 @@ export async function autoInstallLanguageServer(pkg) {
|
|
|
237
213
|
});
|
|
238
214
|
const timer = setTimeout(() => {
|
|
239
215
|
if (isWin) {
|
|
240
|
-
// win32 下 taskkill /T 连整棵子进程树强杀,避免 npm/node 残留。
|
|
241
216
|
if (typeof proc.pid === "number") {
|
|
242
217
|
const killer = spawn("taskkill", ["/PID", String(proc.pid), "/T", "/F"], {
|
|
243
218
|
stdio: "ignore",
|
|
@@ -247,9 +222,6 @@ export async function autoInstallLanguageServer(pkg) {
|
|
|
247
222
|
}
|
|
248
223
|
}
|
|
249
224
|
else {
|
|
250
|
-
// POSIX:npm 由非 shell 直接 spawn,kill 其主进程即可让安装流程终止
|
|
251
|
-
//(取 SIGKILL 而非 detached 进程组方案:不改变子进程组语义,安装
|
|
252
|
-
// 超时本身是罕见路径,残余 node 子进程随 npm 主进程退出被回收)。
|
|
253
225
|
try {
|
|
254
226
|
proc.kill("SIGKILL");
|
|
255
227
|
}
|
|
@@ -273,7 +245,6 @@ export async function autoInstallLanguageServer(pkg) {
|
|
|
273
245
|
});
|
|
274
246
|
});
|
|
275
247
|
console.warn(`[LSP] Language server [${pkg}] installed, resolving binaries…`);
|
|
276
|
-
// 新二进制落盘,探测缓存失效
|
|
277
248
|
clearResolveBinaryCache();
|
|
278
249
|
installFailedAt.delete(pkg);
|
|
279
250
|
return true;
|
|
@@ -290,9 +261,6 @@ export async function autoInstallLanguageServer(pkg) {
|
|
|
290
261
|
installTasks.set(pkg, task);
|
|
291
262
|
return task;
|
|
292
263
|
}
|
|
293
|
-
// ----------------------------------------------------------------------------
|
|
294
|
-
// JSON-RPC 2.0 传输层与单项目 LSP 客户端
|
|
295
|
-
// ----------------------------------------------------------------------------
|
|
296
264
|
export class LspClient {
|
|
297
265
|
projectCwd;
|
|
298
266
|
langKey;
|
|
@@ -303,16 +271,14 @@ export class LspClient {
|
|
|
303
271
|
proc = null;
|
|
304
272
|
nextId = 1;
|
|
305
273
|
pendingRequests = new Map();
|
|
306
|
-
diagnosticsCache = new Map();
|
|
307
|
-
openFiles = new Set();
|
|
308
|
-
docVersions = new Map();
|
|
274
|
+
diagnosticsCache = new Map();
|
|
275
|
+
openFiles = new Set();
|
|
276
|
+
docVersions = new Map();
|
|
309
277
|
buffer = Buffer.alloc(0);
|
|
310
278
|
idleTimer = null;
|
|
311
279
|
initialized = false;
|
|
312
280
|
isShuttingDown = false;
|
|
313
|
-
constructor(projectCwd, langKey, binPath, binArgs, languageId,
|
|
314
|
-
/** 客户端不可用(空闲回收 / 进程退出 / spawn 失败)时从池移除的回调 */
|
|
315
|
-
onEvict) {
|
|
281
|
+
constructor(projectCwd, langKey, binPath, binArgs, languageId, onEvict) {
|
|
316
282
|
this.projectCwd = projectCwd;
|
|
317
283
|
this.langKey = langKey;
|
|
318
284
|
this.binPath = binPath;
|
|
@@ -332,18 +298,12 @@ export class LspClient {
|
|
|
332
298
|
windowsHide: true,
|
|
333
299
|
});
|
|
334
300
|
this.proc.stdout?.on("data", (chunk) => this.handleData(chunk));
|
|
335
|
-
this.proc.stderr?.on("data", (_d) => {
|
|
336
|
-
// 可选记录 debug 日志,不干扰输出
|
|
337
|
-
});
|
|
338
|
-
// spawn 失败(ENOENT/EACCES 等)只触发 'error',进程从未启动时不会触发
|
|
339
|
-
// 'exit'——不监听会让 initialize 等请求挂到超时,客户端还留在池里被误判存活。
|
|
301
|
+
this.proc.stderr?.on("data", (_d) => { });
|
|
340
302
|
this.proc.on("error", (err) => {
|
|
341
303
|
this.proc = null;
|
|
342
304
|
this.rejectAllPending(new Error(`Language server failed to start: ${err.message}`));
|
|
343
305
|
this.onEvict();
|
|
344
306
|
});
|
|
345
|
-
// stdin 写错误(对端退出后的 EPIPE 等)在 stream 上异步 emit,不监听会以
|
|
346
|
-
// uncaughtException 崩掉整个服务进程。这里统一兜底:标记死亡 + 清理挂起请求。
|
|
347
307
|
this.proc.stdin?.on("error", (err) => {
|
|
348
308
|
this.proc = null;
|
|
349
309
|
this.rejectAllPending(new Error(`Language server stdin error: ${err.message}`));
|
|
@@ -352,11 +312,9 @@ export class LspClient {
|
|
|
352
312
|
this.proc.on("exit", (code) => {
|
|
353
313
|
this.proc = null;
|
|
354
314
|
this.rejectAllPending(new Error(`Language server exited with code ${code}`));
|
|
355
|
-
// 进程退出即从池移除,防止后续请求命中死客户端
|
|
356
315
|
this.onEvict();
|
|
357
316
|
});
|
|
358
317
|
try {
|
|
359
|
-
// 发送 initialize 握手
|
|
360
318
|
await this.request("initialize", {
|
|
361
319
|
processId: process.pid,
|
|
362
320
|
rootUri: pathToFileURL(this.projectCwd).toString(),
|
|
@@ -404,7 +362,6 @@ export class LspClient {
|
|
|
404
362
|
return;
|
|
405
363
|
if (this.idleTimer)
|
|
406
364
|
clearTimeout(this.idleTimer);
|
|
407
|
-
// 15 分钟无调用自动回收
|
|
408
365
|
this.idleTimer = setTimeout(() => {
|
|
409
366
|
this.shutdown().catch(() => { });
|
|
410
367
|
this.onEvict();
|
|
@@ -439,8 +396,6 @@ export class LspClient {
|
|
|
439
396
|
handleMessage(msg) {
|
|
440
397
|
if (msg.id !== undefined) {
|
|
441
398
|
if (msg.method) {
|
|
442
|
-
// 服务端向客户端发起的请求(如 window/workDoneProgress/create, client/registerCapability)
|
|
443
|
-
// 标准 JSON-RPC 必须回复 result: null,防止上游语言服务器挂起等待
|
|
444
399
|
const reply = JSON.stringify({ jsonrpc: "2.0", id: msg.id, result: null });
|
|
445
400
|
const wire = `Content-Length: ${Buffer.byteLength(reply, "utf8")}\r\n\r\n${reply}`;
|
|
446
401
|
try {
|
|
@@ -486,8 +441,6 @@ export class LspClient {
|
|
|
486
441
|
this.proc.stdin.write(wire);
|
|
487
442
|
}
|
|
488
443
|
catch (err) {
|
|
489
|
-
// 同步写失败(stream 已销毁等):撤销挂起请求;异步 EPIPE 由 start() 里的
|
|
490
|
-
// stdin 'error' 监听兜底,这里只需保证 promise 被 reject 而非向上抛。
|
|
491
444
|
clearTimeout(timer);
|
|
492
445
|
this.pendingRequests.delete(id);
|
|
493
446
|
rej(new Error(`Language server stdin write failed: ${err.message}`));
|
|
@@ -503,9 +456,7 @@ export class LspClient {
|
|
|
503
456
|
try {
|
|
504
457
|
this.proc.stdin.write(wire);
|
|
505
458
|
}
|
|
506
|
-
catch {
|
|
507
|
-
// 通知写失败只影响状态同步,不值得打断调用链;异步 EPIPE 由 stdin 'error' 监听兜底
|
|
508
|
-
}
|
|
459
|
+
catch { }
|
|
509
460
|
}
|
|
510
461
|
async syncDocument(absPath) {
|
|
511
462
|
const uri = pathToFileURL(absPath).toString();
|
|
@@ -582,11 +533,8 @@ export class LspClient {
|
|
|
582
533
|
this.rejectAllPending(new Error("LSP client shut down"));
|
|
583
534
|
}
|
|
584
535
|
}
|
|
585
|
-
// ----------------------------------------------------------------------------
|
|
586
|
-
// 全局项目级语言服务器管理池(Project-Level LSP Pool)
|
|
587
|
-
// ----------------------------------------------------------------------------
|
|
588
536
|
class LspServerPool {
|
|
589
|
-
pool = new Map();
|
|
537
|
+
pool = new Map();
|
|
590
538
|
inFlight = new Map();
|
|
591
539
|
shuttingDown = false;
|
|
592
540
|
hasAliveClient(projectCwd, filePath) {
|
|
@@ -608,8 +556,6 @@ class LspServerPool {
|
|
|
608
556
|
const poolKey = `${projectCwd}::${langInfo.langKey}`;
|
|
609
557
|
const client = this.pool.get(poolKey);
|
|
610
558
|
if (client) {
|
|
611
|
-
// 池命中必须复检存活:进程退出事件与请求之间有竞态窗口(exit 回调排队、
|
|
612
|
-
// spawn error 未触发 exit),死客户端留在池里会让所有请求挂到超时。
|
|
613
559
|
if (client.isAlive()) {
|
|
614
560
|
client.touch();
|
|
615
561
|
return { client };
|
|
@@ -621,7 +567,6 @@ class LspServerPool {
|
|
|
621
567
|
return pending;
|
|
622
568
|
}
|
|
623
569
|
const task = (async () => {
|
|
624
|
-
// 寻找可用命令
|
|
625
570
|
let resolvedBin = null;
|
|
626
571
|
let resolvedArgs = [];
|
|
627
572
|
let hint = "";
|
|
@@ -637,7 +582,6 @@ class LspServerPool {
|
|
|
637
582
|
if (!autoPkg && cmd.npmPackage)
|
|
638
583
|
autoPkg = cmd.npmPackage;
|
|
639
584
|
}
|
|
640
|
-
// 用户态按需安装必须经用户显式授权(allowInstall),避免在工具调用链里无提示联网 npm install
|
|
641
585
|
if (!resolvedBin && autoPkg && opts?.allowInstall === true) {
|
|
642
586
|
const ok = await autoInstallLanguageServer(autoPkg);
|
|
643
587
|
if (ok) {
|
|
@@ -664,8 +608,6 @@ class LspServerPool {
|
|
|
664
608
|
this.pool.delete(poolKey);
|
|
665
609
|
}
|
|
666
610
|
});
|
|
667
|
-
// 启动失败时客户端尚在 start() 内部、池里没有它,onEvict 是空操作;
|
|
668
|
-
// 成功后再退出/回收才会真正从池移除。
|
|
669
611
|
try {
|
|
670
612
|
await newClient.start();
|
|
671
613
|
if (this.shuttingDown) {
|
|
@@ -696,9 +638,6 @@ class LspServerPool {
|
|
|
696
638
|
}
|
|
697
639
|
}
|
|
698
640
|
export const globalLspPool = new LspServerPool();
|
|
699
|
-
/**
|
|
700
|
-
* 辅助函数:在文件改动后,若已有存活的语言服务器,获取即时编译报错(Writethrough Diagnostics)
|
|
701
|
-
*/
|
|
702
641
|
export async function getLiveLspDiagnostics(absPath, cwd) {
|
|
703
642
|
if (!globalLspPool.hasAliveClient(cwd, absPath)) {
|
|
704
643
|
return null;
|
|
@@ -708,7 +647,6 @@ export async function getLiveLspDiagnostics(absPath, cwd) {
|
|
|
708
647
|
return null;
|
|
709
648
|
const { client } = res;
|
|
710
649
|
const uri = await client.syncDocument(absPath);
|
|
711
|
-
// 稍等 80ms 让后台增量分析返回
|
|
712
650
|
await new Promise((r) => setTimeout(r, 80));
|
|
713
651
|
const diags = client.getDiagnostics(uri);
|
|
714
652
|
const errors = diags.filter((d) => d.severity === 1 || !d.severity);
|
|
@@ -723,18 +661,8 @@ export async function getLiveLspDiagnostics(absPath, cwd) {
|
|
|
723
661
|
});
|
|
724
662
|
return `⚠️ Post-edit Diagnostics (${errors.length} error${errors.length > 1 ? "s" : ""}):\n${lines.join("\n")}`;
|
|
725
663
|
}
|
|
726
|
-
/** 文本大纲与 details.symbols 共用的展平符号数上限(顶层与子级一并计数)。 */
|
|
727
664
|
const DOCUMENT_SYMBOL_OUTLINE_CAP = 300;
|
|
728
|
-
/**
|
|
729
|
-
* details.symbols 的序列化体积预算(字符数)。details 随会话持久且整体 ≤64KB,
|
|
730
|
-
* 超限会被整条丢弃(见 serialize.ts 的 TOOL_DETAILS_CAP);符号名/签名极长的
|
|
731
|
-
* 极端文件(生成的 .d.ts、protobuf 产物)下 300 个符号也可能撑爆,故按实际
|
|
732
|
-
* 序列化体积逐步收紧上限(预算留足余量给 count/truncated 等包装字段)。
|
|
733
|
-
*/
|
|
734
665
|
const DOCUMENT_SYMBOL_DETAILS_CHAR_BUDGET = 60_000;
|
|
735
|
-
/**
|
|
736
|
-
* 递归格式化 DocumentSymbol 列表为缩进的符号大纲树(做条数上限保护)
|
|
737
|
-
*/
|
|
738
666
|
function formatDocumentSymbols(symbols, indent = "", lines = []) {
|
|
739
667
|
for (const sym of symbols) {
|
|
740
668
|
if (lines.length >= DOCUMENT_SYMBOL_OUTLINE_CAP) {
|
|
@@ -754,12 +682,6 @@ function formatDocumentSymbols(symbols, indent = "", lines = []) {
|
|
|
754
682
|
}
|
|
755
683
|
return lines;
|
|
756
684
|
}
|
|
757
|
-
/**
|
|
758
|
-
* 与 formatDocumentSymbols 同口径的结构化裁剪:按展平后的符号数(先序遍历,
|
|
759
|
-
* 顶层与子级一并计数)截断到 cap 个。只在展平序列的边界上裁剪,保留符号的
|
|
760
|
-
* 父子结构保持一致 —— 父被裁掉则整棵子树不再出现;有符号被裁时 truncated 置真。
|
|
761
|
-
* 未触发截断时原样返回(不拷贝,避免大对象无谓重建)。
|
|
762
|
-
*/
|
|
763
685
|
function capDocumentSymbolTree(symbols, cap) {
|
|
764
686
|
let count = 0;
|
|
765
687
|
let truncated = false;
|
|
@@ -787,12 +709,6 @@ function capDocumentSymbolTree(symbols, cap) {
|
|
|
787
709
|
const { kept } = walk(symbols);
|
|
788
710
|
return { capped: truncated ? kept : symbols, truncated };
|
|
789
711
|
}
|
|
790
|
-
/**
|
|
791
|
-
* details.symbols 的最终裁剪:先与文本大纲同口径按展平计数截到 300;再用实际
|
|
792
|
-
* 序列化体积校验 —— details 随会话持久且整体 ≤64KB,超限整条丢弃(见
|
|
793
|
-
* serialize.ts 的 TOOL_DETAILS_CAP),符号名/签名极长的极端文件下按半数逐步
|
|
794
|
-
* 收紧展平上限,保证结构化大纲真的能进快照而不是被整条丢掉。
|
|
795
|
-
*/
|
|
796
712
|
function capDocumentSymbolsForDetails(symbols) {
|
|
797
713
|
let cap = DOCUMENT_SYMBOL_OUTLINE_CAP;
|
|
798
714
|
let res = capDocumentSymbolTree(symbols, cap);
|
|
@@ -804,9 +720,6 @@ function capDocumentSymbolsForDetails(symbols) {
|
|
|
804
720
|
}
|
|
805
721
|
return res;
|
|
806
722
|
}
|
|
807
|
-
/**
|
|
808
|
-
* 递归单趟查找符号(两遍扫描:先严格精确匹配,未命中再执行大小写忽略回退,避免遮蔽后续精确符号;支持 containerName 点分路径)
|
|
809
|
-
*/
|
|
810
723
|
function findSymbolPass(symbols, target, mode, parentName = "") {
|
|
811
724
|
const targetLower = target.toLowerCase();
|
|
812
725
|
for (const sym of symbols) {
|
|
@@ -836,9 +749,6 @@ function findSymbolPass(symbols, target, mode, parentName = "") {
|
|
|
836
749
|
function findSymbol(symbols, target) {
|
|
837
750
|
return findSymbolPass(symbols, target, "exact") ?? findSymbolPass(symbols, target, "ci");
|
|
838
751
|
}
|
|
839
|
-
/**
|
|
840
|
-
* 收集文件内可用的顶层符号全名清单(最多收集 50 条,供找不到符号时提供备选提示)
|
|
841
|
-
*/
|
|
842
752
|
function collectSymbolNames(symbols, prefix = "", names = []) {
|
|
843
753
|
for (const sym of symbols) {
|
|
844
754
|
if (names.length >= 50)
|
|
@@ -856,9 +766,6 @@ function collectSymbolNames(symbols, prefix = "", names = []) {
|
|
|
856
766
|
}
|
|
857
767
|
return names;
|
|
858
768
|
}
|
|
859
|
-
/**
|
|
860
|
-
* 当未传 path 且执行工作区级操作(如 workspaceSymbol)时,寻找工作区默认主文件以定位语言服务
|
|
861
|
-
*/
|
|
862
769
|
function findDefaultSourceFileForLsp(cwd) {
|
|
863
770
|
const candidates = [
|
|
864
771
|
"src/index.ts",
|
|
@@ -1020,7 +927,6 @@ export function makeLspTool(options) {
|
|
|
1020
927
|
}
|
|
1021
928
|
const client = clientRes.client;
|
|
1022
929
|
const uri = await client.syncDocument(absPath);
|
|
1023
|
-
// 0-indexed positions for LSP protocol
|
|
1024
930
|
const position = {
|
|
1025
931
|
line: line - 1,
|
|
1026
932
|
character: character - 1,
|
|
@@ -1035,8 +941,6 @@ export function makeLspTool(options) {
|
|
|
1035
941
|
details: { ok: true, locations: [] },
|
|
1036
942
|
};
|
|
1037
943
|
}
|
|
1038
|
-
// 与 references(:25) 同口径:每个位置都要整读一次目标文件拼 snippet,
|
|
1039
|
-
// 无上限的 definition 列表会放大成几十次同步 IO 拖死请求。
|
|
1040
944
|
const MAX_DEFS = 25;
|
|
1041
945
|
const formatted = locs.slice(0, MAX_DEFS).map((loc) => {
|
|
1042
946
|
const targetUri = loc.targetUri || loc.uri || "";
|
|
@@ -1130,7 +1034,6 @@ export function makeLspTool(options) {
|
|
|
1130
1034
|
};
|
|
1131
1035
|
}
|
|
1132
1036
|
if (action === "diagnostics") {
|
|
1133
|
-
// 给予极短缓冲以确保 publishDiagnostics 缓存已收到
|
|
1134
1037
|
await new Promise((r) => setTimeout(r, 120));
|
|
1135
1038
|
const diags = client.getDiagnostics(uri);
|
|
1136
1039
|
if (diags.length === 0) {
|
|
@@ -1166,9 +1069,6 @@ export function makeLspTool(options) {
|
|
|
1166
1069
|
};
|
|
1167
1070
|
}
|
|
1168
1071
|
const lines = formatDocumentSymbols(symbols);
|
|
1169
|
-
// details 随会话持久且整体 ≤64KB(超限整条丢弃):symbols 与文本大纲同口径
|
|
1170
|
-
// 截断 —— 按展平后的符号数(先序遍历,顶层与子级一并计数)截到 300,保留
|
|
1171
|
-
// 符号维持父子结构;再按序列化体积兜底收紧,极端文件下保证 details 进得了快照。
|
|
1172
1072
|
const { capped: detailsSymbols, truncated: symbolsTruncated } = capDocumentSymbolsForDetails(symbols);
|
|
1173
1073
|
return {
|
|
1174
1074
|
content: [
|
|
@@ -1226,9 +1126,8 @@ export function makeLspTool(options) {
|
|
|
1226
1126
|
details: { ok: false, error: "Missing range" },
|
|
1227
1127
|
};
|
|
1228
1128
|
}
|
|
1229
|
-
let startLine = range.start.line;
|
|
1230
|
-
let endLine = range.end.line;
|
|
1231
|
-
// 针对行尾排他边界(end.character === 0 且跨行时)避免多读末尾空行
|
|
1129
|
+
let startLine = range.start.line;
|
|
1130
|
+
let endLine = range.end.line;
|
|
1232
1131
|
if (range.end.character === 0 && endLine > startLine) {
|
|
1233
1132
|
endLine -= 1;
|
|
1234
1133
|
}
|
|
@@ -1313,16 +1212,12 @@ export function makeLspTool(options) {
|
|
|
1313
1212
|
};
|
|
1314
1213
|
}
|
|
1315
1214
|
if (action === "cascade") {
|
|
1316
|
-
// 影响级联(Impact Cascade):找出引用本文件(或本文件某个符号)的工作区文件,
|
|
1317
|
-
// 聚合它们的实时诊断——让"改了签名/导出,下游编译炸了"在编辑当轮就暴露,
|
|
1318
|
-
// 而不是等到构建或提交时才发现。
|
|
1319
1215
|
const MAX_SEEDS = 20;
|
|
1320
1216
|
const MAX_DEPENDENTS = 25;
|
|
1321
1217
|
const DIAGS_BUDGET_MS = 1500;
|
|
1322
1218
|
const normalizePath = (p) => (process.platform === "win32" ? p.toLowerCase() : p);
|
|
1323
|
-
// 1. 收集种子位置:给了 line/character 就只查那个符号;否则查全部顶层符号。
|
|
1324
1219
|
const seeds = [];
|
|
1325
|
-
let seedTotal = 0;
|
|
1220
|
+
let seedTotal = 0;
|
|
1326
1221
|
if (typeof params.line === "number") {
|
|
1327
1222
|
seeds.push({ line: line - 1, character: character - 1 });
|
|
1328
1223
|
}
|
|
@@ -1343,7 +1238,6 @@ export function makeLspTool(options) {
|
|
|
1343
1238
|
details: { ok: true, impacted: [], clean: [], notReported: [], referencedFiles: [] },
|
|
1344
1239
|
};
|
|
1345
1240
|
}
|
|
1346
|
-
// 2. 对每个种子查 references(不含声明处),汇总工作区内的引用方文件。
|
|
1347
1241
|
const selfNorm = normalizePath(absPath);
|
|
1348
1242
|
const depPaths = new Set();
|
|
1349
1243
|
const seedResults = await Promise.allSettled(seeds.map((pos) => client.request("textDocument/references", { textDocument: { uri }, position: pos, context: { includeDeclaration: false } }, timeoutMs)));
|
|
@@ -1362,19 +1256,16 @@ export function makeLspTool(options) {
|
|
|
1362
1256
|
continue;
|
|
1363
1257
|
}
|
|
1364
1258
|
if (normalizePath(refPath) === selfNorm)
|
|
1365
|
-
continue;
|
|
1259
|
+
continue;
|
|
1366
1260
|
const relRef = relative(cwd, refPath);
|
|
1367
1261
|
if (relRef === ".." || relRef.startsWith(".." + sep) || relRef.startsWith("../") || isAbsolute(relRef)) {
|
|
1368
|
-
continue;
|
|
1262
|
+
continue;
|
|
1369
1263
|
}
|
|
1370
1264
|
if (relRef.split(sep).includes("node_modules"))
|
|
1371
1265
|
continue;
|
|
1372
1266
|
depPaths.add(refPath);
|
|
1373
1267
|
}
|
|
1374
1268
|
}
|
|
1375
|
-
// 只分析排序后的前 MAX_DEPENDENTS 个引用方,但计数必须如实上报:文本与
|
|
1376
|
-
// details 都带截断前的真实总数,超出部分用尾注标明(对照 references 动作
|
|
1377
|
-
// 的 "... and N more references" 口径),避免模型误以为清单是完整的。
|
|
1378
1269
|
const totalReferencing = depPaths.size;
|
|
1379
1270
|
const dependents = [...depPaths].sort().slice(0, MAX_DEPENDENTS);
|
|
1380
1271
|
if (dependents.length === 0) {
|
|
@@ -1388,7 +1279,6 @@ export function makeLspTool(options) {
|
|
|
1388
1279
|
details: { ok: true, impacted: [], clean: [], notReported: [], referencedFiles: [] },
|
|
1389
1280
|
};
|
|
1390
1281
|
}
|
|
1391
|
-
// 3. 逐个 didOpen/didChange 触发服务器分析,轮询等待 publishDiagnostics 回流。
|
|
1392
1282
|
const depUris = [];
|
|
1393
1283
|
for (const dep of dependents) {
|
|
1394
1284
|
try {
|
|
@@ -1408,7 +1298,6 @@ export function makeLspTool(options) {
|
|
|
1408
1298
|
pending.delete(u);
|
|
1409
1299
|
}
|
|
1410
1300
|
}
|
|
1411
|
-
// 4. 聚合输出:有错误的排前面,其次警告,clean 与未上报的折叠列出。
|
|
1412
1301
|
const impacted = [];
|
|
1413
1302
|
const clean = [];
|
|
1414
1303
|
const notReported = [];
|
|
@@ -1428,7 +1317,7 @@ export function makeLspTool(options) {
|
|
|
1428
1317
|
impacted.push({ path: depRel, errors, warnings, diagnostics: diags.slice(0, 10) });
|
|
1429
1318
|
}
|
|
1430
1319
|
else if (diags.length === 0 && !knownFinal.has(depUri)) {
|
|
1431
|
-
notReported.push(depRel);
|
|
1320
|
+
notReported.push(depRel);
|
|
1432
1321
|
}
|
|
1433
1322
|
else {
|
|
1434
1323
|
clean.push(depRel);
|
|
@@ -1456,8 +1345,6 @@ export function makeLspTool(options) {
|
|
|
1456
1345
|
if (notReported.length > 0) {
|
|
1457
1346
|
out.push(`Diagnostics not reported in time (${notReported.length}, server may still be analyzing): ${notReported.slice(0, 5).join(", ")}${notReported.length > 5 ? ", ..." : ""}`);
|
|
1458
1347
|
}
|
|
1459
|
-
// 截断尾注:与 references 动作的 "... and N more references" 同口径,
|
|
1460
|
-
// 让模型知道被丢弃的引用方/种子符号既不在 clean 也不在 notReported 里。
|
|
1461
1348
|
if (totalReferencing > dependents.length) {
|
|
1462
1349
|
out.push(`... and ${totalReferencing - dependents.length} more not analyzed`);
|
|
1463
1350
|
}
|
package/dist/server/managed.js
CHANGED
|
@@ -1,65 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* managed — instances whose updates come from outside.
|
|
3
|
-
*
|
|
4
|
-
* pi-web-ui can update itself: the top bar shows an updates badge and a panel
|
|
5
|
-
* whose buttons run `npm i -g pi-web-ui@latest` in a visible terminal and
|
|
6
|
-
* restart the server. The plugin market installs plugins from the network the
|
|
7
|
-
* same way. On a developer's laptop both are conveniences.
|
|
8
|
-
*
|
|
9
|
-
* Behind a deploy pipeline they are not. A Docker image, a distribution
|
|
10
|
-
* package, or a release script that also checks the reverse proxy, the service
|
|
11
|
-
* unit and the environment variables a new version needs — for all of those,
|
|
12
|
-
* an in-app self-update leaves the machine in a state nothing describes, until
|
|
13
|
-
* the next real deploy silently undoes it. `PI_WEB_MANAGED=1` says "this
|
|
14
|
-
* instance is managed from outside": the update paths refuse, and the client
|
|
15
|
-
* stops offering them.
|
|
16
|
-
*
|
|
17
|
-
* Two rules kept this small:
|
|
18
|
-
*
|
|
19
|
-
* - **The server refuses, the client only hides.** Hiding a button while the
|
|
20
|
-
* socket still accepts the message is hiding, not disabling: anything that
|
|
21
|
-
* can open the WebSocket can still send it.
|
|
22
|
-
* - **Nothing else changes.** Chatting, plugins already installed, git,
|
|
23
|
-
* terminal, settings are untouched — this switch is about who installs
|
|
24
|
-
* software on the machine, not about what the interface can do.
|
|
25
|
-
*/
|
|
26
|
-
/** The client messages that install or replace software on the machine. */
|
|
27
1
|
export const MANAGED_MESSAGES = [
|
|
28
|
-
/** Update check behind the top-bar badge. */
|
|
29
2
|
"check_update",
|
|
30
|
-
/** "Re-check all" in the UPDATE panel (app + components). */
|
|
31
3
|
"check_updates_all",
|
|
32
|
-
/** Installs the pi agent itself. */
|
|
33
4
|
"install_pi_agent",
|
|
34
|
-
/** Updates an agent engine package via background process. */
|
|
35
5
|
"update_engine",
|
|
36
|
-
/** Uninstalls an agent engine package via background process. */
|
|
37
6
|
"uninstall_engine",
|
|
38
|
-
/** Plugin market: fetches and installs a plugin from the network. */
|
|
39
7
|
"plugin_catalog_add",
|
|
40
|
-
/** Plugin install/update/uninstall run as a background job (issue #152). */
|
|
41
8
|
"plugin_job",
|
|
42
|
-
/** Catalog sync can install/update entries too (issue #148). */
|
|
43
9
|
"plugin_catalog_sync",
|
|
44
10
|
];
|
|
45
|
-
/**
|
|
46
|
-
* Whether this instance is managed from outside.
|
|
47
|
-
*
|
|
48
|
-
* Accepts the spellings people actually put in a systemd unit or a
|
|
49
|
-
* docker-compose file; anything else — including an empty variable — means no,
|
|
50
|
-
* so the default stays exactly what it is today.
|
|
51
|
-
*/
|
|
52
11
|
export function isManaged(env = process.env) {
|
|
53
12
|
const v = (env.PI_WEB_MANAGED ?? "").trim().toLowerCase();
|
|
54
13
|
return v === "1" || v === "true" || v === "yes" || v === "on";
|
|
55
14
|
}
|
|
56
|
-
/**
|
|
57
|
-
* The reason to send back, or null when the message may proceed.
|
|
58
|
-
*
|
|
59
|
-
* Returning the text rather than a boolean keeps the caller a single line and
|
|
60
|
-
* puts the explanation next to the rule it comes from — the user gets a
|
|
61
|
-
* sentence, not a silently dropped message.
|
|
62
|
-
*/
|
|
63
15
|
export function managedRefusal(type, managed) {
|
|
64
16
|
if (!managed)
|
|
65
17
|
return null;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* marker-service.ts — 标记服务(内置版 pi-marker-tools)。
|
|
3
|
-
*/
|
|
4
1
|
import { pick } from "./i18n.js";
|
|
5
2
|
import { ensureMarkersRegistered, parseMarkers, getMarker, allMarkers, collectGuidance, listMarkerNames, } from "./markers/index.js";
|
|
6
3
|
import { loadStateFromBranch, appendSnapshot } from "./markers/store.js";
|
|
@@ -35,7 +32,6 @@ export class MarkerService {
|
|
|
35
32
|
return false;
|
|
36
33
|
return !this.settings.disabledMarkers.includes(name);
|
|
37
34
|
}
|
|
38
|
-
/** 当前服务端语言(英文默认,未接线前保持原有英文行为)。 */
|
|
39
35
|
lang() {
|
|
40
36
|
return this.host.lang?.() ?? "en";
|
|
41
37
|
}
|
|
@@ -43,7 +39,6 @@ export class MarkerService {
|
|
|
43
39
|
if (!this.settings.markersEnabled)
|
|
44
40
|
return "";
|
|
45
41
|
const disabled = new Set(this.settings.disabledMarkers);
|
|
46
|
-
// AI guidance is strictly in concise English matching tool prompt guidelines.
|
|
47
42
|
const lines = collectGuidance(disabled, "en");
|
|
48
43
|
if (lines.length === 0)
|
|
49
44
|
return "";
|
|
@@ -84,7 +79,6 @@ export class MarkerService {
|
|
|
84
79
|
}
|
|
85
80
|
this.host.stateStore.saveMarkerSettings(this.host.clientId, this.settings);
|
|
86
81
|
}
|
|
87
|
-
// -- state helpers --
|
|
88
82
|
memFor(convId, ns) {
|
|
89
83
|
return this.memStore.get(convId)?.get(ns);
|
|
90
84
|
}
|
|
@@ -107,9 +101,7 @@ export class MarkerService {
|
|
|
107
101
|
return structuredClone(fromBranch);
|
|
108
102
|
}
|
|
109
103
|
}
|
|
110
|
-
catch {
|
|
111
|
-
// best-effort:分支不可读 → 回落 mem/init(快照损坏不阻断对话)。
|
|
112
|
-
}
|
|
104
|
+
catch { }
|
|
113
105
|
}
|
|
114
106
|
const mem = this.memFor(convId, namespace);
|
|
115
107
|
if (mem !== undefined)
|
|
@@ -121,14 +113,6 @@ export class MarkerService {
|
|
|
121
113
|
const mgr = this.host.getSessionManager(convId);
|
|
122
114
|
appendSnapshot(mgr, namespace, state);
|
|
123
115
|
}
|
|
124
|
-
// -- parse & execute --
|
|
125
|
-
/**
|
|
126
|
-
* 解析执行一条 assistant 终稿文本中的内联标记。
|
|
127
|
-
*
|
|
128
|
-
* 多个气泡(同一轮内前一段文本 + 后一段文本)的 message_end 事件会先后到达,
|
|
129
|
-
* 而 apply 是异步的——若并发执行会同时读到旧快照、分配重叠 id、后存覆盖前存。
|
|
130
|
-
* 因此按会话串行化:每个 conv 的处理链式排队,保证状态严格按文本顺序累积。
|
|
131
|
-
*/
|
|
132
116
|
chains = new Map();
|
|
133
117
|
handleAssistantText(conversationId, text) {
|
|
134
118
|
const prev = this.chains.get(conversationId) ?? Promise.resolve();
|
|
@@ -199,7 +183,6 @@ export class MarkerService {
|
|
|
199
183
|
};
|
|
200
184
|
}
|
|
201
185
|
if (result.applied) {
|
|
202
|
-
// action 落库;notify/conv 即时生效(通知已发 / 对话已重命名),无需快照。
|
|
203
186
|
const canonicalTool = token.tool === "suggest" ? ACTION_NAMESPACE : token.tool;
|
|
204
187
|
if (canonicalTool !== "notify" && canonicalTool !== "conv") {
|
|
205
188
|
dirty.add(canonicalTool);
|
|
@@ -232,10 +215,8 @@ export class MarkerService {
|
|
|
232
215
|
if (prev && prev.join("\n") === next.join("\n"))
|
|
233
216
|
return;
|
|
234
217
|
this.overlayCache.set(key, next);
|
|
235
|
-
// 通过宿主的 widget 合并(跟随当前活动会话,不覆盖扩展 widget)。
|
|
236
218
|
this.host.refreshMarkers();
|
|
237
219
|
}
|
|
238
|
-
/** 计算某个会话的标记 overlay 行(供 UI widget 动态渲染当前活动会话)。 */
|
|
239
220
|
overlayLines(conversationId) {
|
|
240
221
|
const lines = [];
|
|
241
222
|
for (const m of allMarkers()) {
|
|
@@ -289,8 +270,6 @@ export class MarkerService {
|
|
|
289
270
|
this.host.onActionsChange?.(conversationId);
|
|
290
271
|
}
|
|
291
272
|
}
|
|
292
|
-
/** 供设置面板展示的 marker 目录(含启用状态)。 */
|
|
293
|
-
/** UI 过滤:rename/title 是 conv 的别名,suggest 是 action 的别名,不单独展示。 */
|
|
294
273
|
listForUi() {
|
|
295
274
|
const seen = new Set();
|
|
296
275
|
const out = [];
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* builtins/action.ts — 建议操作标记(期待用户操作)。
|
|
3
|
-
*
|
|
4
|
-
* 语法:
|
|
5
|
-
* [[action:suggest:<按钮文字>]] 添加快捷操作建议(点击发送该文字)
|
|
6
|
-
* [[action:suggest:<按钮显示>,prompt=<实际发送文本>]] 区分展示标签与实际发送内容
|
|
7
|
-
* [[action:suggest:label=<按钮显示>,prompt=<发送文本>]] kwargs 风格
|
|
8
|
-
* [[action:clear:all]] 清空当前建议操作
|
|
9
|
-
*
|
|
10
|
-
* 兼容操作别名:
|
|
11
|
-
* tool 兼容 action 与 suggest
|
|
12
|
-
* op 兼容 suggest / add / next / reply / choice / option / clear
|
|
13
|
-
*/
|
|
14
1
|
import { getServerBlock, pick } from "../../i18n.js";
|
|
15
2
|
export const ACTION_NAMESPACE = "action";
|
|
16
3
|
export function initActionState() {
|
|
@@ -22,7 +9,6 @@ const ACTION_GUIDANCE_ZH = [
|
|
|
22
9
|
const ACTION_GUIDANCE_EN = [
|
|
23
10
|
"- Suggest action buttons: [[action:suggest:<label>]] (one marker per button; for multiple choices output separate markers: [[action:suggest:A]] [[action:suggest:B]], NEVER join options in one marker). Separate prompt: [[action:suggest:<label>,prompt=<text>]]. Clear: [[action:clear:all]].",
|
|
24
11
|
];
|
|
25
|
-
/** 语言感知的 action guidance:en 用英译、zh 用中文,默认英文。 */
|
|
26
12
|
export function getActionGuidance(lang = "en") {
|
|
27
13
|
return getServerBlock(lang, "markers.action.guidance", ACTION_GUIDANCE_ZH, ACTION_GUIDANCE_EN);
|
|
28
14
|
}
|
|
@@ -46,8 +32,6 @@ export const actionMarker = {
|
|
|
46
32
|
error: pick(lang, `action 未知操作: ${token.op}(支持 suggest/next/add/clear)`, `action unknown operation: ${token.op} (supports suggest/next/add/clear)`, "markers.action.unknown.operation", { "token.op": token.op }),
|
|
47
33
|
};
|
|
48
34
|
}
|
|
49
|
-
// 提取 label 与 prompt:
|
|
50
|
-
// args: token.args.join(",").trim() (兼容含逗号的正文,如 "是,继续执行")
|
|
51
35
|
const argsText = token.args.join(",").trim();
|
|
52
36
|
const kwLabel = token.kwargs["label"]?.trim() || "";
|
|
53
37
|
const kwPrompt = token.kwargs["prompt"]?.trim() || "";
|
|
@@ -64,12 +48,10 @@ export const actionMarker = {
|
|
|
64
48
|
prompt = label;
|
|
65
49
|
if (!label)
|
|
66
50
|
label = prompt;
|
|
67
|
-
// 字符长度封顶保护
|
|
68
51
|
if (label.length > 80)
|
|
69
52
|
label = label.slice(0, 80);
|
|
70
53
|
if (prompt.length > 2000)
|
|
71
54
|
prompt = prompt.slice(0, 2000);
|
|
72
|
-
// 去重
|
|
73
55
|
const existing = state.actions.find((a) => a.label === label && a.prompt === prompt);
|
|
74
56
|
if (existing) {
|
|
75
57
|
return {
|
|
@@ -77,7 +59,6 @@ export const actionMarker = {
|
|
|
77
59
|
feedback: pick(lang, `建议操作已存在: ${label}`, `Suggested action already exists: ${label}`, "markers.action.already.exists", { label }),
|
|
78
60
|
};
|
|
79
61
|
}
|
|
80
|
-
// 数量上限 8 个,超限剔除最早的一项
|
|
81
62
|
if (state.actions.length >= 8) {
|
|
82
63
|
state.actions.shift();
|
|
83
64
|
}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* builtins/notify.ts — 纯提醒标记。
|
|
3
|
-
*/
|
|
4
1
|
import { getServerBlock, pick } from "../../i18n.js";
|
|
5
|
-
const NOTIFY_GUIDANCE_ZH = [
|
|
6
|
-
// #499:guidance 只能承诺协议真实支持的级别——success 从未存在于 notice 协议
|
|
7
|
-
// (protocol.ts 仅 info|warning|error),按指引用 success 会被静默降级成 info。
|
|
8
|
-
"- 浮动通知:[[notify:<级别>:<内容>]](级别:info|warning|error,不进入正文)。",
|
|
9
|
-
];
|
|
2
|
+
const NOTIFY_GUIDANCE_ZH = ["- 浮动通知:[[notify:<级别>:<内容>]](级别:info|warning|error,不进入正文)。"];
|
|
10
3
|
const NOTIFY_GUIDANCE_EN = [
|
|
11
4
|
"- Non-interruptive toast: [[notify:<level>:<message>]] (level: info|warning|error; omitted from reply).",
|
|
12
5
|
];
|
|
13
|
-
/** 语言感知的 notify guidance(issue #91):en 用英译、zh 用中文,默认英文。 */
|
|
14
6
|
export function getNotifyGuidance(lang = "en") {
|
|
15
7
|
return getServerBlock(lang, "markers.notify.guidance", NOTIFY_GUIDANCE_ZH, NOTIFY_GUIDANCE_EN);
|
|
16
8
|
}
|