pi-web-ui 0.117.0 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -2
- package/README.md +69 -138
- package/README.zh-CN.md +70 -179
- package/README.zh-TW.md +3 -1
- package/bin/device-hub-cli.mjs +147 -43
- package/bin/frp-manager.mjs +4 -80
- package/bin/hub-upgrade.mjs +561 -0
- package/bin/pi-device-hub.mjs +0 -1
- package/bin/pi-web-ui.mjs +56 -444
- package/deploy/nginx-subpath.conf +0 -33
- package/deploy/pi-web-ui.service +0 -20
- package/dist/server/agent-formatters.js +4 -38
- package/dist/server/agent-service-daemon.js +160 -374
- package/dist/server/agent-service.js +875 -2978
- package/dist/server/approval-audit.js +2 -23
- package/dist/server/approval-default-rules.js +0 -6
- package/dist/server/approval-rules.js +7 -105
- package/dist/server/ask-user-question-tool.js +1 -12
- package/dist/server/atomic-file.js +33 -5
- package/dist/server/attachment-store.js +0 -36
- package/dist/server/attachments.js +3 -112
- package/dist/server/auth-cookie.js +0 -21
- package/dist/server/bash-tool.js +1 -32
- package/dist/server/bg-servers.js +0 -96
- package/dist/server/browser-page-tool.js +11 -62
- package/dist/server/builtin-modules.js +7 -0
- package/dist/server/canvas/canvas-agent-tool.js +58 -47
- package/dist/server/canvas/canvas-cards.js +0 -14
- package/dist/server/canvas/canvas-dispatch.js +7 -4
- package/dist/server/canvas/canvas-orchestrator.js +167 -181
- package/dist/server/canvas/canvas-runtime-messages.js +30 -0
- package/dist/server/canvas/canvas-scheduled-task.js +0 -3
- package/dist/server/canvas/canvas-scheduler.js +5 -7
- package/dist/server/canvas/canvas-store.js +24 -35
- package/dist/server/canvas/canvas-validation.js +17 -14
- package/dist/server/canvas/canvas-workspace.js +26 -30
- package/dist/server/canvas/pstack-skills-data.js +0 -5
- package/dist/server/claim-files-tool.js +1 -15
- package/dist/server/claim-store.js +5 -49
- package/dist/server/client-id-utils.js +0 -16
- package/dist/server/client-state.js +6 -213
- package/dist/server/communicate-tool.js +0 -3
- package/dist/server/compact-context-tool.js +0 -30
- package/dist/server/compacted-history.js +0 -35
- package/dist/server/compaction-instructions.js +0 -13
- package/dist/server/compaction-markers.js +3 -76
- package/dist/server/compaction-state.js +0 -21
- package/dist/server/composer-drafts.js +0 -34
- package/dist/server/context-budget-runner.js +0 -11
- package/dist/server/context-budget.js +1 -70
- package/dist/server/context-evidence.js +0 -14
- package/dist/server/context-usage.js +0 -12
- package/dist/server/control-socket.js +4 -48
- package/dist/server/conversation-communication.js +0 -10
- package/dist/server/conversation-identity.js +0 -1
- package/dist/server/conversation-read-tool.js +0 -58
- package/dist/server/conversation-tool-names.js +0 -1
- package/dist/server/conversation-tool.js +0 -1
- package/dist/server/conversation-touches.js +4 -75
- package/dist/server/dangling-tools.js +0 -82
- package/dist/server/delegate-mode.js +0 -36
- package/dist/server/delegate-task.js +2 -28
- package/dist/server/device-center/approval-summary.js +0 -1
- package/dist/server/device-center/bot-catalog.js +0 -3
- package/dist/server/device-center/bot-execution.js +0 -8
- package/dist/server/device-center/bot-presets.js +0 -1
- package/dist/server/device-center/bots.js +0 -1
- package/dist/server/device-center/collab-service.js +1 -3
- package/dist/server/device-center/collab-tool.js +0 -10
- package/dist/server/device-center/connector.js +21 -11
- package/dist/server/device-center/delivery-authority.js +0 -3
- package/dist/server/device-center/delivery-subject.js +0 -1
- package/dist/server/device-center/desktop-linux.js +3 -15
- package/dist/server/device-center/desktop-native.js +1 -10
- package/dist/server/device-center/desktop-page.js +2 -3
- package/dist/server/device-center/desktop-setup.js +1 -3
- package/dist/server/device-center/desktop.js +1 -7
- package/dist/server/device-center/device-integration.js +1 -27
- package/dist/server/device-center/device-lan-access.js +403 -0
- package/dist/server/device-center/device-lan.js +484 -0
- package/dist/server/device-center/device-portals.js +0 -3
- package/dist/server/device-center/execution-failure.js +0 -2
- package/dist/server/device-center/execution-guides.js +0 -1
- package/dist/server/device-center/execution-instructions.js +0 -1
- package/dist/server/device-center/execution-settings.js +0 -1
- package/dist/server/device-center/execution-system-prompt.js +0 -3
- package/dist/server/device-center/execution-workspace.js +1 -4
- package/dist/server/device-center/executor.js +0 -27
- package/dist/server/device-center/file-sync-paths.js +0 -5
- package/dist/server/device-center/file-sync.js +0 -10
- package/dist/server/device-center/group-context-delta.js +0 -8
- package/dist/server/device-center/group-context-message.js +0 -14
- package/dist/server/device-center/group-context.js +0 -19
- package/dist/server/device-center/group-events.js +0 -2
- package/dist/server/device-center/group-plan-guard.js +1 -35
- package/dist/server/device-center/group-router-runtime.js +182 -0
- package/dist/server/device-center/group-router-worker.js +178 -0
- package/dist/server/device-center/group-router.js +359 -0
- package/dist/server/device-center/hub-auth.js +24 -2
- package/dist/server/device-center/hub-conversations.js +0 -12
- package/dist/server/device-center/hub-deliveries.js +0 -1
- package/dist/server/device-center/hub-integration.js +0 -8
- package/dist/server/device-center/hub-locks.js +1 -5
- package/dist/server/device-center/hub-mobile.js +147 -0
- package/dist/server/device-center/hub-orchestration.js +400 -0
- package/dist/server/device-center/hub-page.js +25 -7
- package/dist/server/device-center/hub-setup.js +0 -6
- package/dist/server/device-center/hub-transaction-log.js +0 -22
- package/dist/server/device-center/hub-upgrade.js +162 -0
- package/dist/server/device-center/hub-webhooks.js +1 -3
- package/dist/server/device-center/hub.js +210 -86
- package/dist/server/device-center/human-interaction.js +1 -4
- package/dist/server/device-center/integration-errors.js +0 -2
- package/dist/server/device-center/integration-verification.js +0 -2
- package/dist/server/device-center/local-hub.js +0 -2
- package/dist/server/device-center/local-publication.js +1 -8
- package/dist/server/device-center/local-verification-job.js +0 -2
- package/dist/server/device-center/local-verification.js +0 -1
- package/dist/server/device-center/local.js +267 -39
- package/dist/server/device-center/main.js +14 -1
- package/dist/server/device-center/mobile-notification-forwarder.js +292 -0
- package/dist/server/device-center/native-desktop/macos.js +0 -1
- package/dist/server/device-center/native-desktop/windows.js +0 -1
- package/dist/server/device-center/partition-log.js +0 -31
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +0 -7
- package/dist/server/device-center/publish-intent.js +0 -5
- package/dist/server/device-center/relay.js +85 -30
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +1 -18
- package/dist/server/device-center/store.js +13 -33
- package/dist/server/device-center/task-context-budget.js +0 -3
- package/dist/server/device-center/task-error.js +0 -1
- package/dist/server/device-center/task-journal.js +6 -23
- package/dist/server/device-center/task-outcome.js +0 -13
- package/dist/server/device-center/task-plan.js +0 -1
- package/dist/server/device-center/task-progress.js +0 -16
- package/dist/server/device-center/task-recovery.js +5 -88
- package/dist/server/device-center/task-report-outbox.js +0 -4
- package/dist/server/device-center/task-report.js +2 -10
- package/dist/server/device-center/task-scheduler.js +1 -35
- package/dist/server/device-center/task-settlement.js +0 -18
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +0 -50
- package/dist/server/device-center/transfer-stream.js +5 -45
- package/dist/server/device-center/transfers.js +2 -10
- package/dist/server/device-center/verification-limits.js +0 -1
- package/dist/server/device-center/work-contract.js +1 -73
- package/dist/server/device-center/work-items.js +317 -0
- package/dist/server/device-center/workspaces.js +0 -1
- package/dist/server/dispatch-domain-handlers.js +190 -32
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +69 -599
- package/dist/server/dsh/dsh-client.js +7 -111
- package/dist/server/dsh/dsh-market-service.js +4 -25
- package/dist/server/dsh/dsh-serialize.js +0 -49
- package/dist/server/dsh/dsh-sessions.js +0 -37
- package/dist/server/dsh/dsh-usage.js +0 -37
- package/dist/server/dsh/preset-clones.js +1 -65
- package/dist/server/dsh/runtime/custom-prompt.mjs +0 -14
- package/dist/server/dsh/runtime/goal-rpc.mjs +7 -176
- package/dist/server/dsh/runtime/launcher.mjs +2 -53
- package/dist/server/dsh/runtime/override.patch.yml +0 -29
- package/dist/server/dsh/runtime/runtime-root.mjs +0 -54
- package/dist/server/durable/durable-agent-service.js +5 -23
- package/dist/server/durable/durable-driver.js +12 -73
- package/dist/server/durable/durable-event-projector.js +1 -50
- package/dist/server/durable/durable-loader.js +0 -12
- package/dist/server/durable/durable-models.js +11 -80
- package/dist/server/durable/durable-storage.js +1 -17
- package/dist/server/durable/durable-tools.js +2 -20
- package/dist/server/durable/index.js +0 -3
- package/dist/server/edit-soft-tool.js +2 -81
- package/dist/server/engine-capabilities.js +0 -13
- package/dist/server/engine-catalog.js +74 -0
- package/dist/server/engine-cli.js +89 -0
- package/dist/server/engine-probe.js +35 -217
- package/dist/server/ensure-bash.js +2 -28
- package/dist/server/eval-tool.js +1 -50
- package/dist/server/evidence-tool-hooks.js +0 -2
- package/dist/server/file-archives.js +0 -10
- package/dist/server/file-save.js +1 -12
- package/dist/server/file-transfer-routes.js +0 -11
- package/dist/server/files-service.js +18 -271
- package/dist/server/global-loader.js +9 -89
- package/dist/server/goal-evidence.js +1 -35
- package/dist/server/goal-review-gate.js +0 -58
- package/dist/server/goal-service.js +19 -422
- package/dist/server/hashline-engine.js +8 -112
- package/dist/server/host-guard.js +0 -24
- package/dist/server/host-metrics.js +0 -6
- package/dist/server/http-proxy.js +1 -7
- package/dist/server/i18n.js +5 -72
- package/dist/server/icon-svg.js +0 -15
- package/dist/server/index.js +177 -680
- package/dist/server/json-utils.js +0 -12
- package/dist/server/launch-origin.js +0 -44
- package/dist/server/left-panel-running.js +0 -9
- package/dist/server/load-timing.js +1 -4
- package/dist/server/load-tools-tool.js +0 -20
- package/dist/server/locales.js +1 -46
- package/dist/server/lsp-tool.js +13 -126
- package/dist/server/managed.js +0 -48
- package/dist/server/marker-service.js +1 -22
- package/dist/server/markers/builtins/action.js +0 -19
- package/dist/server/markers/builtins/notify.js +1 -9
- package/dist/server/markers/builtins/rename.js +0 -13
- package/dist/server/markers/index.js +0 -3
- package/dist/server/markers/marker.js +0 -13
- package/dist/server/markers/registry.js +0 -3
- package/dist/server/markers/store.js +1 -12
- package/dist/server/market-service.js +7 -43
- package/dist/server/mcp-agent-tool.js +0 -10
- package/dist/server/mcp-bridge.js +6 -138
- package/dist/server/mcp-hot-reload.js +0 -25
- package/dist/server/mcp-manager.js +2 -44
- package/dist/server/mcp-oauth-login.js +0 -2
- package/dist/server/mcp-oauth-ui.js +1 -4
- package/dist/server/mcp-oauth.js +5 -79
- package/dist/server/mcp-project-runtime.js +0 -4
- package/dist/server/message-deletion.js +0 -2
- package/dist/server/message-entry-resolver.js +0 -8
- package/dist/server/message-window.js +0 -71
- package/dist/server/mobile-notification-events.js +16 -0
- package/dist/server/mobile-origin.js +79 -0
- package/dist/server/mobile-push.js +523 -0
- package/dist/server/model-admin.js +19 -358
- package/dist/server/model-enrich.js +0 -19
- package/dist/server/model-resolver.js +2 -61
- package/dist/server/native-cli-discovery.js +115 -0
- package/dist/server/native-cli-model.js +71 -0
- package/dist/server/native-cli-references.js +214 -0
- package/dist/server/native-cli-remote-cleanup.js +58 -0
- package/dist/server/native-cli-remote-files.js +282 -0
- package/dist/server/native-cli-routes.js +68 -0
- package/dist/server/native-cli-runtime.js +1 -0
- package/dist/server/native-cli-session-hooks.js +170 -0
- package/dist/server/native-cli-session.js +585 -0
- package/dist/server/native-cli-state.js +82 -0
- package/dist/server/native-cli.js +210 -0
- package/dist/server/net-guard.js +9 -71
- package/dist/server/office-parse.js +0 -50
- package/dist/server/orphan-manager.js +0 -18
- package/dist/server/patch-bash-process.js +0 -4
- package/dist/server/patch-executable-lookup.js +0 -77
- package/dist/server/patch-node-pty.js +3 -43
- package/dist/server/patch-remote-catalog.js +1 -32
- package/dist/server/patch-tool.js +0 -15
- package/dist/server/payload-limits.js +0 -5
- package/dist/server/pending-question.js +0 -5
- package/dist/server/permission-preset.js +4 -33
- package/dist/server/persona-chain.js +0 -26
- package/dist/server/pkg-info.js +1 -17
- package/dist/server/plan-manager.js +2 -49
- package/dist/server/plan-mode.js +0 -97
- package/dist/server/plan-update-tool.js +1 -15
- package/dist/server/plugin-api-catalog.js +6 -4
- package/dist/server/plugin-assets.js +1 -35
- package/dist/server/plugin-bundled.js +68 -0
- package/dist/server/plugin-catalog-sync.js +0 -37
- package/dist/server/plugin-catalog.js +13 -67
- package/dist/server/plugin-chat-attachments.js +0 -1
- package/dist/server/plugin-conversation-view.js +0 -20
- package/dist/server/plugin-dom.js +1 -23
- package/dist/server/plugin-facilities.js +4 -115
- package/dist/server/plugin-grants.js +2 -90
- package/dist/server/plugin-install-spec.js +0 -43
- package/dist/server/plugin-installer.js +34 -75
- package/dist/server/plugin-llm.js +4 -38
- package/dist/server/plugin-manifest-validate.js +0 -31
- package/dist/server/plugin-permissions.js +1 -24
- package/dist/server/plugin-project.js +7 -129
- package/dist/server/plugin-removal.js +1 -8
- package/dist/server/plugin-schedule.js +1 -38
- package/dist/server/plugin-secrets.js +3 -16
- package/dist/server/plugin-tool-guard.js +1 -28
- package/dist/server/plugin-ui-slots.js +0 -4
- package/dist/server/plugin-updater.js +15 -90
- package/dist/server/plugins.js +71 -619
- package/dist/server/present-files-tool.js +0 -57
- package/dist/server/preset-fields.js +9 -62
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +3 -172
- package/dist/server/process-utils.js +4 -80
- package/dist/server/prompt-assembler.js +2 -30
- package/dist/server/prompt-base-store.js +0 -47
- package/dist/server/prompt-composer.js +21 -98
- package/dist/server/prompt-templates.js +0 -2
- package/dist/server/protocol-version.js +1 -11
- package/dist/server/protocol.js +0 -5
- package/dist/server/queue-modes.js +0 -3
- package/dist/server/queue-utils.js +0 -40
- package/dist/server/quick-ask-context.js +384 -0
- package/dist/server/quick-ask-settings.js +34 -1
- package/dist/server/quick-ask.js +123 -27
- package/dist/server/read-tool.js +0 -65
- package/dist/server/reasoning-registry.js +1 -29
- package/dist/server/remote-cli-persistence.js +373 -0
- package/dist/server/remote-native-cli.js +78 -0
- package/dist/server/remote-ssh-service.js +481 -190
- package/dist/server/request-context.js +0 -9
- package/dist/server/resolve-global-sdk.js +0 -26
- package/dist/server/sandbox-data.js +0 -1
- package/dist/server/sandbox-engines.js +0 -1
- package/dist/server/sandbox-runtime-gate.js +0 -3
- package/dist/server/sandbox-service.js +0 -41
- package/dist/server/sandbox-tool.js +0 -20
- package/dist/server/schedule-agent-tool.js +2 -31
- package/dist/server/scheduler-tasks.js +3 -54
- package/dist/server/scm-commitmsg.js +0 -53
- package/dist/server/scm.js +3 -48
- package/dist/server/sdk-builtin-extensions.js +2 -29
- package/dist/server/sdk-origin.js +0 -45
- package/dist/server/serialize.js +2 -92
- package/dist/server/server-config.js +0 -11
- package/dist/server/session-branch.js +1 -87
- package/dist/server/session-list-scan.js +17 -25
- package/dist/server/session-open.js +2 -26
- package/dist/server/session-parser.js +1 -55
- package/dist/server/session-scan.js +1 -17
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +11 -126
- package/dist/server/setup-config.js +0 -2
- package/dist/server/setup-page.js +0 -9
- package/dist/server/skill-content-filler.js +0 -17
- package/dist/server/skill-discovery.js +5 -92
- package/dist/server/skill-maintenance.js +1 -28
- package/dist/server/skill-tool.js +0 -30
- package/dist/server/slash-commands.js +5 -50
- package/dist/server/soft-cap.js +0 -42
- package/dist/server/startup-banner.js +0 -8
- package/dist/server/subagent-handoff.js +0 -11
- package/dist/server/subagent-helpers.js +2 -17
- package/dist/server/subagent-notify.js +0 -19
- package/dist/server/subagent-security-gate.js +0 -50
- package/dist/server/subagent-task.js +0 -9
- package/dist/server/subagent-templates-hant.js +0 -10
- package/dist/server/subagent-templates.js +3 -103
- package/dist/server/subagents.js +1 -87
- package/dist/server/system-screenshot-windows.js +259 -0
- package/dist/server/system-screenshot.js +77 -0
- package/dist/server/tabs.js +3 -48
- package/dist/server/terminals.js +559 -586
- package/dist/server/text-quote.js +0 -12
- package/dist/server/text-sniff.js +2 -52
- package/dist/server/themes.js +2 -41
- package/dist/server/tool-approval.js +0 -47
- package/dist/server/tool-guards.js +0 -90
- package/dist/server/tool-host-factories.js +1 -16
- package/dist/server/tool-info.js +0 -13
- package/dist/server/tool-manager.js +1 -229
- package/dist/server/tool-overrides.js +1 -46
- package/dist/server/tool-prompt-overrides.js +1 -30
- package/dist/server/tool-prompts.js +0 -14
- package/dist/server/tool-signature.js +0 -25
- package/dist/server/transcript-prepare.js +1 -19
- package/dist/server/tts-routes.js +58 -0
- package/dist/server/tts-service.js +106 -0
- package/dist/server/tts-system.js +160 -0
- package/dist/server/turn-timing.js +0 -1
- package/dist/server/unauthorized-page.js +0 -8
- package/dist/server/universal/driver-base.js +2 -31
- package/dist/server/universal/drivers/claude-code.js +12 -172
- package/dist/server/universal/drivers/codex.js +12 -35
- package/dist/server/universal/drivers/mock-driver.js +1 -11
- package/dist/server/universal/index.js +0 -3
- package/dist/server/universal/session-store.js +4 -21
- package/dist/server/universal/universal-attachments.js +2 -36
- package/dist/server/universal/universal-service.js +5 -24
- package/dist/server/universal/universal-session.js +26 -148
- package/dist/server/universal/universal-types.js +0 -3
- package/dist/server/update-check.js +6 -182
- package/dist/server/uploads.js +4 -43
- package/dist/server/virtual-tui.js +2 -27
- package/dist/server/vision-bridge.js +0 -27
- package/dist/server/wait-subscription-scan.js +13 -115
- package/dist/server/webui-context.js +2 -87
- package/dist/server/workspace-handle.js +1 -56
- package/dist/server/workspace-snapshot.js +7 -113
- package/dist/server/worktree-service.js +2 -53
- package/dist/server/worktree-tool.js +0 -11
- package/dist/server/ws-client-id.js +0 -18
- package/dist/server/ws-pending-queue.js +0 -7
- package/dist/server/ws-unknown-types.js +0 -17
- package/docs/README.md +24 -17
- package/docs/architecture-plugins.md +37 -1
- package/docs/device-center.md +28 -2
- package/docs/device-desktop.md +3 -3
- package/docs/group-orchestration.md +142 -0
- package/docs/hub-upgrade-release-testing.md +46 -0
- package/extensions/webui.ts +3 -74
- package/package.json +7 -3
- package/plugin-sdk/README.md +6 -0
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +0 -1
- package/plugin-sdk/client.mjs +1 -31
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +120 -119
- package/plugin-sdk/index.mjs +0 -6
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +0 -1
- package/plugin-sdk/testing.mjs +31 -86
- package/plugins/catalog.json +52 -4
- package/plugins/superagent/README.md +110 -0
- package/plugins/superagent/client/entry.mjs +21 -0
- package/plugins/superagent/index.mjs +8 -0
- package/plugins/superagent/main.mjs +218 -0
- package/plugins/superagent/manifest.json +15 -0
- package/plugins/superagent/server.mjs +572 -0
- package/plugins/superagent/style.css +167 -0
- package/themes/aetheris.css +1 -31
- package/themes/ayu-light.css +0 -1
- package/themes/bases/flow-base.css +2 -83
- package/themes/bases/obsidian-base.css +2 -37
- package/themes/bases/statusbar-flat-base.css +0 -1
- package/themes/bases/zhujian-base.css +0 -63
- package/themes/bases/zhupi-base.css +0 -64
- package/themes/catppuccin-latte.css +0 -1
- package/themes/catppuccin.css +0 -1
- package/themes/claude-code-dark.css +0 -1
- package/themes/codex.css +0 -1
- package/themes/dark-teal.css +22 -54
- package/themes/everforest-light.css +0 -1
- package/themes/flow-cristallo.css +1 -9
- package/themes/flow-ink.css +1 -10
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +1 -10
- package/themes/flow-zurich.css +1 -10
- package/themes/flow.css +1 -9
- package/themes/geist.css +0 -1
- package/themes/gruvbox-light.css +0 -1
- package/themes/kanagawa-lotus.css +0 -1
- package/themes/md-preview.css +1 -2
- package/themes/mist.css +0 -1
- package/themes/nord.css +0 -1
- package/themes/one-dark.css +0 -1
- package/themes/paper.css +0 -1
- package/themes/rose-pine-dawn.css +0 -1
- package/themes/sakura.css +0 -1
- package/themes/solarized-light.css +0 -1
- package/themes/tokyo-night.css +0 -1
- package/themes/translucent.css +4 -35
- package/themes/transparent.css +4 -41
- package/themes/vs-code-dark.css +0 -1
- package/themes/wallpaper-flow.css +3 -17
- package/themes/wallpaper-obsidian.css +1 -4
- package/themes/white.css +0 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BjNRIUIc.js → BgTasksModal-D-x7kA63.js} +1 -1
- package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
- package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
- package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
- package/web/dist/assets/{Dropdown-CQtstPGv.js → Dropdown-CTgVLUbp.js} +1 -1
- package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
- package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
- package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
- package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
- package/web/dist/assets/{HintTip-ChTW8o1m.js → HintTip-Da6qc566.js} +1 -1
- package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
- package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
- package/web/dist/assets/{PiSetupModal-BX5rUuoI.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/{SCMPanel-DPAyY2sW.js → SCMPanel-CuEgzAlO.js} +2 -2
- package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
- package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
- package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
- package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
- package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
- package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
- package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
- package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
- package/web/dist/assets/index-CQc3VrWa.css +1 -0
- package/web/dist/assets/index-D_AGu4Zv.js +404 -0
- package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
- package/web/dist/assets/{remote-ssh-client-Dzi-eEyE.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +11 -10
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/web/dist/assets/BgTasksModal-C0zuU8FE.js +0 -1
- package/web/dist/assets/CanvasStudio-BWvdmJ0M.js +0 -1579
- package/web/dist/assets/CanvasStudio-VQFjmTGq.js +0 -1579
- package/web/dist/assets/DeviceCenter-DI9_0aBB.js +0 -3
- package/web/dist/assets/DeviceCenter-DsNtXqzY.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +0 -1
- package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +0 -1
- package/web/dist/assets/DeviceGroups-CP7CcyPD.js +0 -1
- package/web/dist/assets/FilePreview-BMB2tNyT.js +0 -2
- package/web/dist/assets/FilePreview-RGFQUbJo.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BM5wxiqU.js +0 -1
- package/web/dist/assets/GlobalSearchModal-DGv_WINq.js +0 -1
- package/web/dist/assets/GroupConversation-B7SnuXj1.js +0 -61
- package/web/dist/assets/GroupConversation-Dda69q-2.js +0 -61
- package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +0 -2
- package/web/dist/assets/ModelConfigModal-yqeadyab.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-DY4SCfXg.js +0 -1
- package/web/dist/assets/SCMPanel-C4KbQvvK.js +0 -2
- package/web/dist/assets/SettingsModal-DxZp6D_g.js +0 -32
- package/web/dist/assets/SettingsModal-WhQzaOPt.js +0 -32
- package/web/dist/assets/TerminalPanel-D4By_RVc.js +0 -3
- package/web/dist/assets/TerminalPanel-lZw8-i3j.js +0 -3
- package/web/dist/assets/TuiOverlayModal-C3pAVuC8.js +0 -1
- package/web/dist/assets/TuiOverlayModal-D7_rEXcJ.js +0 -1
- package/web/dist/assets/app-globals-KqOVtmp1.js +0 -123
- package/web/dist/assets/canvas-client-BY6ojmle.js +0 -1
- package/web/dist/assets/desktop-CV6KKp9R.js +0 -1
- package/web/dist/assets/index-BawF7ZP5.js +0 -397
- package/web/dist/assets/index-BoGCoq5X.js +0 -397
- package/web/dist/assets/index-CVW9FoY2.css +0 -1
- package/web/dist/assets/plugin-host-Dn8Dd6SC.js +0 -1
- package/web/dist/assets/theme-D_bihpdN.js +0 -1
|
@@ -9,7 +9,6 @@ import { isAbsoluteWirePath, wireToAbs } from "./files-service.js";
|
|
|
9
9
|
import { buildVisionBridgePrompt, findVisionModels, transcribeImages } from "./vision-bridge.js";
|
|
10
10
|
import { saveAttachment } from "./attachment-store.js";
|
|
11
11
|
import { getGlobalRemoteSshService, isRemoteWorkspaceUri, parseRemoteWorkspaceUri, resolveRemoteWorkspacePath, } from "./remote-ssh-service.js";
|
|
12
|
-
/** Resolve reference metadata without creating the store's implicit default graph. */
|
|
13
12
|
export function getCanvasReference(graphId) {
|
|
14
13
|
const dataDir = resolveDataDir();
|
|
15
14
|
if (!isSafeGraphId(graphId) || !existsSync(join(dataDir, "canvas", `${graphId}.json`))) {
|
|
@@ -20,22 +19,16 @@ export function getCanvasReference(graphId) {
|
|
|
20
19
|
throw new Error("Canvas graph id mismatch");
|
|
21
20
|
return { id: graphId, title: graph.name || graphId };
|
|
22
21
|
}
|
|
23
|
-
/** 跨快照的视觉转写缓存:批次 hash(名称 + base64 头 + 提示词)→ 转写文本。
|
|
24
|
-
* 编辑重问重发相同图片不再重复耗视觉 token。进程级共享即可。
|
|
25
|
-
* 长驻进程下无界 Map 会随图片种类缓慢吃内存(单条转写可达数十 KB),
|
|
26
|
-
* 超过 VISION_BRIDGE_CACHE_MAX 按插入序 FIFO 淘汰最旧。 */
|
|
27
22
|
const VISION_BRIDGE_CACHE_MAX = 256;
|
|
28
23
|
const visionBridgeCache = new Map();
|
|
29
24
|
function cacheVisionTranscript(key, value) {
|
|
30
25
|
visionBridgeCache.set(key, value);
|
|
31
26
|
if (visionBridgeCache.size > VISION_BRIDGE_CACHE_MAX) {
|
|
32
|
-
// Map 迭代序 = 插入序,第一个 key 即最旧。
|
|
33
27
|
const oldest = visionBridgeCache.keys().next().value;
|
|
34
28
|
if (oldest !== undefined)
|
|
35
29
|
visionBridgeCache.delete(oldest);
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
|
-
/** "provider/id" 解析;非法格式返回 null。 */
|
|
39
32
|
export function parseModelSpec(spec) {
|
|
40
33
|
if (!spec)
|
|
41
34
|
return null;
|
|
@@ -44,7 +37,6 @@ export function parseModelSpec(spec) {
|
|
|
44
37
|
return null;
|
|
45
38
|
return { provider: spec.slice(0, slash), id: spec.slice(slash + 1), spec };
|
|
46
39
|
}
|
|
47
|
-
/** XML attribute escaping — page titles can contain quotes/brackets. */
|
|
48
40
|
function attr(value) {
|
|
49
41
|
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
50
42
|
}
|
|
@@ -96,11 +88,6 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
96
88
|
".svg": "image/svg+xml",
|
|
97
89
|
};
|
|
98
90
|
const out = [];
|
|
99
|
-
/** Push the aside for a raw uploaded file (fresh fileData or a restored
|
|
100
|
-
* uploadPath re-read from disk). Uploads are NEVER inlined: the model gets
|
|
101
|
-
* the persisted absolute path and reads it on demand with its read tool.
|
|
102
|
-
* `upload: true` marks the card as a restorable upload — the browser
|
|
103
|
-
* re-sends it by path when editing & re-asking a question. */
|
|
104
91
|
const pushUploadAside = (name, wirePath, buf) => {
|
|
105
92
|
out.push({
|
|
106
93
|
message: {
|
|
@@ -122,29 +109,16 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
122
109
|
},
|
|
123
110
|
});
|
|
124
111
|
};
|
|
125
|
-
// -- Vision bridge ------------------------------------------------------
|
|
126
|
-
// When the active model can't accept images (DeepSeek, GLM, …), pasted
|
|
127
|
-
// images are transcribed by a configured vision model first and the
|
|
128
|
-
// transcript is fed to the text-only model as text evidence (see
|
|
129
|
-
// vision-bridge.ts — any model in models.json whose input includes
|
|
130
|
-
// "image" works, zero extra config). Vision-capable main models keep
|
|
131
|
-
// the raw image-content path untouched.
|
|
132
112
|
const mainModel = ctx.session.model;
|
|
133
113
|
const mainSupportsVision = mainModel?.input?.includes("image") ?? false;
|
|
134
114
|
const bridgedImages = [];
|
|
135
|
-
/** Raw image bytes for path-referenced image files (idx → info), pre-read
|
|
136
|
-
* so the loop below doesn't re-read them. SVG stays a plain text file —
|
|
137
|
-
* the model reads its source, far more useful than a rasterized blob. */
|
|
138
115
|
const pathImageData = new Map();
|
|
139
|
-
/** Cap for path images (fully read + base64'd); larger ones fall back to
|
|
140
|
-
* a plain path reference (the model can still attempt to read them). */
|
|
141
116
|
const MAX_PATH_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
142
117
|
for (const [idx, att] of attachments.entries()) {
|
|
143
118
|
if (att.imageData) {
|
|
144
119
|
const raw = att.imageData.replace(/^data:[^;]*;base64,/, "");
|
|
145
120
|
const mimeType = att.mimeType?.startsWith("image/") ? att.mimeType : "image/png";
|
|
146
121
|
const bytes = Buffer.byteLength(raw, "base64");
|
|
147
|
-
// Only images that would actually be sent (non-empty, under the cap).
|
|
148
122
|
if (bytes > 0 && bytes <= 2 * 1024 * 1024) {
|
|
149
123
|
if (!mainSupportsVision) {
|
|
150
124
|
bridgedImages.push({ idx, att, raw, mimeType, bytes });
|
|
@@ -202,7 +176,6 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
202
176
|
bridgedImages.push({ idx, att, raw, mimeType: mime, bytes: st.size });
|
|
203
177
|
}
|
|
204
178
|
}
|
|
205
|
-
/** Transcript per attachment index (filled below, keyed by bridgedImages idx). */
|
|
206
179
|
const bridgeTranscripts = new Map();
|
|
207
180
|
if (bridgedImages.length > 0) {
|
|
208
181
|
if (!ctx.settings.visionBridgeEnabled) {
|
|
@@ -215,8 +188,6 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
215
188
|
}
|
|
216
189
|
else {
|
|
217
190
|
const visionModels = findVisionModels(ctx.session.modelRuntime);
|
|
218
|
-
// Preferred model from settings ("provider/id") — validated to exist
|
|
219
|
-
// and actually accept images; falls back to the first auto-detected.
|
|
220
191
|
let chosen = visionModels[0] ?? null;
|
|
221
192
|
const pref = ctx.settings.visionBridgeModel;
|
|
222
193
|
if (pref) {
|
|
@@ -241,13 +212,7 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
241
212
|
});
|
|
242
213
|
}
|
|
243
214
|
else {
|
|
244
|
-
// Batch hash so re-sending identical images (edit & re-ask) reuses
|
|
245
|
-
// the transcript instead of re-burning tokens on the vision API.
|
|
246
|
-
// issue #91:转写提示词按客户端 UI 语言选用(英文默认),语言进缓存键。
|
|
247
215
|
const vLang = ctx.getLang?.() ?? "en";
|
|
248
|
-
// The active transcription prompt is part of the key: changing
|
|
249
|
-
// the custom prompt must invalidate cached transcripts made with
|
|
250
|
-
// the old prompt.
|
|
251
216
|
const batchHash = bridgedImages.map((b) => `${b.att.name ?? "img"}:${b.raw.slice(0, 48)}`).join("|") +
|
|
252
217
|
"::" +
|
|
253
218
|
buildVisionBridgePrompt(ctx.settings.visionBridgePromptMode, ctx.settings.visionBridgePrompt, vLang) +
|
|
@@ -317,11 +282,6 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
317
282
|
});
|
|
318
283
|
continue;
|
|
319
284
|
}
|
|
320
|
-
// Quoted conversation (left-panel right-click / global-search quote):
|
|
321
|
-
// `path` is unused — the reference travels in conversationId (running
|
|
322
|
-
// conversation, incl. subagents) or sessionPath (history transcript).
|
|
323
|
-
// The transcript is NOT inlined here (it can be huge and goes stale);
|
|
324
|
-
// the model fetches it on demand with the conversation tool.
|
|
325
285
|
if (att.mode === "conversation") {
|
|
326
286
|
const convId = att.conversationId;
|
|
327
287
|
const sessPath = att.sessionPath;
|
|
@@ -356,7 +316,6 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
356
316
|
});
|
|
357
317
|
continue;
|
|
358
318
|
}
|
|
359
|
-
// Canvas identifiers are not filesystem paths. Resolve only through the canvas store.
|
|
360
319
|
if (att.mode === "canvas") {
|
|
361
320
|
const graphId = att.path;
|
|
362
321
|
try {
|
|
@@ -388,22 +347,13 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
388
347
|
}
|
|
389
348
|
continue;
|
|
390
349
|
}
|
|
391
|
-
// Granted web page (page-picker extension): `path` is the page origin,
|
|
392
|
-
// NOT a workspace path — never stat/read it. The model gets the exact
|
|
393
|
-
// browser_page target plus the fact that this page is already granted,
|
|
394
|
-
// so it doesn't have to guess an origin out of the prose.
|
|
395
350
|
if (att.mode === "page") {
|
|
396
351
|
const url = att.path;
|
|
397
352
|
let target = url;
|
|
398
353
|
try {
|
|
399
|
-
// The extension matches pages by origin — keep the hint in the same
|
|
400
|
-
// shape as `browser_page`'s `target` (sub-paths are not part of it).
|
|
401
354
|
target = new URL(url).origin;
|
|
402
355
|
}
|
|
403
|
-
catch {
|
|
404
|
-
// Not a full URL (hand-written string) → pass it through as-is and
|
|
405
|
-
// let the extension decide.
|
|
406
|
-
}
|
|
356
|
+
catch { }
|
|
407
357
|
const pageTitle = att.name ?? url;
|
|
408
358
|
out.push({
|
|
409
359
|
message: {
|
|
@@ -411,7 +361,7 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
411
361
|
content: [
|
|
412
362
|
{
|
|
413
363
|
type: "text",
|
|
414
|
-
text: `\n<browser-page url="${attr(url)}" title="${attr(pageTitle)}">\nThe user attached this web page
|
|
364
|
+
text: `\n<browser-page url="${attr(url)}" title="${attr(pageTitle)}">\nThe user attached this web page from the native browser or an authorized browser extension. Use the browser_page tool with target="${attr(target)}" to read or act on it — do not fetch it over the network.\n</browser-page>`,
|
|
415
365
|
},
|
|
416
366
|
],
|
|
417
367
|
display: true,
|
|
@@ -420,8 +370,6 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
420
370
|
});
|
|
421
371
|
continue;
|
|
422
372
|
}
|
|
423
|
-
// Raw pasted/dropped/uploaded image — no workspace path involved (the
|
|
424
|
-
// browser downscales client-side; this guard only prevents abuse).
|
|
425
373
|
if (att.imageData) {
|
|
426
374
|
const raw = att.imageData.replace(/^data:[^;]*;base64,/, "");
|
|
427
375
|
const mimeType = att.mimeType?.startsWith("image/") ? att.mimeType : "image/png";
|
|
@@ -452,14 +400,9 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
452
400
|
attachmentUrl = rec.url;
|
|
453
401
|
attachmentHash = rec.hash;
|
|
454
402
|
}
|
|
455
|
-
catch {
|
|
456
|
-
/* CAS 保存失败不阻断流程 */
|
|
457
|
-
}
|
|
403
|
+
catch { }
|
|
458
404
|
const transcript = bridgeTranscripts.get(idx);
|
|
459
405
|
if (transcript) {
|
|
460
|
-
// Bridged: the text-only main model can't see images, so it gets the
|
|
461
|
-
// vision model's transcript as text evidence; the image block is
|
|
462
|
-
// kept so the card still shows the original thumbnail.
|
|
463
406
|
out.push({
|
|
464
407
|
message: {
|
|
465
408
|
customType: "file",
|
|
@@ -502,7 +445,6 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
502
445
|
display: true,
|
|
503
446
|
details: {
|
|
504
447
|
name: att.name ?? "image.png",
|
|
505
|
-
// No workspace path — the card renders without the path line.
|
|
506
448
|
path: undefined,
|
|
507
449
|
mode: "image",
|
|
508
450
|
size: bytes,
|
|
@@ -513,10 +455,6 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
513
455
|
});
|
|
514
456
|
continue;
|
|
515
457
|
}
|
|
516
|
-
// Raw uploaded file (base64) — no workspace path involved. The bytes are
|
|
517
|
-
// persisted under <dataDir>/uploads/<clientId>/ so the model can read
|
|
518
|
-
// them on demand with its read tool (absolute path, no traversal guard
|
|
519
|
-
// needed — the path is server-generated). Always a path reference.
|
|
520
458
|
if (att.fileData) {
|
|
521
459
|
const maxBytes = uploadLimitBytes(ctx.settings, "chat");
|
|
522
460
|
if (isUploadDataTooLong(att.fileData.length, maxBytes)) {
|
|
@@ -548,10 +486,6 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
548
486
|
continue;
|
|
549
487
|
}
|
|
550
488
|
// Uploaded files live in a GLOBAL per-user dir (not inside the project
|
|
551
|
-
// or the per-client session store) so browsing a repo never picks up
|
|
552
|
-
// uploaded junk: <dataDir>/uploads/<clientId>/(保留期自动清理,见 uploads.ts)。
|
|
553
|
-
// saveUpload 对非法 clientId/displayName 抛错(消毒失败整条拒绝,绝不
|
|
554
|
-
// 落到别的目录)—— 这里报错跳过该附件,不让一条坏附件中断整条消息。
|
|
555
489
|
let saved;
|
|
556
490
|
try {
|
|
557
491
|
saved = saveUpload(ctx.clientId, att.name ?? "file", buf);
|
|
@@ -566,20 +500,10 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
566
500
|
continue;
|
|
567
501
|
}
|
|
568
502
|
const { abs, displayName: safeName } = saved;
|
|
569
|
-
// Wire format: forward-slash absolute path (the read tool accepts
|
|
570
|
-
// absolute paths; Windows uses "C:/..." — safe inside the XML-ish tag).
|
|
571
503
|
const wirePath = abs.split(sep).join("/");
|
|
572
504
|
pushUploadAside(safeName, wirePath, buf);
|
|
573
505
|
continue;
|
|
574
506
|
}
|
|
575
|
-
// Restored upload from edit-and-re-ask: the browser re-sends the
|
|
576
|
-
// server-generated absolute path of a previously uploaded (fileData)
|
|
577
|
-
// file instead of the original base64 (the fork drops the original
|
|
578
|
-
// aside card, so the bytes must be re-read from the uploads dir).
|
|
579
|
-
// Validate the path stays inside THIS client's uploads/ folder, then
|
|
580
|
-
// re-read the persisted bytes and attach by the same path — no
|
|
581
|
-
// re-save (the file already exists; retention sweeping governs its
|
|
582
|
-
// lifetime, same as the original card).
|
|
583
507
|
if (att.uploadPath) {
|
|
584
508
|
const rootDir = uploadsRoot();
|
|
585
509
|
const abs = resolve(rootDir, att.uploadPath);
|
|
@@ -669,8 +593,6 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
669
593
|
}
|
|
670
594
|
}
|
|
671
595
|
const name = att.path.split(/[\\/]/).pop() ?? att.path;
|
|
672
|
-
// Folders can't be inlined — always a path reference the model browses
|
|
673
|
-
// on demand with its own tools (ls/read).
|
|
674
596
|
if (stat.isDirectory()) {
|
|
675
597
|
out.push({
|
|
676
598
|
message: {
|
|
@@ -701,8 +623,6 @@ The user referenced this canvas. First use canvas(action="get", graphId="${attr(
|
|
|
701
623
|
const pathImg = pathImageData.get(idx);
|
|
702
624
|
const transcript = bridgeTranscripts.get(idx);
|
|
703
625
|
if (transcript) {
|
|
704
|
-
// Text-only main model: the vision bridge transcribed this image —
|
|
705
|
-
// the model gets the transcript as text evidence (+ thumbnail).
|
|
706
626
|
out.push({
|
|
707
627
|
message: {
|
|
708
628
|
customType: "file",
|
|
@@ -736,8 +656,6 @@ ${transcript}
|
|
|
736
656
|
continue;
|
|
737
657
|
}
|
|
738
658
|
if (pathImg) {
|
|
739
|
-
// Vision-capable main model (or bridge failed): send the raw image
|
|
740
|
-
// content straight from the pre-read bytes.
|
|
741
659
|
out.push({
|
|
742
660
|
message: {
|
|
743
661
|
customType: "file",
|
|
@@ -754,8 +672,6 @@ ${transcript}
|
|
|
754
672
|
});
|
|
755
673
|
continue;
|
|
756
674
|
}
|
|
757
|
-
// Pre-read failed (unsupported sniff / too large): fall back to the
|
|
758
|
-
// legacy inline-cap behavior.
|
|
759
675
|
if (stat.size > MAX_ATTACHMENT_BYTES) {
|
|
760
676
|
ctx.emit({
|
|
761
677
|
type: "notice",
|
|
@@ -784,7 +700,6 @@ ${transcript}
|
|
|
784
700
|
});
|
|
785
701
|
continue;
|
|
786
702
|
}
|
|
787
|
-
/** Path-only aside — no file content is read or injected. */
|
|
788
703
|
const makeReference = () => ({
|
|
789
704
|
message: {
|
|
790
705
|
customType: "file",
|
|
@@ -798,12 +713,6 @@ ${transcript}
|
|
|
798
713
|
details: { name, path: rel, mode: "reference", size: stat.size },
|
|
799
714
|
},
|
|
800
715
|
});
|
|
801
|
-
// Everything else is a PATH REFERENCE: the file content is never injected
|
|
802
|
-
// into the prompt (small files included) — the model reads what it needs
|
|
803
|
-
// with its own read tool (built-in truncation/pagination).
|
|
804
|
-
// Line-range mode adds the `lines` attribute so the model knows which
|
|
805
|
-
// slice the user picked and only reads that part.
|
|
806
|
-
// A legacy `mode: "inline"` (old client / persisted draft) lands here too.
|
|
807
716
|
if (att.mode === "lines") {
|
|
808
717
|
const range = att.lines;
|
|
809
718
|
if (!range || range.start < 1 || range.end < range.start) {
|
|
@@ -843,10 +752,6 @@ ${transcript}
|
|
|
843
752
|
}
|
|
844
753
|
return out;
|
|
845
754
|
}
|
|
846
|
-
/**
|
|
847
|
-
* 判断一个会话 entry 是否是提问前置注入的 aside 卡片(附件/并行提醒等)。
|
|
848
|
-
* 这些消息由服务端的 prompt 前置阶段通过 sendCustomMessage 注入在用户提问消息之前。
|
|
849
|
-
*/
|
|
850
755
|
export function isPromptAsideEntry(entry) {
|
|
851
756
|
if (!entry || typeof entry !== "object")
|
|
852
757
|
return false;
|
|
@@ -855,19 +760,12 @@ export function isPromptAsideEntry(entry) {
|
|
|
855
760
|
return ((e.type === "custom_message" || (e.type === "message" && e.message?.role === "custom")) &&
|
|
856
761
|
(customType === "file" || customType === "parallel-work-reminder"));
|
|
857
762
|
}
|
|
858
|
-
/**
|
|
859
|
-
* 判断一个 entry 是否为用户提问消息。
|
|
860
|
-
*/
|
|
861
763
|
export function isUserMessageEntry(entry) {
|
|
862
764
|
if (!entry || typeof entry !== "object")
|
|
863
765
|
return false;
|
|
864
766
|
const e = entry;
|
|
865
767
|
return (e.type === "message" && e.message?.role === "user") || e.type === "user" || e.role === "user";
|
|
866
768
|
}
|
|
867
|
-
/**
|
|
868
|
-
* 判断一个 entry 是否为上一轮对话结束时的有效业务节点
|
|
869
|
-
* (例如助手回复、工具返回、bash 执行、分支或压缩摘要,或者更早一轮的用户提问)。
|
|
870
|
-
*/
|
|
871
769
|
export function isConversationTurnEntry(entry) {
|
|
872
770
|
if (!entry || typeof entry !== "object")
|
|
873
771
|
return false;
|
|
@@ -885,17 +783,10 @@ export function isConversationTurnEntry(entry) {
|
|
|
885
783
|
}
|
|
886
784
|
return false;
|
|
887
785
|
}
|
|
888
|
-
/**
|
|
889
|
-
* 从给定的 entry 节点开始,向上追溯跳过属于该轮提问的前置附件 aside 节点(customType === "file" 等)、
|
|
890
|
-
* SDK 注入的系统截面(role === "system")以及配置变更节点,
|
|
891
|
-
* 返回该轮提问之前的基准 entry id(作为 fork/分支截断点)。
|
|
892
|
-
* 如果追溯到会话根(即该提问是会话第一轮提问),返回 null。
|
|
893
|
-
*/
|
|
894
786
|
export function findTurnBaseEntryId(sm, entryId) {
|
|
895
787
|
const target = sm.getEntry(entryId);
|
|
896
788
|
if (!target)
|
|
897
789
|
return null;
|
|
898
|
-
// 只有针对用户消息,才需要向上跳过属于该提问的前置附件 aside 卡片和系统截面
|
|
899
790
|
if (!isUserMessageEntry(target)) {
|
|
900
791
|
const parentId = target.parentId;
|
|
901
792
|
return parentId ?? null;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/** True when the browser connection is TLS: direct (`socket.encrypted`,
|
|
2
|
-
* express `req.secure`) or via a TLS-terminating proxy (`x-forwarded-proto`
|
|
3
|
-
* / RFC 7239 `forwarded`). */
|
|
4
1
|
export function isTlsRequest(req) {
|
|
5
2
|
if (req.socket?.encrypted)
|
|
6
3
|
return true;
|
|
@@ -16,27 +13,9 @@ export function isTlsRequest(req) {
|
|
|
16
13
|
return true;
|
|
17
14
|
return false;
|
|
18
15
|
}
|
|
19
|
-
/** Build the `Set-Cookie` value for `pi_web_token`. `encodedValue` is already
|
|
20
|
-
* `encodeURIComponent`'d (or `""` when clearing). */
|
|
21
16
|
export function buildPiWebTokenCookie(encodedValue, maxAge, secure) {
|
|
22
17
|
return `pi_web_token=${encodedValue}; Path=/; HttpOnly; SameSite=Strict; Max-Age=${maxAge}${secure ? "; Secure" : ""}`;
|
|
23
18
|
}
|
|
24
|
-
/**
|
|
25
|
-
* `pi_web_token` cookie 值 → 原始口令。
|
|
26
|
-
*
|
|
27
|
-
* 下发时按 `encodeURIComponent` 编码(RFC 6265 的 cookie-value 只允许 ASCII,
|
|
28
|
-
* `=` / `+` / 空格 / 非 ASCII 都必须转义),所以**比对前必须先解码** —— 否则
|
|
29
|
-
* 含这些字符的口令永远匹配不上,表现为「`?token=` 那一次 200,之后所有资源与
|
|
30
|
-
* WS 全 401」(issue #261:base64 口令尾巴上的 `=` 被存成 `%3D`,服务端却拿
|
|
31
|
-
* `%3D` 去和 `=` 比)。
|
|
32
|
-
*
|
|
33
|
-
* 浏览器回来的一定是编码值,但手写 cookie / 旧客户端可能是明文(`=` 在值里
|
|
34
|
-
* 合法,我们按首个 `=` 切分),所以调用方应把「原样」与「解码后」两种候选都
|
|
35
|
-
* 试一遍(见 index.ts 的 requestTokens)。
|
|
36
|
-
*
|
|
37
|
-
* 不是合法百分号编码时原样返回:`decodeURIComponent` 会抛 `URIError`,
|
|
38
|
-
* 而一个手写的脏 cookie 绝不该把请求打成 500。
|
|
39
|
-
*/
|
|
40
19
|
export function decodeCookieToken(raw) {
|
|
41
20
|
if (!raw)
|
|
42
21
|
return "";
|
package/dist/server/bash-tool.js
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* bash-tool — bash 工具的原生可中断版本与动态终端分流版本。
|
|
3
|
-
*
|
|
4
|
-
* - makeKillableBashTool: 包装 SDK 原生进程版 bash,带 AbortController 集合与 head/tail 后处理。
|
|
5
|
-
* - makeAdaptiveBashTool: 根据用户设置在进程版与可见终端版之间动态分流执行。
|
|
6
|
-
*
|
|
7
|
-
* 从 agent-service.ts 抽出为独立模块。
|
|
8
|
-
*/
|
|
9
1
|
import { createBashToolDefinition, createLocalBashOperations, } from "@earendil-works/pi-coding-agent";
|
|
10
2
|
import { applyHeadTail } from "./terminals.js";
|
|
11
3
|
import { BASH_DESCRIPTION, BASH_PARAMETERS, BASH_PROMPT_GUIDELINES, BASH_PROMPT_SNIPPET } from "./tool-prompts.js";
|
|
12
4
|
import { getGlobalRemoteSshService, isRemoteWorkspaceUri, restoreWorkspaceUriFromSessionDir, } from "./remote-ssh-service.js";
|
|
13
|
-
|
|
14
|
-
* Killable bash tool: wraps the SDK bash tool (native process spawn, NO terminal).
|
|
15
|
-
* Used when the「默认 bash 覆盖」setting is OFF. Registers its own AbortController
|
|
16
|
-
* into a client-level set (kills) so abortBash() kills only these commands while the
|
|
17
|
-
* agent run and the conversation continue. Exposes persist (ignored — native has no
|
|
18
|
-
* terminal) plus head/tail (post-processed on the returned output) so the parameter
|
|
19
|
-
* schema stays consistent with the terminal-backed tool.
|
|
20
|
-
*/
|
|
21
|
-
export function makeKillableBashTool(cwd, kills,
|
|
22
|
-
/** per-call 返回文本的服务端语言(默认英文);工具 definition 为纯英文。 */
|
|
23
|
-
lang = () => "en") {
|
|
5
|
+
export function makeKillableBashTool(cwd, kills, lang = () => "en") {
|
|
24
6
|
const base = createLocalBashOperations();
|
|
25
7
|
const tool = createBashToolDefinition(cwd, {
|
|
26
8
|
operations: {
|
|
@@ -57,7 +39,6 @@ lang = () => "en") {
|
|
|
57
39
|
},
|
|
58
40
|
},
|
|
59
41
|
});
|
|
60
|
-
// Keep the SDK definition so execute receives the current session context.
|
|
61
42
|
return {
|
|
62
43
|
name: tool.name,
|
|
63
44
|
label: tool.label,
|
|
@@ -69,7 +50,6 @@ lang = () => "en") {
|
|
|
69
50
|
executionMode: tool.executionMode,
|
|
70
51
|
execute: async (toolCallId, params, signal, onUpdate, ctx) => {
|
|
71
52
|
const result = (await tool.execute(toolCallId, params, signal, onUpdate, ctx));
|
|
72
|
-
// head/tail 后处理(native 无终端,直接截返回行即可)。
|
|
73
53
|
const p = params;
|
|
74
54
|
if ((p?.head || p?.tail) && result?.content?.[0]?.text != null) {
|
|
75
55
|
result.content[0].text = applyHeadTail(result.content[0].text, p.head, p.tail, lang());
|
|
@@ -78,22 +58,11 @@ lang = () => "en") {
|
|
|
78
58
|
},
|
|
79
59
|
};
|
|
80
60
|
}
|
|
81
|
-
/**
|
|
82
|
-
* 动态分流 bash:按「默认 bash 覆盖」设置(terminalBash)在调用时决定走哪套——
|
|
83
|
-
* 关 = 原生 SDK bash(纯进程、不开终端);开 = 终端接管 bash(persist 决定一次性/
|
|
84
|
-
* 持久)。开关因此即时生效(customTools 固定于 runtime 创建,不能在创建时二选一)。
|
|
85
|
-
*
|
|
86
|
-
* 提示词不在此覆盖:两条路径共用 server/tool-prompts.ts 的那一份(单源),
|
|
87
|
-
* 覆盖 description 正是当年终端版文案被写死却不生效的成因。
|
|
88
|
-
*/
|
|
89
61
|
export function makeAdaptiveBashTool(killable, terminalBacked, useTerminal) {
|
|
90
62
|
return {
|
|
91
63
|
...killable,
|
|
92
64
|
execute: (id, params, signal, onUpdate, ctx) => {
|
|
93
65
|
const p = params;
|
|
94
|
-
// Windows 下 ConPTY 架构限制(MSYS2 全局控制台上限 128,且高频创建销毁容易句柄耗尽/卡顿):
|
|
95
|
-
// 一次性命令(persist !== true)走原生 spawn(基于 pipe,无需分配控制台,速度快 60 倍且免死锁,issue #269);
|
|
96
|
-
// 只有明确需要持久交互(persist === true)才进可见终端 ai-bash。
|
|
97
66
|
const shouldUseTerminal = useTerminal() && (process.platform !== "win32" || p?.persist === true);
|
|
98
67
|
return (shouldUseTerminal ? terminalBacked : killable).execute(id, params, signal, onUpdate, ctx);
|
|
99
68
|
},
|