pi-web-ui 0.116.0 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -3
- package/README.md +69 -138
- package/README.zh-CN.md +70 -179
- package/README.zh-TW.md +3 -1
- package/bin/device-hub-cli.mjs +163 -36
- package/bin/frp-manager.mjs +4 -80
- package/bin/hub-upgrade.mjs +561 -0
- package/bin/pi-device-hub.mjs +0 -1
- package/bin/pi-web-ui.mjs +184 -504
- package/deploy/nginx-subpath.conf +0 -33
- package/deploy/pi-web-ui.service +0 -20
- package/dist/server/agent-formatters.js +4 -38
- package/dist/server/agent-service-daemon.js +203 -371
- package/dist/server/agent-service.js +1281 -3030
- package/dist/server/approval-audit.js +2 -23
- package/dist/server/approval-default-rules.js +0 -6
- package/dist/server/approval-rules.js +7 -105
- package/dist/server/ask-user-question-tool.js +1 -12
- package/dist/server/atomic-file.js +33 -5
- package/dist/server/attachment-store.js +0 -36
- package/dist/server/attachments.js +3 -112
- package/dist/server/auth-cookie.js +0 -21
- package/dist/server/bash-tool.js +1 -32
- package/dist/server/bg-servers.js +0 -96
- package/dist/server/browser-page-tool.js +11 -62
- package/dist/server/builtin-modules.js +7 -0
- package/dist/server/canvas/canvas-agent-tool.js +58 -47
- package/dist/server/canvas/canvas-cards.js +0 -14
- package/dist/server/canvas/canvas-dispatch.js +7 -4
- package/dist/server/canvas/canvas-orchestrator.js +167 -181
- package/dist/server/canvas/canvas-runtime-messages.js +30 -0
- package/dist/server/canvas/canvas-scheduled-task.js +0 -3
- package/dist/server/canvas/canvas-scheduler.js +5 -7
- package/dist/server/canvas/canvas-store.js +24 -35
- package/dist/server/canvas/canvas-validation.js +17 -14
- package/dist/server/canvas/canvas-workspace.js +42 -114
- package/dist/server/canvas/pstack-skills-data.js +0 -5
- package/dist/server/claim-files-tool.js +1 -15
- package/dist/server/claim-store.js +5 -49
- package/dist/server/client-id-utils.js +0 -16
- package/dist/server/client-state.js +36 -214
- package/dist/server/communicate-tool.js +0 -3
- package/dist/server/compact-context-tool.js +0 -30
- package/dist/server/compacted-history.js +0 -35
- package/dist/server/compaction-instructions.js +0 -13
- package/dist/server/compaction-markers.js +38 -92
- package/dist/server/compaction-state.js +0 -21
- package/dist/server/composer-drafts.js +0 -34
- package/dist/server/context-budget-runner.js +0 -11
- package/dist/server/context-budget.js +1 -70
- package/dist/server/context-evidence.js +0 -14
- package/dist/server/context-usage.js +0 -12
- package/dist/server/control-socket.js +4 -48
- package/dist/server/conversation-communication.js +0 -10
- package/dist/server/conversation-identity.js +0 -1
- package/dist/server/conversation-read-tool.js +0 -58
- package/dist/server/conversation-tool-names.js +0 -1
- package/dist/server/conversation-tool.js +0 -1
- package/dist/server/conversation-touches.js +4 -75
- package/dist/server/dangling-tools.js +142 -68
- package/dist/server/delegate-mode.js +0 -36
- package/dist/server/delegate-task.js +2 -28
- package/dist/server/device-center/approval-summary.js +0 -1
- package/dist/server/device-center/bot-catalog.js +0 -3
- package/dist/server/device-center/bot-execution.js +48 -9
- package/dist/server/device-center/bot-presets.js +0 -1
- package/dist/server/device-center/bots.js +0 -1
- package/dist/server/device-center/collab-service.js +27 -11
- package/dist/server/device-center/collab-tool.js +393 -27
- package/dist/server/device-center/connector.js +128 -48
- package/dist/server/device-center/delivery-authority.js +95 -0
- package/dist/server/device-center/delivery-subject.js +29 -0
- package/dist/server/device-center/desktop-linux.js +3 -15
- package/dist/server/device-center/desktop-native.js +1 -10
- package/dist/server/device-center/desktop-page.js +2 -3
- package/dist/server/device-center/desktop-setup.js +1 -3
- package/dist/server/device-center/desktop.js +1 -7
- package/dist/server/device-center/device-integration.js +452 -208
- package/dist/server/device-center/device-lan-access.js +403 -0
- package/dist/server/device-center/device-lan.js +484 -0
- package/dist/server/device-center/device-portals.js +0 -3
- package/dist/server/device-center/execution-failure.js +0 -2
- package/dist/server/device-center/execution-guides.js +15 -6
- package/dist/server/device-center/execution-instructions.js +0 -1
- package/dist/server/device-center/execution-settings.js +0 -1
- package/dist/server/device-center/execution-system-prompt.js +0 -3
- package/dist/server/device-center/execution-workspace.js +1 -4
- package/dist/server/device-center/executor.js +46 -31
- package/dist/server/device-center/file-sync-paths.js +0 -5
- package/dist/server/device-center/file-sync.js +0 -10
- package/dist/server/device-center/group-context-delta.js +0 -8
- package/dist/server/device-center/group-context-message.js +0 -14
- package/dist/server/device-center/group-context.js +0 -19
- package/dist/server/device-center/group-events.js +0 -2
- package/dist/server/device-center/group-plan-guard.js +1 -35
- package/dist/server/device-center/group-router-runtime.js +182 -0
- package/dist/server/device-center/group-router-worker.js +178 -0
- package/dist/server/device-center/group-router.js +359 -0
- package/dist/server/device-center/hub-auth.js +24 -2
- package/dist/server/device-center/hub-conversations.js +13 -15
- package/dist/server/device-center/hub-deliveries.js +119 -15
- package/dist/server/device-center/hub-integration.js +647 -334
- package/dist/server/device-center/hub-locks.js +1 -5
- package/dist/server/device-center/hub-mobile.js +147 -0
- package/dist/server/device-center/hub-orchestration.js +400 -0
- package/dist/server/device-center/hub-page.js +28 -9
- package/dist/server/device-center/hub-setup.js +23 -7
- package/dist/server/device-center/hub-transaction-log.js +175 -0
- package/dist/server/device-center/hub-upgrade.js +162 -0
- package/dist/server/device-center/hub-webhooks.js +1 -3
- package/dist/server/device-center/hub.js +946 -404
- package/dist/server/device-center/human-interaction.js +1 -4
- package/dist/server/device-center/integration-errors.js +0 -2
- package/dist/server/device-center/integration-verification.js +111 -0
- package/dist/server/device-center/local-hub.js +6 -4
- package/dist/server/device-center/local-publication.js +416 -0
- package/dist/server/device-center/local-verification-job.js +95 -0
- package/dist/server/device-center/local-verification.js +273 -0
- package/dist/server/device-center/local.js +341 -18
- package/dist/server/device-center/main.js +18 -2
- package/dist/server/device-center/mobile-notification-forwarder.js +292 -0
- package/dist/server/device-center/native-desktop/macos.js +0 -1
- package/dist/server/device-center/native-desktop/windows.js +0 -1
- package/dist/server/device-center/partition-log.js +52 -46
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +305 -0
- package/dist/server/device-center/publish-intent.js +374 -0
- package/dist/server/device-center/relay.js +217 -52
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +419 -52
- package/dist/server/device-center/store.js +223 -65
- package/dist/server/device-center/task-context-budget.js +0 -3
- package/dist/server/device-center/task-error.js +0 -1
- package/dist/server/device-center/task-journal.js +6 -23
- package/dist/server/device-center/task-outcome.js +68 -0
- package/dist/server/device-center/task-plan.js +0 -1
- package/dist/server/device-center/task-progress.js +0 -16
- package/dist/server/device-center/task-recovery.js +569 -227
- package/dist/server/device-center/task-report-outbox.js +0 -4
- package/dist/server/device-center/task-report.js +2 -10
- package/dist/server/device-center/task-scheduler.js +1 -35
- package/dist/server/device-center/task-settlement.js +335 -0
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +393 -0
- package/dist/server/device-center/transfer-stream.js +5 -45
- package/dist/server/device-center/transfers.js +2 -10
- package/dist/server/device-center/verification-limits.js +9 -0
- package/dist/server/device-center/work-contract.js +923 -0
- package/dist/server/device-center/work-items.js +317 -0
- package/dist/server/device-center/workspaces.js +0 -1
- package/dist/server/dispatch-domain-handlers.js +202 -29
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +78 -601
- package/dist/server/dsh/dsh-client.js +7 -111
- package/dist/server/dsh/dsh-market-service.js +4 -25
- package/dist/server/dsh/dsh-serialize.js +0 -49
- package/dist/server/dsh/dsh-sessions.js +0 -37
- package/dist/server/dsh/dsh-usage.js +0 -37
- package/dist/server/dsh/preset-clones.js +1 -65
- package/dist/server/dsh/runtime/custom-prompt.mjs +0 -14
- package/dist/server/dsh/runtime/goal-rpc.mjs +7 -176
- package/dist/server/dsh/runtime/launcher.mjs +2 -53
- package/dist/server/dsh/runtime/override.patch.yml +0 -29
- package/dist/server/dsh/runtime/runtime-root.mjs +0 -54
- package/dist/server/durable/durable-agent-service.js +5 -23
- package/dist/server/durable/durable-driver.js +12 -73
- package/dist/server/durable/durable-event-projector.js +1 -50
- package/dist/server/durable/durable-loader.js +0 -12
- package/dist/server/durable/durable-models.js +11 -80
- package/dist/server/durable/durable-storage.js +1 -17
- package/dist/server/durable/durable-tools.js +2 -20
- package/dist/server/durable/index.js +0 -3
- package/dist/server/edit-soft-tool.js +2 -81
- package/dist/server/engine-capabilities.js +0 -13
- package/dist/server/engine-catalog.js +74 -0
- package/dist/server/engine-cli.js +89 -0
- package/dist/server/engine-probe.js +35 -217
- package/dist/server/ensure-bash.js +2 -28
- package/dist/server/eval-tool.js +1 -50
- package/dist/server/evidence-tool-hooks.js +0 -2
- package/dist/server/file-archives.js +0 -10
- package/dist/server/file-save.js +1 -12
- package/dist/server/file-transfer-routes.js +0 -11
- package/dist/server/files-service.js +18 -271
- package/dist/server/global-loader.js +9 -89
- package/dist/server/goal-evidence.js +1 -35
- package/dist/server/goal-review-gate.js +0 -58
- package/dist/server/goal-service.js +19 -422
- package/dist/server/hashline-engine.js +8 -112
- package/dist/server/host-guard.js +0 -24
- package/dist/server/host-metrics.js +0 -6
- package/dist/server/http-proxy.js +1 -7
- package/dist/server/i18n.js +5 -72
- package/dist/server/icon-svg.js +0 -15
- package/dist/server/index.js +199 -677
- package/dist/server/json-utils.js +0 -12
- package/dist/server/launch-origin.js +0 -44
- package/dist/server/left-panel-running.js +0 -9
- package/dist/server/load-timing.js +1 -4
- package/dist/server/load-tools-tool.js +0 -20
- package/dist/server/locales.js +1 -46
- package/dist/server/lsp-tool.js +13 -126
- package/dist/server/managed.js +0 -48
- package/dist/server/marker-service.js +1 -22
- package/dist/server/markers/builtins/action.js +0 -19
- package/dist/server/markers/builtins/notify.js +1 -9
- package/dist/server/markers/builtins/rename.js +0 -13
- package/dist/server/markers/index.js +0 -3
- package/dist/server/markers/marker.js +0 -13
- package/dist/server/markers/registry.js +0 -3
- package/dist/server/markers/store.js +1 -12
- package/dist/server/market-service.js +7 -43
- package/dist/server/mcp-agent-tool.js +0 -10
- package/dist/server/mcp-bridge.js +6 -138
- package/dist/server/mcp-hot-reload.js +0 -25
- package/dist/server/mcp-manager.js +2 -44
- package/dist/server/mcp-oauth-login.js +0 -2
- package/dist/server/mcp-oauth-ui.js +1 -4
- package/dist/server/mcp-oauth.js +5 -79
- package/dist/server/mcp-project-runtime.js +0 -4
- package/dist/server/message-deletion.js +0 -2
- package/dist/server/message-entry-resolver.js +0 -8
- package/dist/server/message-window.js +0 -71
- package/dist/server/mobile-notification-events.js +16 -0
- package/dist/server/mobile-origin.js +79 -0
- package/dist/server/mobile-push.js +523 -0
- package/dist/server/model-admin.js +19 -358
- package/dist/server/model-enrich.js +0 -19
- package/dist/server/model-resolver.js +2 -61
- package/dist/server/native-cli-discovery.js +115 -0
- package/dist/server/native-cli-model.js +71 -0
- package/dist/server/native-cli-references.js +214 -0
- package/dist/server/native-cli-remote-cleanup.js +58 -0
- package/dist/server/native-cli-remote-files.js +282 -0
- package/dist/server/native-cli-routes.js +68 -0
- package/dist/server/native-cli-runtime.js +1 -0
- package/dist/server/native-cli-session-hooks.js +170 -0
- package/dist/server/native-cli-session.js +585 -0
- package/dist/server/native-cli-state.js +82 -0
- package/dist/server/native-cli.js +210 -0
- package/dist/server/net-guard.js +9 -71
- package/dist/server/office-parse.js +0 -50
- package/dist/server/orphan-manager.js +0 -18
- package/dist/server/patch-bash-process.js +0 -4
- package/dist/server/patch-executable-lookup.js +0 -77
- package/dist/server/patch-node-pty.js +6 -45
- package/dist/server/patch-remote-catalog.js +4 -34
- package/dist/server/patch-tool.js +0 -15
- package/dist/server/payload-limits.js +0 -5
- package/dist/server/pending-question.js +0 -5
- package/dist/server/permission-preset.js +4 -33
- package/dist/server/persona-chain.js +0 -26
- package/dist/server/pkg-info.js +1 -17
- package/dist/server/plan-manager.js +2 -49
- package/dist/server/plan-mode.js +0 -97
- package/dist/server/plan-update-tool.js +1 -15
- package/dist/server/plugin-api-catalog.js +6 -4
- package/dist/server/plugin-assets.js +1 -35
- package/dist/server/plugin-bundled.js +68 -0
- package/dist/server/plugin-catalog-sync.js +0 -37
- package/dist/server/plugin-catalog.js +13 -67
- package/dist/server/plugin-chat-attachments.js +0 -1
- package/dist/server/plugin-conversation-view.js +0 -20
- package/dist/server/plugin-dom.js +1 -23
- package/dist/server/plugin-facilities.js +4 -115
- package/dist/server/plugin-grants.js +2 -90
- package/dist/server/plugin-install-spec.js +0 -43
- package/dist/server/plugin-installer.js +34 -75
- package/dist/server/plugin-llm.js +4 -38
- package/dist/server/plugin-manifest-validate.js +0 -31
- package/dist/server/plugin-permissions.js +1 -24
- package/dist/server/plugin-project.js +7 -129
- package/dist/server/plugin-removal.js +1 -8
- package/dist/server/plugin-schedule.js +1 -38
- package/dist/server/plugin-secrets.js +3 -16
- package/dist/server/plugin-tool-guard.js +1 -28
- package/dist/server/plugin-ui-slots.js +0 -4
- package/dist/server/plugin-updater.js +15 -90
- package/dist/server/plugins.js +71 -619
- package/dist/server/present-files-tool.js +0 -57
- package/dist/server/preset-fields.js +24 -61
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +4 -172
- package/dist/server/process-utils.js +4 -80
- package/dist/server/prompt-assembler.js +2 -30
- package/dist/server/prompt-base-store.js +0 -47
- package/dist/server/prompt-composer.js +21 -98
- package/dist/server/prompt-templates.js +0 -2
- package/dist/server/protocol-version.js +1 -11
- package/dist/server/protocol.js +0 -5
- package/dist/server/queue-modes.js +0 -3
- package/dist/server/queue-utils.js +0 -40
- package/dist/server/quick-ask-context.js +384 -0
- package/dist/server/quick-ask-settings.js +61 -0
- package/dist/server/quick-ask.js +260 -0
- package/dist/server/read-tool.js +0 -65
- package/dist/server/reasoning-registry.js +1 -29
- package/dist/server/remote-cli-persistence.js +373 -0
- package/dist/server/remote-native-cli.js +78 -0
- package/dist/server/remote-ssh-service.js +481 -190
- package/dist/server/request-context.js +0 -9
- package/dist/server/resolve-global-sdk.js +55 -31
- package/dist/server/sandbox-data.js +0 -1
- package/dist/server/sandbox-engines.js +0 -1
- package/dist/server/sandbox-runtime-gate.js +0 -3
- package/dist/server/sandbox-service.js +0 -41
- package/dist/server/sandbox-tool.js +0 -20
- package/dist/server/schedule-agent-tool.js +2 -31
- package/dist/server/scheduler-tasks.js +32 -56
- package/dist/server/scm-commitmsg.js +0 -53
- package/dist/server/scm.js +3 -48
- package/dist/server/sdk-builtin-extensions.js +2 -29
- package/dist/server/sdk-origin.js +0 -45
- package/dist/server/serialize.js +2 -92
- package/dist/server/server-config.js +0 -11
- package/dist/server/session-branch.js +1 -87
- package/dist/server/session-list-scan.js +215 -0
- package/dist/server/session-open.js +69 -0
- package/dist/server/session-parser.js +4 -54
- package/dist/server/session-scan.js +81 -45
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +19 -126
- package/dist/server/setup-config.js +0 -2
- package/dist/server/setup-page.js +0 -9
- package/dist/server/skill-content-filler.js +0 -17
- package/dist/server/skill-discovery.js +5 -92
- package/dist/server/skill-maintenance.js +1 -28
- package/dist/server/skill-tool.js +0 -30
- package/dist/server/slash-commands.js +5 -50
- package/dist/server/soft-cap.js +3 -40
- package/dist/server/startup-banner.js +0 -8
- package/dist/server/subagent-handoff.js +0 -11
- package/dist/server/subagent-helpers.js +2 -17
- package/dist/server/subagent-notify.js +0 -19
- package/dist/server/subagent-security-gate.js +0 -50
- package/dist/server/subagent-task.js +0 -9
- package/dist/server/subagent-templates-hant.js +0 -10
- package/dist/server/subagent-templates.js +3 -103
- package/dist/server/subagents.js +1 -87
- package/dist/server/system-screenshot-windows.js +259 -0
- package/dist/server/system-screenshot.js +77 -0
- package/dist/server/tabs.js +3 -48
- package/dist/server/terminals.js +559 -586
- package/dist/server/text-quote.js +0 -12
- package/dist/server/text-sniff.js +2 -52
- package/dist/server/themes.js +2 -41
- package/dist/server/tool-approval.js +0 -47
- package/dist/server/tool-guards.js +0 -90
- package/dist/server/tool-host-factories.js +1 -16
- package/dist/server/tool-info.js +0 -13
- package/dist/server/tool-manager.js +1 -229
- package/dist/server/tool-overrides.js +1 -46
- package/dist/server/tool-prompt-overrides.js +1 -30
- package/dist/server/tool-prompts.js +0 -14
- package/dist/server/tool-signature.js +0 -25
- package/dist/server/transcript-prepare.js +55 -0
- package/dist/server/tts-routes.js +58 -0
- package/dist/server/tts-service.js +106 -0
- package/dist/server/tts-system.js +160 -0
- package/dist/server/turn-timing.js +0 -1
- package/dist/server/unauthorized-page.js +0 -8
- package/dist/server/universal/driver-base.js +2 -31
- package/dist/server/universal/drivers/claude-code.js +98 -194
- package/dist/server/universal/drivers/codex.js +12 -35
- package/dist/server/universal/drivers/mock-driver.js +1 -11
- package/dist/server/universal/index.js +0 -3
- package/dist/server/universal/session-store.js +4 -21
- package/dist/server/universal/universal-attachments.js +2 -36
- package/dist/server/universal/universal-service.js +5 -24
- package/dist/server/universal/universal-session.js +30 -148
- package/dist/server/universal/universal-types.js +0 -3
- package/dist/server/update-check.js +6 -182
- package/dist/server/uploads.js +4 -43
- package/dist/server/virtual-tui.js +2 -27
- package/dist/server/vision-bridge.js +0 -27
- package/dist/server/wait-subscription-scan.js +13 -115
- package/dist/server/webui-context.js +2 -87
- package/dist/server/workspace-handle.js +373 -0
- package/dist/server/workspace-snapshot.js +7 -113
- package/dist/server/worktree-service.js +2 -53
- package/dist/server/worktree-tool.js +0 -11
- package/dist/server/ws-client-id.js +0 -18
- package/dist/server/ws-pending-queue.js +0 -7
- package/dist/server/ws-unknown-types.js +0 -17
- package/docs/README.md +24 -17
- package/docs/architecture-plugins.md +55 -6
- package/docs/device-center.md +57 -23
- package/docs/device-desktop.md +3 -3
- package/docs/group-orchestration.md +142 -0
- package/docs/hub-upgrade-release-testing.md +46 -0
- package/extensions/webui.ts +3 -74
- package/package.json +9 -6
- package/plugin-sdk/README.md +22 -8
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +26 -0
- package/plugin-sdk/client.mjs +52 -0
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +128 -117
- package/plugin-sdk/index.mjs +2 -687
- package/plugin-sdk/package.json +15 -4
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +9 -0
- package/plugin-sdk/testing.mjs +511 -0
- package/plugins/catalog.json +52 -4
- package/plugins/superagent/README.md +110 -0
- package/plugins/superagent/client/entry.mjs +21 -0
- package/plugins/superagent/index.mjs +8 -0
- package/plugins/superagent/main.mjs +218 -0
- package/plugins/superagent/manifest.json +15 -0
- package/plugins/superagent/server.mjs +572 -0
- package/plugins/superagent/style.css +167 -0
- package/themes/aetheris.css +1 -31
- package/themes/ayu-light.css +0 -1
- package/themes/bases/flow-base.css +2 -83
- package/themes/bases/obsidian-base.css +2 -37
- package/themes/bases/statusbar-flat-base.css +0 -1
- package/themes/bases/zhujian-base.css +0 -63
- package/themes/bases/zhupi-base.css +0 -64
- package/themes/catppuccin-latte.css +0 -1
- package/themes/catppuccin.css +0 -1
- package/themes/claude-code-dark.css +0 -1
- package/themes/codex.css +0 -1
- package/themes/dark-teal.css +22 -54
- package/themes/everforest-light.css +0 -1
- package/themes/flow-cristallo.css +160 -0
- package/themes/flow-ink.css +160 -0
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +160 -0
- package/themes/flow-zurich.css +160 -0
- package/themes/flow.css +1 -9
- package/themes/geist.css +0 -1
- package/themes/gruvbox-light.css +0 -1
- package/themes/kanagawa-lotus.css +0 -1
- package/themes/md-preview.css +1 -2
- package/themes/mist.css +0 -1
- package/themes/nord.css +0 -1
- package/themes/one-dark.css +0 -1
- package/themes/paper.css +0 -1
- package/themes/rose-pine-dawn.css +0 -1
- package/themes/sakura.css +0 -1
- package/themes/solarized-light.css +0 -1
- package/themes/tokyo-night.css +0 -1
- package/themes/translucent.css +4 -35
- package/themes/transparent.css +4 -41
- package/themes/vs-code-dark.css +0 -1
- package/themes/wallpaper-flow.css +3 -17
- package/themes/wallpaper-obsidian.css +1 -4
- package/themes/white.css +0 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BDoOpj-F.js → BgTasksModal-D-x7kA63.js} +1 -1
- package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
- package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
- package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
- package/web/dist/assets/{Dropdown-C4LIhshN.js → Dropdown-CTgVLUbp.js} +1 -1
- package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
- package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
- package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
- package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
- package/web/dist/assets/{HintTip-c6d0TJoh.js → HintTip-Da6qc566.js} +1 -1
- package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
- package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
- package/web/dist/assets/{PiSetupModal-BmMrrgB9.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/SCMPanel-CuEgzAlO.js +2 -0
- package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
- package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
- package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
- package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
- package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
- package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
- package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
- package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
- package/web/dist/assets/index-CQc3VrWa.css +1 -0
- package/web/dist/assets/index-D_AGu4Zv.js +404 -0
- package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
- package/web/dist/assets/{remote-ssh-client-CfYSMEZg.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +12 -11
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/dist/gh-comment-781.md +0 -5
- package/dist/server/device-center/local-page.js +0 -17
- package/dist/server/device-center/smoke-preview.js +0 -3
- package/dist/server/durable/durable-capabilities.js +0 -11
- package/dist/server/markers/builtins/services.js +0 -123
- package/dist/server/markers/builtins/todo.js +0 -189
- package/dist/server/markers-list-tool.js +0 -34
- package/dist/server/orchestrator.js +0 -109
- package/dist/server/patch-turn-end-boundary.js +0 -77
- package/dist/server/system-prompt-soul.js +0 -41
- package/dist/server/univer-service.js +0 -448
- package/dist/server/universal/drivers/dsh-driver.js +0 -379
- package/dist/test-artifact.md +0 -9
- package/dist/test-preview-modal.md +0 -11
- package/dist/test-report.html +0 -20
- package/web/dist/assets/BgTasksModal-C0i3O1FT.js +0 -1
- package/web/dist/assets/CanvasStudio-B8thymBN.js +0 -1579
- package/web/dist/assets/CanvasStudio-zSxyIx1R.js +0 -1579
- package/web/dist/assets/DeviceCenter-DfAHKcid.js +0 -3
- package/web/dist/assets/DeviceCenter-ydvOTlzE.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-q5Ik8oXg.js +0 -1
- package/web/dist/assets/DeviceGroups-CI14_SRb.js +0 -1
- package/web/dist/assets/DeviceGroups-DvsB5IEU.js +0 -1
- package/web/dist/assets/FilePreview-BgGongmv.js +0 -2
- package/web/dist/assets/FilePreview-D4NrhF-U.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BWgU8yPd.js +0 -1
- package/web/dist/assets/GlobalSearchModal-F7fNimKk.js +0 -1
- package/web/dist/assets/GroupConversation-Dh71Pdb-.js +0 -17
- package/web/dist/assets/GroupConversation-ZK3nRmNm.js +0 -17
- package/web/dist/assets/ModelConfigModal-YVEgyy34.js +0 -2
- package/web/dist/assets/ModelConfigModal-vWtg3srp.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-BGSBIKD7.js +0 -1
- package/web/dist/assets/SCMPanel-B8_EDxNr.js +0 -2
- package/web/dist/assets/SCMPanel-BU58qk3T.js +0 -2
- package/web/dist/assets/SettingsModal-CMUybq3J.js +0 -32
- package/web/dist/assets/SettingsModal-OBmGTh-5.js +0 -32
- package/web/dist/assets/TerminalPanel-0CYvD72B.js +0 -3
- package/web/dist/assets/TerminalPanel-DDavKvFr.js +0 -3
- package/web/dist/assets/TuiOverlayModal-BsA-QTvN.js +0 -1
- package/web/dist/assets/TuiOverlayModal-DzoVQBuG.js +0 -1
- package/web/dist/assets/app-globals-CZxzGvIo.js +0 -123
- package/web/dist/assets/canvas-client-CUnXlQYX.js +0 -1
- package/web/dist/assets/desktop-aAKpvKJV.js +0 -1
- package/web/dist/assets/index-C6DwztqE.css +0 -1
- package/web/dist/assets/index-CuN802Sj.js +0 -93
- package/web/dist/assets/index-EH5Fw9fa.js +0 -93
- package/web/dist/assets/plugin-host-BRWib9DF.js +0 -1
- package/web/dist/assets/theme-D2l_mLNo.js +0 -1
|
@@ -2,11 +2,9 @@ import { persistContextEvidence, contextEvidenceReference } from "./context-evid
|
|
|
2
2
|
const READ_ONLY_TOOLS = new Set(["read", "grep", "find"]);
|
|
3
3
|
const MIN_DUPLICATE_CHARS = 4096;
|
|
4
4
|
const evidenceReady = new WeakSet();
|
|
5
|
-
/** Enable only when the SDK permission hook and compaction adapters are compatible. */
|
|
6
5
|
export function enableRequestEvidence(sessionManager) {
|
|
7
6
|
evidenceReady.add(sessionManager);
|
|
8
7
|
}
|
|
9
|
-
/** Keep the first exact result, so appending messages does not rewrite earlier requests. */
|
|
10
8
|
export function deduplicateRequestContext(messages) {
|
|
11
9
|
const calls = new Map();
|
|
12
10
|
const originals = new Map();
|
|
@@ -14,7 +12,6 @@ export function deduplicateRequestContext(messages) {
|
|
|
14
12
|
for (let index = 0; index < messages.length; index++) {
|
|
15
13
|
const message = messages[index];
|
|
16
14
|
if (message.role === "user") {
|
|
17
|
-
// A human may have changed workspace files outside the agent.
|
|
18
15
|
calls.clear();
|
|
19
16
|
originals.clear();
|
|
20
17
|
continue;
|
|
@@ -22,7 +19,6 @@ export function deduplicateRequestContext(messages) {
|
|
|
22
19
|
if (message.role === "assistant") {
|
|
23
20
|
const toolCalls = message.content.filter((block) => block.type === "toolCall");
|
|
24
21
|
if (toolCalls.some((block) => !READ_ONLY_TOOLS.has(block.name))) {
|
|
25
|
-
// Mixed/parallel batches cannot establish a reliable read-before-write order.
|
|
26
22
|
calls.clear();
|
|
27
23
|
originals.clear();
|
|
28
24
|
continue;
|
|
@@ -35,7 +31,6 @@ export function deduplicateRequestContext(messages) {
|
|
|
35
31
|
if (message.role !== "toolResult")
|
|
36
32
|
continue;
|
|
37
33
|
if (!READ_ONLY_TOOLS.has(message.toolName)) {
|
|
38
|
-
// Unknown tools (including codemode and plugins) may mutate the workspace.
|
|
39
34
|
calls.clear();
|
|
40
35
|
originals.clear();
|
|
41
36
|
continue;
|
|
@@ -45,11 +40,9 @@ export function deduplicateRequestContext(messages) {
|
|
|
45
40
|
continue;
|
|
46
41
|
calls.delete(message.toolCallId);
|
|
47
42
|
const previous = originals.get(call);
|
|
48
|
-
// Even an ineligible result invalidates the previous observation for this query.
|
|
49
43
|
originals.delete(call);
|
|
50
44
|
if (message.isError || !message.content.length || message.content.some((block) => block.type !== "text"))
|
|
51
45
|
continue;
|
|
52
|
-
// Unknown/signed block fields and structured payloads must retain provider semantics.
|
|
53
46
|
if (message.content.some((block) => Object.keys(block).some((key) => key !== "type" && key !== "text")))
|
|
54
47
|
continue;
|
|
55
48
|
if ("structuredContent" in message)
|
|
@@ -76,7 +69,6 @@ export function deduplicateRequestContext(messages) {
|
|
|
76
69
|
}
|
|
77
70
|
return output;
|
|
78
71
|
}
|
|
79
|
-
/** Conservative estimates; never claim this is the provider's tokenizer. */
|
|
80
72
|
export function requestMessageBudget(model, systemPrompt, tools) {
|
|
81
73
|
const window = model?.contextWindow ?? 128000;
|
|
82
74
|
const output = Math.min(model?.maxTokens ?? 16384, Math.floor(window / 4));
|
|
@@ -157,7 +149,6 @@ export function requestContextExtension(pi) {
|
|
|
157
149
|
}
|
|
158
150
|
catch {
|
|
159
151
|
ctx.signal?.throwIfAborted();
|
|
160
|
-
// Optimization must never prevent a provider request.
|
|
161
152
|
return { messages: event.messages };
|
|
162
153
|
}
|
|
163
154
|
});
|
|
@@ -27,18 +27,13 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import { registerBashProcessPatch } from "./patch-bash-process.js";
|
|
29
29
|
import { registerExecutableLookupPatch } from "./patch-executable-lookup.js";
|
|
30
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
30
|
+
import { closeSync, existsSync, openSync, readFileSync, readSync, statSync } from "node:fs";
|
|
31
31
|
import { registerHooks } from "node:module";
|
|
32
32
|
import { dirname, join } from "node:path";
|
|
33
33
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
34
34
|
import { compareVersions, sdkCopies } from "./sdk-origin.js";
|
|
35
35
|
const PKG = "@earendil-works/pi-coding-agent";
|
|
36
|
-
/** 显式强制自带副本的取值(旧默认;可复现、CI 覆盖的那份)。 */
|
|
37
36
|
const BUNDLED_MODES = new Set(["bundled", "0", "off", "false", "no"]);
|
|
38
|
-
/**
|
|
39
|
-
* 找出传入副本列表中的随包自带副本(如果有的话)。
|
|
40
|
-
* 自带副本必须位于 pi-web-ui 自身包根下的 node_modules/@earendil-works/pi-coding-agent/package.json。
|
|
41
|
-
*/
|
|
42
37
|
export function findBundledCopy(copies, fromFile = import.meta.url) {
|
|
43
38
|
const filePath = fromFile.startsWith("file:") ? fileURLToPath(fromFile) : fromFile;
|
|
44
39
|
let cur = dirname(filePath);
|
|
@@ -66,50 +61,84 @@ export function findBundledCopy(copies, fromFile = import.meta.url) {
|
|
|
66
61
|
const expectedBundledPath = join(pkgRoot, "node_modules", PKG, "package.json").replace(/\\/g, "/");
|
|
67
62
|
return copies.find((c) => c.path.replace(/\\/g, "/") === expectedBundledPath) ?? null;
|
|
68
63
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
export function isSdkCopyUsable(copy) {
|
|
65
|
+
if (!existsSync(copy.path))
|
|
66
|
+
return true;
|
|
67
|
+
try {
|
|
68
|
+
const pkgDir = dirname(copy.path);
|
|
69
|
+
const raw = readFileSync(copy.path, "utf8");
|
|
70
|
+
const info = JSON.parse(raw);
|
|
71
|
+
if (info?.name && info.name !== PKG)
|
|
72
|
+
return false;
|
|
73
|
+
const mainRel = typeof info?.main === "string" ? info.main : "dist/index.js";
|
|
74
|
+
const mainFile = join(pkgDir, mainRel);
|
|
75
|
+
if (!existsSync(mainFile) || statSync(mainFile).size === 0)
|
|
76
|
+
return false;
|
|
77
|
+
const sessionFile = join(pkgDir, "dist", "core", "agent-session.js");
|
|
78
|
+
if (existsSync(sessionFile)) {
|
|
79
|
+
const stat = statSync(sessionFile);
|
|
80
|
+
if (stat.size < 10000)
|
|
81
|
+
return false;
|
|
82
|
+
const fd = openSync(sessionFile, "r");
|
|
83
|
+
try {
|
|
84
|
+
const buf = Buffer.alloc(Math.min(2048, stat.size));
|
|
85
|
+
readSync(fd, buf, 0, buf.length, Math.max(0, stat.size - buf.length));
|
|
86
|
+
const tail = buf.toString("utf8").trim();
|
|
87
|
+
if (!tail.includes("sourceMappingURL") && !tail.endsWith("}") && !tail.endsWith("};")) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
closeSync(fd);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export function pickGlobalSdk(copies, mode, bundledCopy = copies[0] ?? null, isUsable = isSdkCopyUsable) {
|
|
75
102
|
if (BUNDLED_MODES.has((mode ?? "global").trim().toLowerCase()))
|
|
76
103
|
return null;
|
|
77
|
-
|
|
104
|
+
const validCopies = copies.filter(isUsable);
|
|
105
|
+
const validBundled = bundledCopy && isUsable(bundledCopy) ? bundledCopy : null;
|
|
78
106
|
if (process.env.PI_WEB_SDK_DIR) {
|
|
79
|
-
const hostCopy =
|
|
80
|
-
if (hostCopy && (!
|
|
107
|
+
const hostCopy = validCopies.find((c) => dirname(c.path) === process.env.PI_WEB_SDK_DIR);
|
|
108
|
+
if (hostCopy && (!validBundled || compareVersions(hostCopy.version, validBundled.version) >= 0)) {
|
|
81
109
|
return hostCopy;
|
|
82
110
|
}
|
|
83
111
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (!bundledCopy) {
|
|
87
|
-
if (copies.length === 0)
|
|
112
|
+
if (!validBundled) {
|
|
113
|
+
if (validCopies.length === 0)
|
|
88
114
|
return null;
|
|
89
|
-
let best =
|
|
90
|
-
for (const copy of
|
|
115
|
+
let best = validCopies[0];
|
|
116
|
+
for (const copy of validCopies.slice(1)) {
|
|
91
117
|
if (compareVersions(copy.version, best.version) > 0) {
|
|
92
118
|
best = copy;
|
|
93
119
|
}
|
|
94
120
|
}
|
|
95
121
|
return best;
|
|
96
122
|
}
|
|
97
|
-
// 存在自带副本:只考虑比自带副本**严格更新**的外部副本,多份取版本最高的(旧的/同版本的都不折腾)。
|
|
98
123
|
let best = null;
|
|
99
|
-
for (const copy of
|
|
100
|
-
if (copy.path ===
|
|
124
|
+
for (const copy of validCopies) {
|
|
125
|
+
if (copy.path === validBundled.path)
|
|
101
126
|
continue;
|
|
102
|
-
if (compareVersions(copy.version,
|
|
127
|
+
if (compareVersions(copy.version, validBundled.version) > 0 &&
|
|
103
128
|
(!best || compareVersions(copy.version, best.version) > 0)) {
|
|
104
129
|
best = copy;
|
|
105
130
|
}
|
|
106
131
|
}
|
|
107
132
|
return best;
|
|
108
133
|
}
|
|
109
|
-
/** 注册钩子;返回实际选中的副本(null = 用自带副本)。 */
|
|
110
134
|
export function registerGlobalSdkPreference(mode = process.env.PI_WEB_SDK, fromFile = import.meta.url) {
|
|
111
135
|
try {
|
|
112
136
|
const copies = sdkCopies(fromFile);
|
|
137
|
+
for (const copy of copies) {
|
|
138
|
+
if (existsSync(copy.path) && !isSdkCopyUsable(copy)) {
|
|
139
|
+
console.warn(`[pi-web-ui] SDK copy at ${copy.path} (v${copy.version}) appears incomplete or damaged, skipping.`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
113
142
|
const bundled = findBundledCopy(copies, fromFile);
|
|
114
143
|
const chosen = pickGlobalSdk(copies, mode, bundled);
|
|
115
144
|
if (!chosen)
|
|
@@ -117,8 +146,6 @@ export function registerGlobalSdkPreference(mode = process.env.PI_WEB_SDK, fromF
|
|
|
117
146
|
registerHooks({
|
|
118
147
|
resolve(specifier, context, nextResolve) {
|
|
119
148
|
if (specifier === PKG) {
|
|
120
|
-
// 以目标副本的 package.json 为父重新解析:Node 从那里往上找,
|
|
121
|
-
// 第一个命中的就是它自己 —— 等价于「从那个包内部 import 自己」。
|
|
122
149
|
try {
|
|
123
150
|
return nextResolve(specifier, { ...context, parentURL: pathToFileURL(chosen.path).href });
|
|
124
151
|
}
|
|
@@ -131,7 +158,6 @@ export function registerGlobalSdkPreference(mode = process.env.PI_WEB_SDK, fromF
|
|
|
131
158
|
return nextResolve(specifier, context);
|
|
132
159
|
}
|
|
133
160
|
catch {
|
|
134
|
-
// 本地缺少 typebox(如 pnpm 隔离安装)时,从已选中的 pi SDK 目录解析(issue #562)
|
|
135
161
|
try {
|
|
136
162
|
return nextResolve(specifier, { ...context, parentURL: pathToFileURL(chosen.path).href });
|
|
137
163
|
}
|
|
@@ -146,11 +172,9 @@ export function registerGlobalSdkPreference(mode = process.env.PI_WEB_SDK, fromF
|
|
|
146
172
|
return chosen;
|
|
147
173
|
}
|
|
148
174
|
catch {
|
|
149
|
-
// 钩子注册失败(Node 太老 / 环境怪异)→ 静默退回默认解析,绝不影响启动。
|
|
150
175
|
return null;
|
|
151
176
|
}
|
|
152
177
|
}
|
|
153
|
-
// ---- 副作用:被 `--import` 加载时立刻生效 --------------------------------
|
|
154
178
|
registerBashProcessPatch();
|
|
155
179
|
registerExecutableLookupPatch();
|
|
156
180
|
const used = registerGlobalSdkPreference();
|
|
@@ -589,7 +589,6 @@ export class SandboxManager {
|
|
|
589
589
|
await mkdir(path);
|
|
590
590
|
});
|
|
591
591
|
}
|
|
592
|
-
// Keep the import baseline: subsequent previews continue to show the sandbox's changes.
|
|
593
592
|
return { sandbox: info, sourcePath: info.sourcePath, copiedFiles, deletedFiles };
|
|
594
593
|
}
|
|
595
594
|
catch (error) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { evaluateSandboxJail } from "./sandbox-service.js";
|
|
2
|
-
/** Only these host capabilities can be sealed. A matching name alone never grants trust. */
|
|
3
2
|
const HOST_CAPABILITIES = new Set(["read", "write", "edit", "edit_soft", "patch", "present_files", "sandbox"]);
|
|
4
|
-
/** Final SDK tool_call guard. Leases belong to the host wrappers, not this hook. */
|
|
5
3
|
export function createSandboxRuntimeGate(getSandbox, cwd) {
|
|
6
4
|
const trusted = new Map();
|
|
7
5
|
let session;
|
|
@@ -35,7 +33,6 @@ export function createSandboxRuntimeGate(getSandbox, cwd) {
|
|
|
35
33
|
},
|
|
36
34
|
};
|
|
37
35
|
}
|
|
38
|
-
/** noExtensions alone still permits explicit paths; keep both locked across reloads. */
|
|
39
36
|
export function sandboxExtensionOptions(sandbox) {
|
|
40
37
|
return sandbox ? { noExtensions: true, additionalExtensionPaths: [] } : {};
|
|
41
38
|
}
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 沙盒项目服务(Sandbox Project Service):
|
|
3
|
-
*
|
|
4
|
-
* 1. 隔离副本工作区管理(`<dataDir>/sandboxes/registry.json` + `<dataDir>/sandboxes/<id>/`):
|
|
5
|
-
* - 支持「空白沙盒」与「导入现有项目」(自动跳过 node_modules/.venv/target 等重型缓存目录与越界软链);
|
|
6
|
-
* - 支持「临时沙盒(用完即删)」与「永久沙盒(持久化保留,随时一键转正)」;
|
|
7
|
-
* - 支持一键重置(还原到初始空白或重新从源项目同步)、另存为正式项目(promote)、将修改写回源项目(applyToSource)、彻底销毁(destroy)。
|
|
8
|
-
*
|
|
9
|
-
* 2. 沙盒安全围栏(Sandbox Jail Gate):
|
|
10
|
-
* - 当会话处于受管沙盒目录内时,所有文件写入/编辑/补丁(write/edit/edit_soft/patch)必须严格落在
|
|
11
|
-
* `sandbox.path` 内部(含祖先目录 realpath 校验,防软链逃逸),越界直接硬拒绝(不走审批放行);
|
|
12
|
-
* - 没有操作系统隔离后端时拒绝宿主 shell、解释器、终端和任意代码执行;
|
|
13
|
-
* - 仅放行来源可信且能力明确的受限文件工具,未知工具和外部副作用默认拒绝。
|
|
14
|
-
*/
|
|
15
1
|
import { existsSync, realpathSync } from "node:fs";
|
|
16
2
|
import { homedir } from "node:os";
|
|
17
3
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
@@ -19,7 +5,6 @@ import * as sandboxJailFs from "node:fs";
|
|
|
19
5
|
import { normalizePathKey } from "./client-state.js";
|
|
20
6
|
import { isConversationTool } from "./conversation-tool-names.js";
|
|
21
7
|
import { pick } from "./i18n.js";
|
|
22
|
-
/** 导入项目进沙盒时默认跳过的重型依赖/构建缓存目录名。 */
|
|
23
8
|
export const SANDBOX_IGNORED_DIRS = new Set([
|
|
24
9
|
"node_modules",
|
|
25
10
|
".venv",
|
|
@@ -47,9 +32,6 @@ export function isSameOrSubpath(childAbs, parentAbs) {
|
|
|
47
32
|
const p = toComparablePath(parentAbs);
|
|
48
33
|
return c === p || c.startsWith(p + "/");
|
|
49
34
|
}
|
|
50
|
-
/**
|
|
51
|
-
* 解析目标路径并校验是否严格位于 `sandboxRoot` 内部(含祖先目录 realpath 校验,防软链逃逸)。
|
|
52
|
-
*/
|
|
53
35
|
export function isStrictlyInsideSandbox(targetPath, cwd, sandboxRoot) {
|
|
54
36
|
if (!targetPath || typeof targetPath !== "string")
|
|
55
37
|
return false;
|
|
@@ -63,11 +45,9 @@ export function isStrictlyInsideSandbox(targetPath, cwd, sandboxRoot) {
|
|
|
63
45
|
: trimmed;
|
|
64
46
|
const resolvedTarget = isAbsolute(expanded) ? resolve(expanded) : resolve(cwd, expanded);
|
|
65
47
|
const resolvedSandbox = resolve(sandboxRoot);
|
|
66
|
-
// 1. 词法路径必须在 sandboxRoot 之内
|
|
67
48
|
if (!isSameOrSubpath(resolvedTarget, resolvedSandbox)) {
|
|
68
49
|
return false;
|
|
69
50
|
}
|
|
70
|
-
// 2. 真实路径(realpath)校验:沿目标路径向上找到第一个已存在的祖先目录,防止通过沙盒内软链写到外部
|
|
71
51
|
let realSandbox;
|
|
72
52
|
try {
|
|
73
53
|
if (sandboxJailFs.lstatSync(resolvedSandbox).isSymbolicLink())
|
|
@@ -98,7 +78,6 @@ export function isStrictlyInsideSandbox(targetPath, cwd, sandboxRoot) {
|
|
|
98
78
|
}
|
|
99
79
|
return true;
|
|
100
80
|
}
|
|
101
|
-
/** 从 patch 工具的补丁文本中提取所有涉及的文件路径。 */
|
|
102
81
|
export function extractPatchTargetPaths(patchText) {
|
|
103
82
|
if (!patchText || typeof patchText !== "string")
|
|
104
83
|
return [];
|
|
@@ -115,9 +94,6 @@ export function extractPatchTargetPaths(patchText) {
|
|
|
115
94
|
paths.push(mUnified[1].trim());
|
|
116
95
|
continue;
|
|
117
96
|
}
|
|
118
|
-
// hashline 格式段头(本仓 patch 工具实际消费的唯一格式):[path#TAG] / [path]。
|
|
119
|
-
// 不识别的话 hashline 补丁提取出 0 个目标 → 围栏检查整体空转,patch 路径
|
|
120
|
-
// 只剩 hashline-engine 的词法 cwd 限制(无 realpath,沙盒内软链可逃逸)
|
|
121
97
|
const mHashline = rawLine.match(/^\s*\[([^#\]]+)(?:#[0-9a-fA-F]{4})?\]\s*$/);
|
|
122
98
|
if (mHashline?.[1]?.trim()) {
|
|
123
99
|
paths.push(mHashline[1].trim());
|
|
@@ -125,7 +101,6 @@ export function extractPatchTargetPaths(patchText) {
|
|
|
125
101
|
}
|
|
126
102
|
return paths;
|
|
127
103
|
}
|
|
128
|
-
/** Copy workspaces are not an OS execution boundary. Capabilities are opt-in. */
|
|
129
104
|
const SANDBOX_MANAGEMENT_ACTIONS = new Set([
|
|
130
105
|
"list",
|
|
131
106
|
"create",
|
|
@@ -136,13 +111,7 @@ const SANDBOX_MANAGEMENT_ACTIONS = new Set([
|
|
|
136
111
|
"apply_to_source",
|
|
137
112
|
"destroy",
|
|
138
113
|
]);
|
|
139
|
-
/** Reject links (including dangling links), special files and Windows alternate streams.
|
|
140
|
-
* This is a preflight for trusted local file tools, not protection against a hostile
|
|
141
|
-
* process racing filesystem changes; arbitrary host execution is therefore denied.
|
|
142
|
-
*/
|
|
143
114
|
function sandboxJailPath(raw, cwd, root) {
|
|
144
|
-
// SDK file tools strip a leading @ and normalize Unicode spaces. Refuse
|
|
145
|
-
// alternate spellings rather than checking a different path from execution.
|
|
146
115
|
if (typeof raw !== "string" ||
|
|
147
116
|
!raw.trim() ||
|
|
148
117
|
raw !== raw.trim() ||
|
|
@@ -198,8 +167,6 @@ export function evaluateSandboxJail(sandbox, toolName, params, cwd, policy = {})
|
|
|
198
167
|
}
|
|
199
168
|
if (!sandboxJailPath(".", cwd, sandbox.path))
|
|
200
169
|
return deny("Sandbox workspace is unavailable or outside its boundary.");
|
|
201
|
-
// The trusted host must validate both endpoints against the captured sandbox identity.
|
|
202
|
-
// Tool arguments cannot grant trust or select a different security boundary.
|
|
203
170
|
if (toolName === "communicate") {
|
|
204
171
|
return typeof p.action === "string" && ["read", "send", "request", "reply", "escalate"].includes(p.action)
|
|
205
172
|
? null
|
|
@@ -215,7 +182,6 @@ export function evaluateSandboxJail(sandbox, toolName, params, cwd, policy = {})
|
|
|
215
182
|
case "write":
|
|
216
183
|
case "edit":
|
|
217
184
|
case "edit_soft":
|
|
218
|
-
// Validate both aliases when present; different implementations choose different precedence.
|
|
219
185
|
if (p.path !== undefined)
|
|
220
186
|
paths.push(p.path);
|
|
221
187
|
if (p.file_path !== undefined)
|
|
@@ -223,15 +189,11 @@ export function evaluateSandboxJail(sandbox, toolName, params, cwd, policy = {})
|
|
|
223
189
|
break;
|
|
224
190
|
case "grep":
|
|
225
191
|
case "find":
|
|
226
|
-
// Host ownership alone does not make SDK search safe: inherited
|
|
227
|
-
// configuration (e.g. RIPGREP_CONFIG_PATH/--pre) can execute code.
|
|
228
|
-
// Reject direct wrapper calls too, until a safe search backend exists.
|
|
229
192
|
return deny("Search requires a verified safe backend without host execution or inherited executable configuration; trusted tool ownership alone is insufficient.");
|
|
230
193
|
case "patch": {
|
|
231
194
|
if (typeof p.patch !== "string" || !p.patch.trim())
|
|
232
195
|
return deny("Missing patch targets.");
|
|
233
196
|
paths.push(...extractPatchTargetPaths(p.patch));
|
|
234
|
-
// Hashline MV is an additional destination, not a section header.
|
|
235
197
|
for (const line of p.patch.split(/\r?\n/)) {
|
|
236
198
|
const move = line.trim().match(/^MV\s+([^\s]+)/i);
|
|
237
199
|
if (move)
|
|
@@ -253,9 +215,6 @@ export function evaluateSandboxJail(sandbox, toolName, params, cwd, policy = {})
|
|
|
253
215
|
}
|
|
254
216
|
return null;
|
|
255
217
|
}
|
|
256
|
-
/**
|
|
257
|
-
* 为工具包一层「沙盒硬围栏」:当 `getSandbox()` 返回非空时,对越界写操作与源项目触达直接硬拒绝。
|
|
258
|
-
*/
|
|
259
218
|
export function withSandboxJailGate(tool, getSandbox, getCwd, getLang, policy = {}, acquireExecution) {
|
|
260
219
|
return {
|
|
261
220
|
...tool,
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sandbox — AI 智能体侧的隔离沙盒项目管理工具。
|
|
3
|
-
*
|
|
4
|
-
* 支持动作:
|
|
5
|
-
* - list: 列出当前受管的所有沙盒项目,并指出当前工作区是否处于沙盒内;
|
|
6
|
-
* - create: 创建「空白沙盒」或「导入现有项目」的隔离沙盒副本(可选 switchTo 切换工作区,或将返回的 path 传给 subagent cwd);
|
|
7
|
-
* - diff: 对比沙盒与源项目之间的新增/修改/删除文件清单;
|
|
8
|
-
* - reset: 将沙盒重置回初始干净状态(清空或重新从源项目复制);
|
|
9
|
-
* - persist: 将临时沙盒转为永久沙盒;
|
|
10
|
-
* - promote: 将沙盒导出为外部正式项目目录;
|
|
11
|
-
* - apply_to_source: 将导入型沙盒的修改同步写回源项目(强制触发用户审批确认 askApproval);
|
|
12
|
-
* - destroy: 销毁指定沙盒并回收磁盘空间。
|
|
13
|
-
*/
|
|
14
1
|
import { Type } from "typebox";
|
|
15
2
|
import { existsSync } from "node:fs";
|
|
16
3
|
import { homedir } from "node:os";
|
|
@@ -51,7 +38,6 @@ const SandboxParameters = Type.Object({
|
|
|
51
38
|
description: "promote: destination directory path outside sandboxes (must be a new or empty directory).",
|
|
52
39
|
})),
|
|
53
40
|
});
|
|
54
|
-
/** details 摘录中最多携带的文件路径条目数(严格守卫 details ≤ 64KB 预算)。 */
|
|
55
41
|
const MAX_DIFF_FILES_IN_DETAILS = 100;
|
|
56
42
|
export function makeSandboxTool(host, getLang) {
|
|
57
43
|
return {
|
|
@@ -265,7 +251,6 @@ export function makeSandboxTool(host, getLang) {
|
|
|
265
251
|
isError: true,
|
|
266
252
|
};
|
|
267
253
|
}
|
|
268
|
-
// 强制触发人工审批:写回源项目会修改真实工作区文件,绝不允许静默执行
|
|
269
254
|
if (host.askApproval) {
|
|
270
255
|
const diffSummaryZh = [
|
|
271
256
|
diff.added.length > 0 ? `新增 ${diff.added.length}` : "",
|
|
@@ -355,9 +340,6 @@ export function makeSandboxTool(host, getLang) {
|
|
|
355
340
|
isError: true,
|
|
356
341
|
};
|
|
357
342
|
}
|
|
358
|
-
// 销毁会 rm -rf 整个沙盒目录(可能含用户转正后的工作成果),
|
|
359
|
-
// 与 apply_to_source 同样强制人工审批——bash 跑 rm -rf 都会命中
|
|
360
|
-
// 内置审批规则,工具路径不该有绕过口
|
|
361
343
|
if (host.askApproval) {
|
|
362
344
|
const decision = await host.askApproval(toolCallId, SANDBOX_TOOL_NAME, {
|
|
363
345
|
action: "destroy",
|
|
@@ -382,8 +364,6 @@ export function makeSandboxTool(host, getLang) {
|
|
|
382
364
|
};
|
|
383
365
|
}
|
|
384
366
|
}
|
|
385
|
-
// 若当前工作区正好在该沙盒内,先切出去(源项目优先,空白沙盒回退
|
|
386
|
-
// homedir——否则销毁后 cwd 悬空,后续 bash/read/write 全部 ENOENT)
|
|
387
367
|
if (activeSbx?.id === targetInfo.id) {
|
|
388
368
|
await host.setCwd(targetInfo.sourcePath && existsSync(targetInfo.sourcePath) ? targetInfo.sourcePath : homedir());
|
|
389
369
|
}
|
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// schedule-agent-tool.ts — 把内置调度器暴露给 Agent(issue #193)
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// 背景:pi-web-ui 早有完整调度基建(SchedulerStore:cron/间隔触发+持久化+
|
|
5
|
-
// 无头执行,见 scheduler-tasks.ts),但只停留在插件 API 与图形面板层面 ——
|
|
6
|
-
// AI 被用户要求“每小时检查一次”“半小时后提醒我”时手里没有工具,只能用
|
|
7
|
-
// sleep 死循环假装答应(休眠的会话根本推不回消息)。
|
|
8
|
-
//
|
|
9
|
-
// 本文件注册一个标准 pi 引擎 customTool(DSH 引擎无 customTool 注册面,不接):
|
|
10
|
-
// schedule(action="create") → 建任务(默认绑定发起对话+单次,用熟即删);
|
|
11
|
-
// schedule(action="list") → 看全部任务(含下次触发/上次结果);
|
|
12
|
-
// schedule(action="cancel") → 按 id 删任务。
|
|
13
|
-
// (历史上是 schedule_task / schedule_list / schedule_cancel 三个独立工具,已合并为
|
|
14
|
-
// 单 action 工具以减少工具条目与上下文开销;旧工具名仍在持久化配置迁移里兼容。)
|
|
15
|
-
// 到期执行走 index.ts 的 executor:目标对话还在 → steer 语义唤醒它(不切用户
|
|
16
|
-
// 当前对话);不在了(关闭/重启)→ 回落原有无头执行;单次任务触发后自动删除。
|
|
17
|
-
//
|
|
18
|
-
// 文案约定:工具 definition(description/promptSnippet/promptGuidelines)为纯英文;per-call
|
|
19
|
-
// 返回文本按 lang 取 pick(lang, zh, en, key, vars),缺表回落英文内联。
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
1
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
22
2
|
import { Type } from "typebox";
|
|
23
3
|
import { pick } from "./i18n.js";
|
|
24
4
|
import { SCHEDULE_TOOL_NAME } from "./tool-manager.js";
|
|
25
5
|
import { computeNextFire, describeIntervalMs, SCHEDULER_MIN_INTERVAL_MS, SchedulerValidationError, } from "./scheduler-tasks.js";
|
|
26
6
|
import { parseCronSpec } from "./plugin-schedule.js";
|
|
27
|
-
/** 用户写法 → 调度规格。纯函数,可单测。
|
|
28
|
-
* 收:5 字段 cron("0 * * * *")、相对时间("in 30m" / "in 1h" / "in 2d")、
|
|
29
|
-
* 裸时长("30m" / "1h",裸数字按分钟)。单位 s/m/h/d/w(大小写不敏感)。 */
|
|
30
7
|
export function parseScheduleSpec(raw) {
|
|
31
8
|
const s = String(raw ?? "").trim();
|
|
32
9
|
if (!s)
|
|
33
10
|
throw new Error("empty");
|
|
34
11
|
const single = s.replace(/\s+/g, " ");
|
|
35
|
-
// 5 字段即按 cron 试("in 30m"是 2 段,不会误判)。
|
|
36
12
|
if (single.split(" ").length === 5 && parseCronSpec(single)) {
|
|
37
13
|
return { kind: "cron", spec: single };
|
|
38
14
|
}
|
|
@@ -50,7 +26,7 @@ export function parseScheduleSpec(raw) {
|
|
|
50
26
|
? 3_600_000
|
|
51
27
|
: unit.startsWith("d")
|
|
52
28
|
? 86_400_000
|
|
53
|
-
: 7 * 86_400_000;
|
|
29
|
+
: 7 * 86_400_000;
|
|
54
30
|
const ms = Math.floor(n * mult);
|
|
55
31
|
if (!Number.isFinite(ms) || ms <= 0)
|
|
56
32
|
throw new Error(`时长非法:${s}`);
|
|
@@ -66,7 +42,6 @@ function fmtTime(ms, lang) {
|
|
|
66
42
|
return new Date(ms).toISOString();
|
|
67
43
|
}
|
|
68
44
|
}
|
|
69
|
-
/** 任务一行摘要(列表用;cron 显示原样,interval 中文用“每 X”,英文用秒数)。 */
|
|
70
45
|
function taskLine(t, lang) {
|
|
71
46
|
const when = t.kind === "cron"
|
|
72
47
|
? `cron ${t.spec}`
|
|
@@ -183,8 +158,6 @@ export function makeScheduleTool(host, ownerConversationId, lang) {
|
|
|
183
158
|
const name = labelRaw || prompt.split("\n")[0].slice(0, 40) || (isCanvas ? `Canvas ${graphId}` : "定时任务");
|
|
184
159
|
const convId = source?.conversationId ??
|
|
185
160
|
((ownerConversationId ?? "").trim() || String(host.activeConversationId() ?? "").trim());
|
|
186
|
-
// 稳定绑定(issue #231):owner 对话的落盘会话文件 —— 压缩/重启后靠它重认同一会话,
|
|
187
|
-
// 内存对话 id(c1/c2…)只做首选唤醒键。宿主没实现 conversationInfo 时按原来只绑 id。
|
|
188
161
|
let bindCwd = cwd;
|
|
189
162
|
let bindSessionFile = source?.sessionFile ?? "";
|
|
190
163
|
try {
|
|
@@ -199,9 +172,7 @@ export function makeScheduleTool(host, ownerConversationId, lang) {
|
|
|
199
172
|
.slice(0, 1024);
|
|
200
173
|
}
|
|
201
174
|
}
|
|
202
|
-
catch {
|
|
203
|
-
/* 绑定快照尽力而为:拿不到稳定键就按原来的 id 绑定触发 */
|
|
204
|
-
}
|
|
175
|
+
catch { }
|
|
205
176
|
const recurring = p.recurring === true;
|
|
206
177
|
let task;
|
|
207
178
|
try {
|