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
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fork-free executable lookup for Android/Termux.
|
|
3
|
-
*
|
|
4
|
-
* Background: on POSIX the SDK resolves host executables with `spawnSync("which", …)`
|
|
5
|
-
* (`dist/utils/shell.js`) and probes availability with `spawnSync(cmd, ["--version"])`
|
|
6
|
-
* (`dist/utils/tools-manager.js`). On Android/Termux forking a child process can stall
|
|
7
|
-
* before it ever execs, so those probes never return and the first tool call hangs the
|
|
8
|
-
* server instead of failing fast. Both are pure lookups, so this patch answers them from
|
|
9
|
-
* PATH — no child process involved.
|
|
10
|
-
*
|
|
11
|
-
* The SDK sources are transformed in memory before compilation, never on disk (same seam
|
|
12
|
-
* as `server/patch-bash-process.ts`). The patch therefore survives every
|
|
13
|
-
* `npm i -g @earendil-works/pi-coding-agent` and applies to whichever copy
|
|
14
|
-
* `resolve-global-sdk.ts` picks. Drop this module once the SDK resolves executables from
|
|
15
|
-
* PATH itself.
|
|
16
|
-
*
|
|
17
|
-
* Two properties matter more than brevity here:
|
|
18
|
-
*
|
|
19
|
-
* 1. The replacement never relies on a binding that happens to exist in the SDK version
|
|
20
|
-
* at hand — it carries its own imports (`PREAMBLE`). Otherwise a version whose module
|
|
21
|
-
* header differs (SDK 1.1.0 has no `shellPathExists`) throws a ReferenceError that the
|
|
22
|
-
* surrounding `catch` swallows, and the hook reports `patched` while shell discovery
|
|
23
|
-
* silently falls back to `sh`.
|
|
24
|
-
* 2. It keeps the *semantics* of executable lookup: an entry only counts when it is a
|
|
25
|
-
* real file we may execute — not a directory and not an inert file. Existence alone
|
|
26
|
-
* made `ensureTool` claim a tool it could not spawn (`ENOENT` right after).
|
|
27
|
-
*/
|
|
28
1
|
import { registerHooks } from "node:module";
|
|
29
2
|
export const SENTINEL = "// pi-web-ui #810: fork-free executable lookup v1";
|
|
30
3
|
export const PREAMBLE_START = "/* pi-web-ui #810: fork-free executable lookup v1 (preamble) */";
|
|
@@ -33,11 +6,6 @@ const TARGETS = {
|
|
|
33
6
|
shell: "/@earendil-works/pi-coding-agent/dist/utils/shell.js",
|
|
34
7
|
"tools-manager": "/@earendil-works/pi-coding-agent/dist/utils/tools-manager.js",
|
|
35
8
|
};
|
|
36
|
-
/**
|
|
37
|
-
* Self-contained definitions the replacement uses, injected ahead of the SDK source.
|
|
38
|
-
* Aliased names cannot collide with the SDK's own imports, so this works for every
|
|
39
|
-
* module header — including the shapes that predate `shellPathExists`.
|
|
40
|
-
*/
|
|
41
9
|
export const PREAMBLE = `${PREAMBLE_START}
|
|
42
10
|
import {
|
|
43
11
|
accessSync as __piWebExecAccess,
|
|
@@ -75,7 +43,6 @@ function __piWebExecProgram(candidate) {
|
|
|
75
43
|
}
|
|
76
44
|
}
|
|
77
45
|
${PREAMBLE_END}`;
|
|
78
|
-
/** SDK 1.4.0 shape: `which` child process in the POSIX branch of findExecutableOnPath. */
|
|
79
46
|
const SHELL_LOOKUP_OLD = ` // Unix: Use 'which' and trust its output (handles Termux and special filesystems)
|
|
80
47
|
try {
|
|
81
48
|
const result = spawnSync("which", [executable], { encoding: "utf-8", timeout: 5000 });
|
|
@@ -89,7 +56,6 @@ const SHELL_LOOKUP_OLD = ` // Unix: Use 'which' and trust its output (handles
|
|
|
89
56
|
catch {
|
|
90
57
|
// Ignore errors
|
|
91
58
|
}`;
|
|
92
|
-
/** SDK 1.4.0 shape: `--version` child process probe in commandExists. */
|
|
93
59
|
const TOOLS_LOOKUP_OLD = `function commandExists(cmd) {
|
|
94
60
|
try {
|
|
95
61
|
const result = spawnSync(cmd, ["--version"], { stdio: "pipe" });
|
|
@@ -132,7 +98,6 @@ const TOOLS_LOOKUP_NEW = `function commandExists(cmd) {
|
|
|
132
98
|
return false;
|
|
133
99
|
}
|
|
134
100
|
}`;
|
|
135
|
-
/** Which target a loaded module URL belongs to, or null when it is not ours to touch. */
|
|
136
101
|
export function executableLookupTarget(url) {
|
|
137
102
|
const normalized = url.replaceAll("\\\\", "/");
|
|
138
103
|
for (const [target, suffix] of Object.entries(TARGETS)) {
|
|
@@ -145,11 +110,8 @@ const ANCHORS = {
|
|
|
145
110
|
shell: "function findExecutableOnPath",
|
|
146
111
|
"tools-manager": "function commandExists",
|
|
147
112
|
};
|
|
148
|
-
/** Any child process a lookup could still be forking through, however it is spelled. */
|
|
149
113
|
const FORKING_CALL = /\b(?:spawnSync|execSync|execFileSync)\s*\(/;
|
|
150
|
-
/** 在这些字符之后出现的 `/` 是正则字面量的开头,而不是除号。 */
|
|
151
114
|
const REGEX_PREFIX_CHARS = new Set("(,=:[!&|?{};+-*%<>~^".split(""));
|
|
152
|
-
/** 这些关键字之后同理(`return /…/` vs `a / b`)。 */
|
|
153
115
|
const REGEX_PREFIX_WORDS = new Set([
|
|
154
116
|
"return",
|
|
155
117
|
"typeof",
|
|
@@ -166,7 +128,6 @@ const REGEX_PREFIX_WORDS = new Set([
|
|
|
166
128
|
"yield",
|
|
167
129
|
"await",
|
|
168
130
|
]);
|
|
169
|
-
/** `/` 在这里是正则字面量而不是除号(只看前一个 token)。 */
|
|
170
131
|
function isRegexStart(source, i) {
|
|
171
132
|
let j = i - 1;
|
|
172
133
|
while (j >= 0 && /\s/.test(source[j]))
|
|
@@ -182,13 +143,6 @@ function isRegexStart(source, i) {
|
|
|
182
143
|
k--;
|
|
183
144
|
return REGEX_PREFIX_WORDS.has(source.slice(k + 1, j + 1));
|
|
184
145
|
}
|
|
185
|
-
/**
|
|
186
|
-
* `}` / `{` 在正则字面量里不是括号。不认正则的话,`/^}$/` 这种只带一个右花括号的
|
|
187
|
-
* 字面量会把深度算错:接着那个嵌套块自己的 `}` 就被当成「函数结束」,于是后面的
|
|
188
|
-
* `spawnSync` 落在被截断的 body 之外,已经打过叉的源码会被判成 `already` —— 正是
|
|
189
|
-
* 上游改写后最危险的那种误判(Android 上依然会卡死,却不报警)。
|
|
190
|
-
* 解析错方向的代价很低:误把代码当成字符串只会让 body 取不出来 → `unsupported`。
|
|
191
|
-
*/
|
|
192
146
|
function skipRegex(source, i) {
|
|
193
147
|
let inClass = false;
|
|
194
148
|
for (let j = i + 1; j < source.length; j++) {
|
|
@@ -197,7 +151,6 @@ function skipRegex(source, i) {
|
|
|
197
151
|
j++;
|
|
198
152
|
continue;
|
|
199
153
|
}
|
|
200
|
-
// 正则字面量不跨行:跑到行尾说明这是个除号,交给调用方按代码处理。
|
|
201
154
|
if (char === "\n")
|
|
202
155
|
return null;
|
|
203
156
|
if (inClass) {
|
|
@@ -212,7 +165,6 @@ function skipRegex(source, i) {
|
|
|
212
165
|
}
|
|
213
166
|
return null;
|
|
214
167
|
}
|
|
215
|
-
/** Index just past the comment or quoted literal starting at `i`, or null when it is code. */
|
|
216
168
|
function skipNonCode(source, i) {
|
|
217
169
|
const char = source[i];
|
|
218
170
|
if (char === "/" && source[i + 1] === "/") {
|
|
@@ -236,10 +188,6 @@ function skipNonCode(source, i) {
|
|
|
236
188
|
}
|
|
237
189
|
return null;
|
|
238
190
|
}
|
|
239
|
-
/**
|
|
240
|
-
* Body of the function starting at `anchor`, or null when it is not there.
|
|
241
|
-
* Skips comments and string/template contents so braces inside them cannot unbalance it.
|
|
242
|
-
*/
|
|
243
191
|
export function functionBody(source, anchor) {
|
|
244
192
|
const start = source.indexOf(anchor);
|
|
245
193
|
if (start < 0)
|
|
@@ -258,9 +206,6 @@ export function functionBody(source, anchor) {
|
|
|
258
206
|
if (char === "{")
|
|
259
207
|
depth++;
|
|
260
208
|
else if (char === "}") {
|
|
261
|
-
// Only a brace that ends the line can close the function. A `}` inside a regex
|
|
262
|
-
// literal sits mid-statement, and treating it as the end would truncate the body —
|
|
263
|
-
// hiding a child process that comes later and reporting the lookup as fixed.
|
|
264
209
|
if (depth === 1) {
|
|
265
210
|
if (isStatementEnd(source, i + 1))
|
|
266
211
|
return source.slice(open, i + 1);
|
|
@@ -271,7 +216,6 @@ export function functionBody(source, anchor) {
|
|
|
271
216
|
}
|
|
272
217
|
return null;
|
|
273
218
|
}
|
|
274
|
-
/** Index of the `}` matching the `{` at `open`, or null when the block is unbalanced. */
|
|
275
219
|
function bracedBlockEnd(source, open) {
|
|
276
220
|
let depth = 0;
|
|
277
221
|
for (let i = open; i < source.length; i++) {
|
|
@@ -287,12 +231,6 @@ function bracedBlockEnd(source, open) {
|
|
|
287
231
|
}
|
|
288
232
|
return null;
|
|
289
233
|
}
|
|
290
|
-
/**
|
|
291
|
-
* What actually runs on POSIX: the body without the `if (process.platform === "win32")`
|
|
292
|
-
* early return. The shell lookup keeps a `where` child process in that branch on every SDK
|
|
293
|
-
* version, and it never runs on Android/Termux — counting it as a fork would report a
|
|
294
|
-
* fork-free POSIX lookup as unrecognized and warn on every start.
|
|
295
|
-
*/
|
|
296
234
|
export function posixPortion(body) {
|
|
297
235
|
const guard = body.search(/if \(process\.platform === "win32"\)\s*\{/);
|
|
298
236
|
if (guard < 0)
|
|
@@ -303,16 +241,9 @@ export function posixPortion(body) {
|
|
|
303
241
|
return body;
|
|
304
242
|
return body.slice(0, guard) + body.slice(close + 1).replace(/^\s*return null;\s*/, "");
|
|
305
243
|
}
|
|
306
|
-
/** Whitespace (and an optional `;`) up to the end of the line — a statement boundary. */
|
|
307
244
|
function isStatementEnd(source, at) {
|
|
308
245
|
return /^[ \t]*;?[ \t]*(?:\r?\n|$)/.test(source.slice(at, at + 8));
|
|
309
246
|
}
|
|
310
|
-
/**
|
|
311
|
-
* A lookup counts as already fork-free only when that is positively identifiable:
|
|
312
|
-
* the function is still there, it scans `process.env.PATH`, and it forks nothing.
|
|
313
|
-
* Anything else — a reformatted probe, an unknown rewrite — stays `unsupported`, so an
|
|
314
|
-
* unrecognized SDK never gets reported as fixed while the probe is still in the way.
|
|
315
|
-
*/
|
|
316
247
|
function isForkFreeLookup(source, anchor) {
|
|
317
248
|
const body = functionBody(source, anchor);
|
|
318
249
|
if (body === null)
|
|
@@ -325,8 +256,6 @@ export function patchExecutableLookupSource(source, target) {
|
|
|
325
256
|
return { code: source, status: "already" };
|
|
326
257
|
const old = target === "shell" ? SHELL_LOOKUP_OLD : TOOLS_LOOKUP_OLD;
|
|
327
258
|
const replacement = target === "shell" ? SHELL_LOOKUP_NEW : TOOLS_LOOKUP_NEW;
|
|
328
|
-
// Exact, single occurrence: a moved or rewritten lookup must fail loudly, never
|
|
329
|
-
// half-apply, because the alternative is a silently hanging server.
|
|
330
259
|
if (source.split(old).length !== 2) {
|
|
331
260
|
return { code: source, status: isForkFreeLookup(source, ANCHORS[target]) ? "already" : "unsupported" };
|
|
332
261
|
}
|
|
@@ -335,7 +264,6 @@ export function patchExecutableLookupSource(source, target) {
|
|
|
335
264
|
const LOG_PREFIX = "[executable-lookup]";
|
|
336
265
|
const OPT_OUT = new Set(["off", "0", "false", "no"]);
|
|
337
266
|
const OPT_IN = new Set(["on", "1", "true", "yes"]);
|
|
338
|
-
/** Android/Termux only by default; `PI_WEB_EXEC_LOOKUP=off` opts out, `=on` forces. */
|
|
339
267
|
export function shouldPatchExecutableLookup(platform = process.platform, env = process.env) {
|
|
340
268
|
const flag = (env.PI_WEB_EXEC_LOOKUP ?? "").trim().toLowerCase();
|
|
341
269
|
if (OPT_OUT.has(flag))
|
|
@@ -344,7 +272,6 @@ export function shouldPatchExecutableLookup(platform = process.platform, env = p
|
|
|
344
272
|
return true;
|
|
345
273
|
return platform === "android" || Boolean(env.TERMUX_VERSION);
|
|
346
274
|
}
|
|
347
|
-
/** Logged once per target, so every restart states whether the patch is really in place. */
|
|
348
275
|
export function describeLookupResult(target, status, url) {
|
|
349
276
|
if (status === "unsupported")
|
|
350
277
|
return {
|
|
@@ -361,11 +288,9 @@ function report(target, status, url) {
|
|
|
361
288
|
else
|
|
362
289
|
console.log(message);
|
|
363
290
|
}
|
|
364
|
-
/** Only ES modules can take the preamble; everything else keeps the SDK's own lookup. */
|
|
365
291
|
export function isPatchableFormat(format) {
|
|
366
292
|
return format === "module" || format === "module-typescript";
|
|
367
293
|
}
|
|
368
|
-
/* SDK sources are transformed in memory before compilation, never on disk. */
|
|
369
294
|
export function registerExecutableLookupPatch(platform = process.platform, env = process.env) {
|
|
370
295
|
if (!shouldPatchExecutableLookup(platform, env))
|
|
371
296
|
return;
|
|
@@ -380,8 +305,6 @@ export function registerExecutableLookupPatch(platform = process.platform, env =
|
|
|
380
305
|
const loaded = nextLoad(url, context);
|
|
381
306
|
if (loaded.source == null)
|
|
382
307
|
return loaded;
|
|
383
|
-
// The preamble is an ES module head; injecting it into CommonJS would break the
|
|
384
|
-
// load instead of falling back to the lookup we were trying to improve.
|
|
385
308
|
if (!isPatchableFormat(loaded.format)) {
|
|
386
309
|
console.warn(`${LOG_PREFIX} ${target}: NOT patched — loaded as ${loaded.format ?? "an unknown format"}, ` +
|
|
387
310
|
`the patch only rewrites ES modules (${url})`);
|
|
@@ -1,48 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* node-pty × Node `--watch` compatibility patches (dev-server noise).
|
|
3
|
-
*
|
|
4
|
-
* Node's `--watch` mode (the dev script runs `node --watch --import tsx`)
|
|
5
|
-
* pushes `watch:require` / `watch:import` messages over the IPC channels of
|
|
6
|
-
* spawned worker threads AND forked child processes to track module
|
|
7
|
-
* dependencies. node-pty 1.1.0 does not recognize these and mishandles them in
|
|
8
|
-
* two places:
|
|
9
|
-
*
|
|
10
|
-
* · windowsConoutConnection.js — logs every unknown worker message via
|
|
11
|
-
* `console.warn`, producing hundreds of "Unexpected ConoutWorkerMessage"
|
|
12
|
-
* lines per terminal (the SCM panel's hidden query PTY triggers it on every
|
|
13
|
-
* git-view open).
|
|
14
|
-
* · windowsPtyAgent.js — the kill path's `_getConsoleProcessList()` treats ANY
|
|
15
|
-
* message from the forked console-list agent as its reply; a watch message
|
|
16
|
-
* has no `consoleProcessList` property, so `message.consoleProcessList` is
|
|
17
|
-
* undefined and the `.forEach` on it crashes the server.
|
|
18
|
-
*
|
|
19
|
-
* Both are benign protocol noise: the ConPTY worker only ever sends its READY
|
|
20
|
-
* sentinel and the agent only sends `{ consoleProcessList }` — both of which
|
|
21
|
-
* node-pty handles. These patches make node-pty ignore unrelated IPC traffic.
|
|
22
|
-
*
|
|
23
|
-
* IMPORTANT: this module MUST be imported before node-pty (see terminals.ts) —
|
|
24
|
-
* it rewrites the installed copies on disk so the subsequently-compiled
|
|
25
|
-
* node-pty modules contain the fixed handlers. Best-effort and idempotent
|
|
26
|
-
* (checks before rewriting), mirroring the spawn-helper chmod self-heal; a
|
|
27
|
-
* read-only node_modules or a different node-pty version just skips the patch
|
|
28
|
-
* (the runtime console.warn filter in terminals.ts still guards the flood).
|
|
29
|
-
*/
|
|
30
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
31
2
|
import { writeAtomicSync } from "./atomic-file.js";
|
|
32
3
|
import { createRequire } from "node:module";
|
|
33
4
|
import { dirname, join } from "node:path";
|
|
34
5
|
const require = createRequire(import.meta.url);
|
|
35
|
-
/** Absolute path of the installed node-pty package root, or null. */
|
|
36
6
|
function ptyPackageDir() {
|
|
37
7
|
try {
|
|
38
|
-
// require.resolve("node-pty") → <pkg>/lib/index.js → package root is two up.
|
|
39
8
|
return dirname(dirname(require.resolve("node-pty")));
|
|
40
9
|
}
|
|
41
10
|
catch {
|
|
42
11
|
return null;
|
|
43
12
|
}
|
|
44
13
|
}
|
|
45
|
-
/** Idempotently replace one code fragment in a node-pty source file. */
|
|
46
14
|
function patchFile(pkgDir, rel, find, replace) {
|
|
47
15
|
try {
|
|
48
16
|
const file = join(pkgDir, rel);
|
|
@@ -50,24 +18,18 @@ function patchFile(pkgDir, rel, find, replace) {
|
|
|
50
18
|
return;
|
|
51
19
|
const src = readFileSync(file, "utf8");
|
|
52
20
|
if (src.includes(replace))
|
|
53
|
-
return;
|
|
21
|
+
return;
|
|
54
22
|
if (!src.includes(find))
|
|
55
|
-
return;
|
|
23
|
+
return;
|
|
56
24
|
writeAtomicSync(file, src.replace(find, replace));
|
|
57
25
|
}
|
|
58
|
-
catch {
|
|
59
|
-
// best-effort — the runtime console.warn filter still guards the flood
|
|
60
|
-
}
|
|
26
|
+
catch { }
|
|
61
27
|
}
|
|
62
28
|
function applyPatches() {
|
|
63
29
|
const pkgDir = ptyPackageDir();
|
|
64
30
|
if (!pkgDir)
|
|
65
31
|
return;
|
|
66
|
-
// 1. ConoutConnection: ignore unknown worker messages instead of warning.
|
|
67
32
|
patchFile(pkgDir, "lib/windowsConoutConnection.js", "console.warn('Unexpected ConoutWorkerMessage', message);", "break; // pi-web-ui: ignore Node --watch worker messages");
|
|
68
|
-
// 2. windowsPtyAgent kill path: only accept a real console-list reply
|
|
69
|
-
// (watch messages arrive first on the fork channel and carry no
|
|
70
|
-
// consoleProcessList — previously resolved undefined and crashed).
|
|
71
33
|
patchFile(pkgDir, "lib/windowsPtyAgent.js", "agent.on('message', function (message) {\n clearTimeout(timeout);\n resolve(message.consoleProcessList);\n });", [
|
|
72
34
|
" agent.on('message', function (message) {",
|
|
73
35
|
" // pi-web-ui: ignore Node --watch messages on the fork channel",
|
|
@@ -77,8 +39,6 @@ function applyPatches() {
|
|
|
77
39
|
" }",
|
|
78
40
|
" });",
|
|
79
41
|
].join("\n"));
|
|
80
|
-
// 3. conpty_console_list_agent: tolerate dead shell PID (AttachConsole failed)
|
|
81
|
-
// when process already exited or was killed — return [] instead of crashing.
|
|
82
42
|
patchFile(pkgDir, "lib/conpty_console_list_agent.js", "var consoleProcessList = getConsoleProcessList(shellPid);\nprocess.send({ consoleProcessList: consoleProcessList });\nprocess.exit(0);", [
|
|
83
43
|
"try {",
|
|
84
44
|
" var consoleProcessList = getConsoleProcessList(shellPid);",
|
|
@@ -1,38 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote-catalog merge patch for @earendil-works/pi-coding-agent.
|
|
3
|
-
*
|
|
4
|
-
* The SDK composes each built-in provider's model list as
|
|
5
|
-
* mergeModels(builtinStaticCatalog, pi.devRemoteCatalog)
|
|
6
|
-
* which is a UNION: same-id entries get replaced by the newer pi.dev row, new
|
|
7
|
-
* ids are appended, but stale built-in models are kept forever (and the UI
|
|
8
|
-
* reports "新增 N 个模型" when the overlay grows).
|
|
9
|
-
*
|
|
10
|
-
* pi-web-ui wants the picker to mirror the OFFICIAL remote catalog exactly —
|
|
11
|
-
* an "ensure latest, no merge, no 'new N' noise" behavior. This module rewrites
|
|
12
|
-
* the installed copy of remote-catalog-provider.js so the remote overlay
|
|
13
|
-
* REPLACES the built-in catalog entirely whenever pi.dev data is present:
|
|
14
|
-
* getModels: () => (dynamicModels.length > 0 ? dynamicModels : provider.getModels())
|
|
15
|
-
* (the built-in catalog only serves as fallback while no remote data has been
|
|
16
|
-
* received yet, so the list can never be empty).
|
|
17
|
-
*
|
|
18
|
-
* Same pattern as patch-node-pty.ts: idempotent (checks before rewriting),
|
|
19
|
-
* best-effort (a read-only node_modules or an SDK version whose source no
|
|
20
|
-
* longer matches the search strings just skips the patch and keeps the SDK's
|
|
21
|
-
* default union semantics — never a crash). MUST be imported before the SDK
|
|
22
|
-
* modules are first loaded (agent-service.ts imports this first).
|
|
23
|
-
*/
|
|
24
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
25
2
|
import { writeAtomicSync } from "./atomic-file.js";
|
|
26
3
|
import { fileURLToPath } from "node:url";
|
|
27
4
|
import { dirname, join } from "node:path";
|
|
28
|
-
/** Supported patch pairs across SDK versions (0.87.x, 1.1.0+). */
|
|
29
5
|
const PATCH_PAIRS = [
|
|
30
|
-
// SDK 0.87.x
|
|
31
6
|
{
|
|
32
7
|
old: "getModels: () => mergeModels(provider.getModels(), dynamicModels),",
|
|
33
8
|
new: "getModels: () => (dynamicModels.length > 0 ? dynamicModels : provider.getModels()),",
|
|
34
9
|
},
|
|
35
|
-
// SDK 1.1.0+ (typed model shards: chat, image, classifier)
|
|
36
10
|
{
|
|
37
11
|
old: 'getModels: () => mergeModels(provider.getModels(), dynamicModels.filter((model) => isModelType(model, "chat"))),',
|
|
38
12
|
new: 'getModels: () => (dynamicModels.length > 0 ? dynamicModels.filter((model) => isModelType(model, "chat")) : provider.getModels()),',
|
|
@@ -42,11 +16,8 @@ const PATCH_PAIRS = [
|
|
|
42
16
|
new: "getAllModels: () => (dynamicModels.length > 0 ? dynamicModels : (provider.getAllModels?.() ?? provider.getModels())),",
|
|
43
17
|
},
|
|
44
18
|
];
|
|
45
|
-
/** Absolute path of the installed remote-catalog-provider.js, or null. */
|
|
46
19
|
function remoteCatalogFile() {
|
|
47
20
|
try {
|
|
48
|
-
// import.meta.resolve honors the package "exports" (import condition) → dist/index.js;
|
|
49
|
-
// remote-catalog-provider.js lives next to it in dist/core/.
|
|
50
21
|
const entry = fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"));
|
|
51
22
|
return join(dirname(entry), "core", "remote-catalog-provider.js");
|
|
52
23
|
}
|
|
@@ -71,8 +42,6 @@ function applyPatch() {
|
|
|
71
42
|
writeAtomicSync(file, src);
|
|
72
43
|
}
|
|
73
44
|
}
|
|
74
|
-
catch {
|
|
75
|
-
// best-effort — without the patch the SDK keeps its default union merge
|
|
76
|
-
}
|
|
45
|
+
catch { }
|
|
77
46
|
}
|
|
78
47
|
applyPatch();
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* patch-tool.ts — 导出给 AI Agent 的结构化补丁工具(Hashline Patch Tool)。
|
|
3
|
-
*
|
|
4
|
-
* 核心设计:
|
|
5
|
-
* - 解决标准 edit 工具容易因缩进幻觉、空白字符或行号漂移导致编辑失败的问题。
|
|
6
|
-
* - 补丁语言基于 [path#TAG] 内容哈希锚点,支持精确行替换(PUT N.=M:)、
|
|
7
|
-
* 语法块级替换(PUT N*:,自动匹配闭合括号/缩进)、行前/后插入(PUT <N: / PUT >N:)、
|
|
8
|
-
* 剪切与寄存器粘贴(CUT / PUT @reg)、文件删除(REM)与重命名(MV)。
|
|
9
|
-
* - 当文件被外部改动导致哈希不一致时,自动尝试 3-Way Merge 冲突自愈。
|
|
10
|
-
*/
|
|
11
1
|
import { resolve } from "node:path";
|
|
12
2
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
13
3
|
import { Type } from "typebox";
|
|
@@ -62,10 +52,6 @@ Success returns the next anchor tag and live LSP diagnostics.`,
|
|
|
62
52
|
details: emptyReport,
|
|
63
53
|
};
|
|
64
54
|
}
|
|
65
|
-
// timeout 此前是死参数:schema 声明了 1-300 秒,execute 从未读取,大补丁
|
|
66
|
-
// 卡住只能等 20 分钟看门狗(issue #462)。这里用 Promise.race 实现真实
|
|
67
|
-
// 超时,覆盖 await 长尾(实时 LSP 诊断等);applyHashlinePatch 是同步
|
|
68
|
-
// 本地文件操作,同步段无法被中断,race 只能兜异步部分。
|
|
69
55
|
const timeoutSec = params.timeout ? Math.min(Math.max(1, params.timeout), 300) : null;
|
|
70
56
|
const finish = async () => {
|
|
71
57
|
const report = applyHashlinePatch(patchText, {
|
|
@@ -84,7 +70,6 @@ Success returns the next anchor tag and live LSP diagnostics.`,
|
|
|
84
70
|
};
|
|
85
71
|
}
|
|
86
72
|
const textOutput = [report.summary];
|
|
87
|
-
// 为成功修改的文件输出最新的头部标签,方便 Agent 连续进行下一步修改
|
|
88
73
|
for (const r of report.results) {
|
|
89
74
|
if (r.op !== "deleted" && r.newHash) {
|
|
90
75
|
const targetPath = r.newPath || r.filePath;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/** Shared upload and WebSocket limits. Keep this module free of runtime dependencies. */
|
|
2
1
|
export const MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
|
|
3
|
-
/** Authenticated report chunks: 16 KiB UTF-8, worst-case JSON escaping plus envelope. */
|
|
4
2
|
export const TASK_REPORT_UPLOAD_JSON_BYTES = 128 * 1024;
|
|
5
3
|
export function normalizeUploadMaxMb(value, fallback) {
|
|
6
4
|
return typeof value === "number" && Number.isFinite(value) ? Math.max(1, Math.min(100, Math.floor(value))) : fallback;
|
|
@@ -9,11 +7,8 @@ export function uploadLimitBytes(settings, kind) {
|
|
|
9
7
|
const defaults = { chat: 20, workspace: 100, folder: 32 };
|
|
10
8
|
return normalizeUploadMaxMb(settings[`${kind}UploadMaxMb`], defaults[kind]) * 1024 * 1024;
|
|
11
9
|
}
|
|
12
|
-
/** Base64 expands each group of up to three bytes into four characters. */
|
|
13
10
|
export const MAX_UPLOAD_BASE64_CHARS = Math.ceil(MAX_UPLOAD_BYTES / 3) * 4;
|
|
14
|
-
/** Base64 payload plus 1MiB for the JSON envelope (paths, names and attachment metadata). */
|
|
15
11
|
export const WS_MAX_PAYLOAD_BYTES = MAX_UPLOAD_BASE64_CHARS + 1024 * 1024;
|
|
16
|
-
/** Reject definitely oversized base64 text before allocating a decoded Buffer. */
|
|
17
12
|
export function isUploadDataTooLong(dataLength, capBytes = MAX_UPLOAD_BYTES) {
|
|
18
13
|
return dataLength > Math.ceil(capBytes / 3) * 4;
|
|
19
14
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
/** A request owns its clock and cancellation; holders may change during takeover. */
|
|
3
2
|
export class PendingQuestion {
|
|
4
3
|
questions;
|
|
5
4
|
id = `q-${randomUUID()}`;
|
|
@@ -34,8 +33,6 @@ export class PendingQuestion {
|
|
|
34
33
|
abort();
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
|
-
/** Independent of legacy onSettled, so holder migration cannot erase other owners' cleanup.
|
|
38
|
-
* Late subscribers run immediately. Returned cleanup only unsubscribes this listener. */
|
|
39
36
|
subscribeSettled(listener) {
|
|
40
37
|
if (this.settled) {
|
|
41
38
|
listener();
|
|
@@ -46,7 +43,6 @@ export class PendingQuestion {
|
|
|
46
43
|
this.settledListeners.delete(listener);
|
|
47
44
|
};
|
|
48
45
|
}
|
|
49
|
-
/** Compatibility alias for integrations using listener naming. */
|
|
50
46
|
addSettledListener(listener) {
|
|
51
47
|
return this.subscribeSettled(listener);
|
|
52
48
|
}
|
|
@@ -62,7 +58,6 @@ export class PendingQuestion {
|
|
|
62
58
|
this.onSettled = undefined;
|
|
63
59
|
const listeners = [...this.settledListeners];
|
|
64
60
|
this.settledListeners.clear();
|
|
65
|
-
// Every owner gets cleanup even if another subscriber throws. Preserve the first error.
|
|
66
61
|
let firstError;
|
|
67
62
|
let failed = false;
|
|
68
63
|
for (const listener of [...listeners, ...(onSettled ? [onSettled] : [])]) {
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 权限预设相关辅助逻辑与会话回放。
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* 从会话 sessionManager entries 回放恢复最后设定的**计划模式**状态(同 permission/preset
|
|
6
|
-
* 的落盘口径:切会话/重载不丢)。从未设定或非布尔 → false。
|
|
7
|
-
*/
|
|
8
1
|
export function readPlanModeFromSession(sm) {
|
|
9
2
|
try {
|
|
10
3
|
const mgr = sm;
|
|
@@ -17,17 +10,9 @@ export function readPlanModeFromSession(sm) {
|
|
|
17
10
|
return e.data.enabled;
|
|
18
11
|
}
|
|
19
12
|
}
|
|
20
|
-
catch {
|
|
21
|
-
// ignore
|
|
22
|
-
}
|
|
13
|
+
catch { }
|
|
23
14
|
return false;
|
|
24
15
|
}
|
|
25
|
-
/**
|
|
26
|
-
* 从会话 sessionManager entries 回放恢复最后设定的**审查者模式**状态(同 plan/mode
|
|
27
|
-
* 口径:customType "delegate/mode")。从未设定或非布尔 → false。
|
|
28
|
-
* ⚠️ 执行对话 id **不回放**:常驻执行对话是本进程内的活对象,重启后
|
|
29
|
-
* 首条请求会重新建一个(宁可多一个执行对话,也别指向一个不存在的 id)。
|
|
30
|
-
*/
|
|
31
16
|
export function readDelegateModeFromSession(sm) {
|
|
32
17
|
try {
|
|
33
18
|
const mgr = sm;
|
|
@@ -40,15 +25,9 @@ export function readDelegateModeFromSession(sm) {
|
|
|
40
25
|
return e.data.enabled;
|
|
41
26
|
}
|
|
42
27
|
}
|
|
43
|
-
catch {
|
|
44
|
-
// ignore
|
|
45
|
-
}
|
|
28
|
+
catch { }
|
|
46
29
|
return false;
|
|
47
30
|
}
|
|
48
|
-
/**
|
|
49
|
-
* 从会话 sessionManager entries 回放恢复最后设定的权限预设(若从未设定则返回 undefined)。
|
|
50
|
-
* customType 为 "permission/preset",载荷结构为 { preset: string }。
|
|
51
|
-
*/
|
|
52
31
|
export function readPermissionFromSession(sm) {
|
|
53
32
|
try {
|
|
54
33
|
const mgr = sm;
|
|
@@ -62,15 +41,9 @@ export function readPermissionFromSession(sm) {
|
|
|
62
41
|
}
|
|
63
42
|
}
|
|
64
43
|
}
|
|
65
|
-
catch {
|
|
66
|
-
// ignore
|
|
67
|
-
}
|
|
44
|
+
catch { }
|
|
68
45
|
return undefined;
|
|
69
46
|
}
|
|
70
|
-
/**
|
|
71
|
-
* 从会话 sessionManager entries 回放恢复最后保存的结构化计划状态。
|
|
72
|
-
* customType 为 "plan/update" 或 "pi-web-ui/plan",载荷结构为 { plan: PlanState }。
|
|
73
|
-
*/
|
|
74
47
|
export function readPlanFromSession(sm) {
|
|
75
48
|
try {
|
|
76
49
|
const mgr = sm;
|
|
@@ -87,8 +60,6 @@ export function readPlanFromSession(sm) {
|
|
|
87
60
|
}
|
|
88
61
|
}
|
|
89
62
|
}
|
|
90
|
-
catch {
|
|
91
|
-
// ignore
|
|
92
|
-
}
|
|
63
|
+
catch { }
|
|
93
64
|
return null;
|
|
94
65
|
}
|
|
@@ -1,25 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* persona-chain — 内联人设注入、扩展提示词包裹剥离与平台人设补丁。
|
|
3
|
-
*
|
|
4
|
-
* 负责:
|
|
5
|
-
* - INLINE_PERSONA_EXT: 自家内联扩展名标识
|
|
6
|
-
* - splitAgentStartPrompt: 剥离先前扩展对 SDK 原始系统提示词的首尾增补
|
|
7
|
-
* - PI_DOC_PATHS: 本地 pi SDK 文档路径发现
|
|
8
|
-
* - WINDOWS_PERSONA: Windows 平台特有人设补丁(超时/非交互 TTY/GBK 编码)
|
|
9
|
-
*
|
|
10
|
-
* 从 agent-service.ts 抽出为独立模块。
|
|
11
|
-
*/
|
|
12
1
|
import { createRequire } from "node:module";
|
|
13
2
|
import { dirname, join } from "node:path";
|
|
14
3
|
import { splitExtensionWrap } from "./prompt-composer.js";
|
|
15
|
-
/** 自家内联扩展名(组合模板渲染,见 prompt-composer.ts)。SDK 以其
|
|
16
|
-
* "<inline:<name>>" 作为 path;扩展白名单/禁用过滤必须放行它。 */
|
|
17
4
|
export const INLINE_PERSONA_EXT = "<inline:pi-webui-persona>";
|
|
18
|
-
/** 本次 run 的 SDK 原始提示词 + 早前扩展的首尾增补(见 splitExtensionWrap)。
|
|
19
|
-
* 导出仅为单测(tests/unit/persona-prompt-chain.test.ts)可达。
|
|
20
|
-
* systemPromptOptions 就是 runner 里那个共享可变对象,forceSystemPrompt 有值即
|
|
21
|
-
* 说明前面有扩展替换过提示词;临时清掉再读 event.systemPrompt 就拿到原始基线
|
|
22
|
-
* (公开字段,不碰 SDK 内部)。没人动过时零开销,直接返回当前文本。 */
|
|
23
5
|
export function splitAgentStartPrompt(event) {
|
|
24
6
|
const current = event.systemPrompt;
|
|
25
7
|
const opts = event.systemPromptOptions;
|
|
@@ -34,7 +16,6 @@ export function splitAgentStartPrompt(event) {
|
|
|
34
16
|
opts.forceSystemPrompt = forced;
|
|
35
17
|
}
|
|
36
18
|
}
|
|
37
|
-
/** Pi 包文档路径(composer 的 {{pi_docs}} 自动内容用)。随安装位置解析一次。 */
|
|
38
19
|
export const PI_DOC_PATHS = (() => {
|
|
39
20
|
try {
|
|
40
21
|
const requireLocal = createRequire(import.meta.url);
|
|
@@ -45,13 +26,6 @@ export const PI_DOC_PATHS = (() => {
|
|
|
45
26
|
return { readme: "", docs: "", examples: "" };
|
|
46
27
|
}
|
|
47
28
|
})();
|
|
48
|
-
/** Windows persona appendix — appended to the SDK system prompt on win32 only.
|
|
49
|
-
* Two failure modes it guards against: (1) the SDK bash tool has NO default
|
|
50
|
-
* timeout, so a long-running command hangs the whole conversation forever;
|
|
51
|
-
* (2) the in-app terminal is an interactive TTY where heredocs / interactive
|
|
52
|
-
* programs wait for input that never comes. Legacy Chinese files are often
|
|
53
|
-
* GBK/GB2312 — read them with the right encoding, never paste mojibake into
|
|
54
|
-
* reasoning/answers. */
|
|
55
29
|
export const WINDOWS_PERSONA = `You are a coding agent running on Windows. The bash tool runs Git Bash (bash.exe), not PowerShell. Follow these rules to avoid hanging the session:
|
|
56
30
|
|
|
57
31
|
|
package/dist/server/pkg-info.js
CHANGED
|
@@ -3,15 +3,6 @@ import { dirname, join, resolve } from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
let cachedPkgRoot = null;
|
|
5
5
|
let cachedAppVersion = null;
|
|
6
|
-
/**
|
|
7
|
-
* 解析 pi-web-ui 包的根目录。
|
|
8
|
-
* 兼容:
|
|
9
|
-
* - 源码开发模式:server/ (tsx)
|
|
10
|
-
* - 源码子模块:server/dsh/ (tsx)
|
|
11
|
-
* - 生产构建模式:dist/server/
|
|
12
|
-
* - 生产构建子模块:dist/server/dsh/
|
|
13
|
-
* - 环境变量显式指定:process.env.PI_WEB_PKG_ROOT
|
|
14
|
-
*/
|
|
15
6
|
export function getPkgRoot(fromUrl = import.meta.url) {
|
|
16
7
|
if (process.env.PI_WEB_PKG_ROOT && existsSync(join(process.env.PI_WEB_PKG_ROOT, "package.json"))) {
|
|
17
8
|
return process.env.PI_WEB_PKG_ROOT;
|
|
@@ -29,16 +20,13 @@ export function getPkgRoot(fromUrl = import.meta.url) {
|
|
|
29
20
|
return dir;
|
|
30
21
|
}
|
|
31
22
|
}
|
|
32
|
-
catch {
|
|
33
|
-
/* ignore */
|
|
34
|
-
}
|
|
23
|
+
catch { }
|
|
35
24
|
}
|
|
36
25
|
const parent = dirname(dir);
|
|
37
26
|
if (parent === dir)
|
|
38
27
|
break;
|
|
39
28
|
dir = parent;
|
|
40
29
|
}
|
|
41
|
-
// Fallback 策略:尝试向上找任意 package.json
|
|
42
30
|
dir = dirname(fileURLToPath(fromUrl));
|
|
43
31
|
const candidates = [resolve(dir, ".."), resolve(dir, "..", ".."), resolve(dir, "..", "..", "..")];
|
|
44
32
|
for (const c of candidates) {
|
|
@@ -50,10 +38,6 @@ export function getPkgRoot(fromUrl = import.meta.url) {
|
|
|
50
38
|
cachedPkgRoot = candidates[0] ?? dir;
|
|
51
39
|
return cachedPkgRoot;
|
|
52
40
|
}
|
|
53
|
-
/**
|
|
54
|
-
* 获取 pi-web-ui 宿主运行时的真实版本号。
|
|
55
|
-
* 若读取失败则 fallback 为 ""。
|
|
56
|
-
*/
|
|
57
41
|
export function getAppVersion(fromUrl = import.meta.url) {
|
|
58
42
|
if (cachedAppVersion !== null)
|
|
59
43
|
return cachedAppVersion;
|