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,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* durable-models.ts — Pi Durable 引擎的全局模型继承与提供商装配器。
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 1. 继承全局模型事实源:从 SDK ModelRuntime 与 models.json 聚合全量可用模型;
|
|
6
|
-
* 2. 装配 @earendil-works/pi-ai 的 models 容器,注入内置与自定义 Providers(带 API Key 与 BaseURL);
|
|
7
|
-
* 3. 解析用户选择的 activeModel,传递给 Durable Conversation 运行时。
|
|
8
|
-
*/
|
|
9
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
10
2
|
import { join } from "node:path";
|
|
11
3
|
import { homedir } from "node:os";
|
|
@@ -19,13 +11,8 @@ function mergeProviderHeaders(...sources) {
|
|
|
19
11
|
}
|
|
20
12
|
return Object.fromEntries(headers.values());
|
|
21
13
|
}
|
|
22
|
-
/**
|
|
23
|
-
* 聚合全局所有已鉴权、可用的模型名录(包括官方内置模型与用户自定义模型)。
|
|
24
|
-
* 优先收录并前置展示 models.json 中的用户自定义服务商与模型。
|
|
25
|
-
*/
|
|
26
14
|
export async function listGlobalAvailableModels(cwd, agentDir) {
|
|
27
15
|
const modelMap = new Map();
|
|
28
|
-
// 1. 优先收录 models.json 中的用户自定义模型(本地代理/自定义端点通常为首选活动端点)
|
|
29
16
|
try {
|
|
30
17
|
const customModels = listCustomModelsFromConfig(agentDir, (entry) => isProtocolSupportedByEngine("durable", entry.api, entry.providerId, entry.modelId));
|
|
31
18
|
for (const cm of customModels) {
|
|
@@ -41,17 +28,13 @@ export async function listGlobalAvailableModels(cwd, agentDir) {
|
|
|
41
28
|
}
|
|
42
29
|
}
|
|
43
30
|
}
|
|
44
|
-
catch {
|
|
45
|
-
/* ignore */
|
|
46
|
-
}
|
|
47
|
-
// 2. 补充 SDK ModelRuntime 动态获取的官方与外部模型
|
|
31
|
+
catch { }
|
|
48
32
|
try {
|
|
49
33
|
const piSdk = await import(/* webpackIgnore: true */ "@earendil-works/pi-coding-agent").catch(() => null);
|
|
50
34
|
if (piSdk && typeof piSdk.createAgentSessionServices === "function") {
|
|
51
35
|
const services = await piSdk.createAgentSessionServices({ cwd, agentDir });
|
|
52
36
|
const available = await services.modelRuntime.getAvailable();
|
|
53
37
|
for (const m of available) {
|
|
54
|
-
// 严格按照实际协议类型进行过滤(绝不按模型名字猜测)
|
|
55
38
|
if (!isProtocolSupportedByEngine("durable", m.api, m.provider, m.id)) {
|
|
56
39
|
continue;
|
|
57
40
|
}
|
|
@@ -68,21 +51,15 @@ export async function listGlobalAvailableModels(cwd, agentDir) {
|
|
|
68
51
|
}
|
|
69
52
|
}
|
|
70
53
|
}
|
|
71
|
-
catch {
|
|
72
|
-
/* SDK model runtime load failed, fall back to models.json */
|
|
73
|
-
}
|
|
54
|
+
catch { }
|
|
74
55
|
return Array.from(modelMap.values());
|
|
75
56
|
}
|
|
76
|
-
/**
|
|
77
|
-
* 为 Pi Durable Harness 装配并初始化全局模型服务(@earendil-works/pi-ai Models 实例)。
|
|
78
|
-
*/
|
|
79
57
|
export async function setupDurableModels(agentDir) {
|
|
80
58
|
const aiModule = await loadDurablePeerModule("@earendil-works/pi-ai", "models").catch(() => null);
|
|
81
59
|
if (!aiModule || typeof aiModule.createModels !== "function") {
|
|
82
60
|
return {};
|
|
83
61
|
}
|
|
84
62
|
const models = aiModule.createModels();
|
|
85
|
-
// 1. 尝试全量装载内置提供商(providers/all 包含 opencode-go、openrouter 等 42+ 个提供商)
|
|
86
63
|
try {
|
|
87
64
|
const allProvidersModule = await loadDurablePeerModule("@earendil-works/pi-ai", "providers/all").catch(() => null);
|
|
88
65
|
if (allProvidersModule && typeof allProvidersModule.builtinProviders === "function") {
|
|
@@ -94,10 +71,7 @@ export async function setupDurableModels(agentDir) {
|
|
|
94
71
|
}
|
|
95
72
|
}
|
|
96
73
|
}
|
|
97
|
-
catch {
|
|
98
|
-
/* ignore fallback to minimal builtins */
|
|
99
|
-
}
|
|
100
|
-
// 2. 兜底保障基础内置提供商
|
|
74
|
+
catch { }
|
|
101
75
|
const fallbackBuiltinIds = ["openai", "anthropic", "google", "google-vertex", "mistral", "groq", "deepseek"];
|
|
102
76
|
for (const pid of fallbackBuiltinIds) {
|
|
103
77
|
if (models.providers && models.providers.has(pid))
|
|
@@ -113,11 +87,8 @@ export async function setupDurableModels(agentDir) {
|
|
|
113
87
|
}
|
|
114
88
|
}
|
|
115
89
|
}
|
|
116
|
-
catch {
|
|
117
|
-
/* provider loading skipped */
|
|
118
|
-
}
|
|
90
|
+
catch { }
|
|
119
91
|
}
|
|
120
|
-
// 3. 继承持久化动态模型缓存 (~/.pi/agent/models-store.json)
|
|
121
92
|
let cachedProviders = {};
|
|
122
93
|
try {
|
|
123
94
|
const userAgentDir = agentDir || join(homedir(), ".pi", "agent");
|
|
@@ -160,10 +131,7 @@ export async function setupDurableModels(agentDir) {
|
|
|
160
131
|
}
|
|
161
132
|
}
|
|
162
133
|
}
|
|
163
|
-
catch {
|
|
164
|
-
/* dynamic models store read skipped */
|
|
165
|
-
}
|
|
166
|
-
// 4. 动态加载 models.json 中的自定义服务商与模型
|
|
134
|
+
catch { }
|
|
167
135
|
try {
|
|
168
136
|
const { providers: customProviders } = readModelsJson(agentDir);
|
|
169
137
|
const implementations = {};
|
|
@@ -179,9 +147,7 @@ export async function setupDurableModels(agentDir) {
|
|
|
179
147
|
if (typeof module?.[factory] === "function")
|
|
180
148
|
implementations[protocol] = module[factory]();
|
|
181
149
|
}
|
|
182
|
-
catch {
|
|
183
|
-
/* An unavailable API must not suppress unrelated providers. */
|
|
184
|
-
}
|
|
150
|
+
catch { }
|
|
185
151
|
}
|
|
186
152
|
for (const [providerId, pConfig] of Object.entries(customProviders)) {
|
|
187
153
|
if (!pConfig || typeof pConfig !== "object")
|
|
@@ -234,8 +200,6 @@ export async function setupDurableModels(agentDir) {
|
|
|
234
200
|
api: implementations,
|
|
235
201
|
});
|
|
236
202
|
if (builtin) {
|
|
237
|
-
// Keep native authentication and operations (ADC/OAuth, images, discovery).
|
|
238
|
-
// Only explicit API overrides opt into a different SDK implementation.
|
|
239
203
|
const overridden = (model) => apiOverride ||
|
|
240
204
|
rawModels.some((m) => m.id === model.id && (m.type ?? "chat") === (model.type ?? "chat") && m.api);
|
|
241
205
|
models.setProvider({
|
|
@@ -253,10 +217,7 @@ export async function setupDurableModels(agentDir) {
|
|
|
253
217
|
}
|
|
254
218
|
}
|
|
255
219
|
}
|
|
256
|
-
catch {
|
|
257
|
-
/* custom provider setup skipped */
|
|
258
|
-
}
|
|
259
|
-
// 5. 为所有已注册 Provider 注入凭证与 BaseURL
|
|
220
|
+
catch { }
|
|
260
221
|
try {
|
|
261
222
|
const { providers } = readModelsJson(agentDir);
|
|
262
223
|
if (models.providers && typeof models.providers.keys === "function") {
|
|
@@ -277,8 +238,6 @@ export async function setupDurableModels(agentDir) {
|
|
|
277
238
|
p.baseUrl = cred.baseUrl;
|
|
278
239
|
if (cred.headers)
|
|
279
240
|
p.headers = { ...p.headers, ...cred.headers };
|
|
280
|
-
// pi-ai streams consume model.baseUrl/headers, not provider metadata.
|
|
281
|
-
// Apply provider defaults before explicit per-model configuration.
|
|
282
241
|
const overrides = Array.isArray(pConfig?.models) ? pConfig.models : [];
|
|
283
242
|
for (const method of ["getModels", "getAllModels"]) {
|
|
284
243
|
if (typeof p[method] !== "function")
|
|
@@ -300,24 +259,17 @@ export async function setupDurableModels(agentDir) {
|
|
|
300
259
|
}
|
|
301
260
|
}
|
|
302
261
|
}
|
|
303
|
-
catch {
|
|
304
|
-
/* credential hydration skipped */
|
|
305
|
-
}
|
|
262
|
+
catch { }
|
|
306
263
|
return models;
|
|
307
264
|
}
|
|
308
|
-
/**
|
|
309
|
-
* 将形如 "openai/gpt-4o" 或 "gpt-4o" 的模型标识解析为 Durable 引擎可识别的 provider 与 modelId。
|
|
310
|
-
*/
|
|
311
265
|
export function resolveDurableModelChoice(modelId, fallbackList, agentDir) {
|
|
312
266
|
if (!modelId || !modelId.trim() || modelId === "default") {
|
|
313
267
|
if (fallbackList && fallbackList.length > 0) {
|
|
314
|
-
// 1. 优先在 fallbackList 中寻找用户在 models.json 里明确配置的自定义端点模型
|
|
315
268
|
const { providers: customConfig } = readModelsJson(agentDir);
|
|
316
269
|
const customFirst = fallbackList.find((m) => Object.prototype.hasOwnProperty.call(customConfig, m.provider));
|
|
317
270
|
if (customFirst) {
|
|
318
271
|
return { provider: customFirst.provider, modelId: customFirst.id.replace(`${customFirst.provider}/`, "") };
|
|
319
272
|
}
|
|
320
|
-
// 2. 其次寻找具备有效 baseUrl 或独立 apiKey 的可用模型
|
|
321
273
|
const configured = fallbackList.find((m) => {
|
|
322
274
|
const cred = resolveProviderCredential(agentDir, m.provider);
|
|
323
275
|
return Boolean(cred.baseUrl || cred.apiKey);
|
|
@@ -335,7 +287,6 @@ export function resolveDurableModelChoice(modelId, fallbackList, agentDir) {
|
|
|
335
287
|
modelId: trimmed.slice(slashIdx + 1),
|
|
336
288
|
};
|
|
337
289
|
}
|
|
338
|
-
// 若未带 provider 前缀,尝试在已知列表中寻找匹配项
|
|
339
290
|
if (fallbackList) {
|
|
340
291
|
const found = fallbackList.find((m) => m.id === trimmed || m.id.endsWith(`/${trimmed}`));
|
|
341
292
|
if (found) {
|
|
@@ -350,9 +301,6 @@ export function resolveDurableModelChoice(modelId, fallbackList, agentDir) {
|
|
|
350
301
|
modelId: trimmed,
|
|
351
302
|
};
|
|
352
303
|
}
|
|
353
|
-
/**
|
|
354
|
-
* 根据模型配置(reasoning 与 thinkingLevelMap)解析支持的思考强度档位。
|
|
355
|
-
*/
|
|
356
304
|
export function calculateSupportedThinkingLevels(modelDef) {
|
|
357
305
|
if (!modelDef) {
|
|
358
306
|
return ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
@@ -371,12 +319,8 @@ export function calculateSupportedThinkingLevels(modelDef) {
|
|
|
371
319
|
return true;
|
|
372
320
|
});
|
|
373
321
|
}
|
|
374
|
-
// 默认具备 reasoning 能力时支持 off, minimal, low, medium, high
|
|
375
322
|
return ["off", "minimal", "low", "medium", "high"];
|
|
376
323
|
}
|
|
377
|
-
/**
|
|
378
|
-
* 快速同步解析指定模型的思考能力(优先 models 容器,次之 models.json / models-store.json / cachedModels)。
|
|
379
|
-
*/
|
|
380
324
|
export function resolveDurableThinkingLevels(modelId, options) {
|
|
381
325
|
if (!modelId || !modelId.trim() || modelId === "default") {
|
|
382
326
|
return ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
@@ -384,7 +328,6 @@ export function resolveDurableThinkingLevels(modelId, options) {
|
|
|
384
328
|
const choice = resolveDurableModelChoice(modelId, options?.cachedModels, options?.agentDir);
|
|
385
329
|
const provider = choice?.provider;
|
|
386
330
|
const bareModelId = choice?.modelId;
|
|
387
|
-
// 1. 尝试从已装配的 models 容器中取
|
|
388
331
|
if (options?.modelsContainer && typeof options.modelsContainer.getModel === "function" && provider && bareModelId) {
|
|
389
332
|
try {
|
|
390
333
|
const m = options.modelsContainer.getModel(provider, bareModelId);
|
|
@@ -392,11 +335,8 @@ export function resolveDurableThinkingLevels(modelId, options) {
|
|
|
392
335
|
return calculateSupportedThinkingLevels(m);
|
|
393
336
|
}
|
|
394
337
|
}
|
|
395
|
-
catch {
|
|
396
|
-
/* ignore */
|
|
397
|
-
}
|
|
338
|
+
catch { }
|
|
398
339
|
}
|
|
399
|
-
// 2. 尝试从 models.json 中取
|
|
400
340
|
try {
|
|
401
341
|
const { providers } = readModelsJson(options?.agentDir);
|
|
402
342
|
if (provider && providers[provider]?.models && Array.isArray(providers[provider].models)) {
|
|
@@ -406,7 +346,6 @@ export function resolveDurableThinkingLevels(modelId, options) {
|
|
|
406
346
|
return calculateSupportedThinkingLevels(found);
|
|
407
347
|
}
|
|
408
348
|
}
|
|
409
|
-
// 若按 provider 未匹配,遍历所有 provider 寻找裸模型 ID 匹配
|
|
410
349
|
for (const pConfig of Object.values(providers)) {
|
|
411
350
|
if (Array.isArray(pConfig?.models)) {
|
|
412
351
|
const found = pConfig.models.find((m) => m.id === bareModelId);
|
|
@@ -416,10 +355,7 @@ export function resolveDurableThinkingLevels(modelId, options) {
|
|
|
416
355
|
}
|
|
417
356
|
}
|
|
418
357
|
}
|
|
419
|
-
catch {
|
|
420
|
-
/* ignore */
|
|
421
|
-
}
|
|
422
|
-
// 3. 尝试从 models-store.json 中取
|
|
358
|
+
catch { }
|
|
423
359
|
try {
|
|
424
360
|
const userAgentDir = options?.agentDir || join(homedir(), ".pi", "agent");
|
|
425
361
|
const storePath = join(userAgentDir, "models-store.json");
|
|
@@ -431,7 +367,6 @@ export function resolveDurableThinkingLevels(modelId, options) {
|
|
|
431
367
|
return calculateSupportedThinkingLevels(found);
|
|
432
368
|
}
|
|
433
369
|
}
|
|
434
|
-
// 若按 provider 未匹配,遍历 store 所有 provider 寻找裸模型 ID 匹配
|
|
435
370
|
for (const pData of Object.values(store)) {
|
|
436
371
|
if (Array.isArray(pData?.models)) {
|
|
437
372
|
const found = pData.models.find((m) => m.id === bareModelId);
|
|
@@ -442,10 +377,7 @@ export function resolveDurableThinkingLevels(modelId, options) {
|
|
|
442
377
|
}
|
|
443
378
|
}
|
|
444
379
|
}
|
|
445
|
-
catch {
|
|
446
|
-
/* ignore */
|
|
447
|
-
}
|
|
448
|
-
// 4. 尝试从 cachedModels 中取
|
|
380
|
+
catch { }
|
|
449
381
|
if (options?.cachedModels && options.cachedModels.length > 0) {
|
|
450
382
|
const found = options.cachedModels.find((m) => m.id === modelId ||
|
|
451
383
|
m.id.endsWith(`/${bareModelId}`) ||
|
|
@@ -454,6 +386,5 @@ export function resolveDurableThinkingLevels(modelId, options) {
|
|
|
454
386
|
return ["off"];
|
|
455
387
|
}
|
|
456
388
|
}
|
|
457
|
-
// 未明确识别或通用兜底
|
|
458
389
|
return ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
459
390
|
}
|
|
@@ -1,38 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* durable-storage.ts — Pi Durable 存储后端管理与目录初始化。
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 1. 自动为每个工作区或全局建立 SQLite 持久化存储(WAL 模式);
|
|
6
|
-
* 2. 动态加载 @earendil-works/pi-durable 的持久化仓储驱动;
|
|
7
|
-
* 3. 当未安装原生包或缺少编译依赖时,优雅回退到内存存储或报错。
|
|
8
|
-
*/
|
|
9
1
|
import { existsSync, mkdirSync } from "node:fs";
|
|
10
2
|
import { createHash } from "node:crypto";
|
|
11
3
|
import { join } from "node:path";
|
|
12
4
|
import { loadDurableModule } from "./durable-loader.js";
|
|
13
|
-
/**
|
|
14
|
-
* 为指定工作区 cwd 解析或创建 SQLite 存储实例。
|
|
15
|
-
*/
|
|
16
5
|
export async function openDurableStorage(dataDir, cwd) {
|
|
17
6
|
const durableDir = join(dataDir, "durable");
|
|
18
7
|
if (!existsSync(durableDir)) {
|
|
19
8
|
mkdirSync(durableDir, { recursive: true });
|
|
20
9
|
}
|
|
21
|
-
// 按 cwd 的 hash 区分项目存储,避免多项目写入同一库发生锁争用
|
|
22
10
|
const slug = createHash("sha256").update(cwd).digest("hex").slice(0, 12);
|
|
23
11
|
const dbPath = join(durableDir, `session-${slug}.sqlite`);
|
|
24
12
|
try {
|
|
25
|
-
// 动态通过全局/本地加载器加载 SQLite 持久层
|
|
26
13
|
const sqliteModule = await loadDurableModule("storage/sqlite/node").catch(() => null);
|
|
27
14
|
if (sqliteModule && typeof sqliteModule.openNodeSqliteStorage === "function") {
|
|
28
15
|
const storage = await sqliteModule.openNodeSqliteStorage(dbPath);
|
|
29
16
|
return { storage, path: dbPath, isMemory: false };
|
|
30
17
|
}
|
|
31
18
|
}
|
|
32
|
-
catch {
|
|
33
|
-
/* sqlite native driver not available, fall back to memory */
|
|
34
|
-
}
|
|
35
|
-
// 动态尝试加载 MemoryStorage
|
|
19
|
+
catch { }
|
|
36
20
|
const coreModule = await loadDurableModule().catch(() => null);
|
|
37
21
|
if (coreModule && coreModule.MemoryStorage) {
|
|
38
22
|
const storage = new coreModule.MemoryStorage();
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* durable-tools.ts — Pi Durable 引擎的工具加载与环境装配。
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 1. 动态加载 @earendil-works/pi-durable/tools 中的官方 CodingTools(read/write/edit/bash);
|
|
6
|
-
* 2. 装配 Registry,注入工作区路径、图片处理器及自定义扩展;
|
|
7
|
-
* 3. 将现有的工具结果(三通道:output / structuredOutput / details)安全适配给 UI。
|
|
8
|
-
*/
|
|
9
1
|
import { loadDurableModule } from "./durable-loader.js";
|
|
10
|
-
|
|
11
|
-
* 为指定工作区配置 Durable Registry 和工具链。
|
|
12
|
-
*/
|
|
13
|
-
export async function setupDurableRegistry(cwd,
|
|
14
|
-
// 预留位(尚未消费):`allowDangerous` / `onToolOutput` 现在没有任何实现,
|
|
15
|
-
// 保留参数形状,后续接线时不必改调用方。
|
|
16
|
-
_options) {
|
|
2
|
+
export async function setupDurableRegistry(cwd, _options) {
|
|
17
3
|
const durableModule = await loadDurableModule().catch(() => null);
|
|
18
4
|
if (!durableModule || typeof durableModule.createRegistry !== "function") {
|
|
19
5
|
throw new Error("Pi Durable 依赖未安装。请运行 npm i -g @earendil-works/pi-durable 启用该引擎。");
|
|
20
6
|
}
|
|
21
7
|
const registry = durableModule.createRegistry();
|
|
22
8
|
const installedToolNames = [];
|
|
23
|
-
// 动态尝试加载官方编码工具
|
|
24
9
|
try {
|
|
25
10
|
const toolsModule = await loadDurableModule("tools").catch(() => null);
|
|
26
11
|
if (toolsModule && toolsModule.CodingTools) {
|
|
@@ -28,10 +13,7 @@ _options) {
|
|
|
28
13
|
installedToolNames.push("read", "write", "edit", "bash");
|
|
29
14
|
}
|
|
30
15
|
}
|
|
31
|
-
catch {
|
|
32
|
-
/* coding tools load failed */
|
|
33
|
-
}
|
|
34
|
-
// 注入工作区路径环境配置(如果存在 defineExtension)
|
|
16
|
+
catch { }
|
|
35
17
|
if (typeof durableModule.defineExtension === "function") {
|
|
36
18
|
const WorkspaceEnv = durableModule.defineExtension({
|
|
37
19
|
name: "workspace_env",
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* edit_soft —— 一个「不严格要求缩进」的独立编辑工具(不覆盖内置 edit)。
|
|
3
|
-
*
|
|
4
|
-
* 背景:内置 `edit` 的 oldText 必须与文件恰好匹配(含缩进/空白)。某些语言
|
|
5
|
-
* (如 JS/JSON)缩进不是语法的一部分,模型给出 oldText 时常常在缩进上与文件
|
|
6
|
-
* 差几个空格/制表符,导致编辑失败。edit_soft 用「逐行核心 = 去掉行首+行尾空白」
|
|
7
|
-
* 做宽松匹配:只要每行的内容一致、缩进不同也能命中。
|
|
8
|
-
*
|
|
9
|
-
* 语义约定:
|
|
10
|
-
* - 先试精确子串匹配(与 edit 相同)。
|
|
11
|
-
* - 精确失败后再按行宽松匹配:oldText 拆成若干行、每行取 trim 后的核心,
|
|
12
|
-
* 在文件里找一段连续行,其核心序列与 oldText 完全一致(仅唯一匹配才写)。
|
|
13
|
-
* - 命中后按「整行替换」写入 newText **原样**(AI 给的缩进就是最终缩进),
|
|
14
|
-
* 只做必要的行尾换行平衡。
|
|
15
|
-
* - 若不支持片段(oldText 不是完整行)会返回错误提示:
|
|
16
|
-
* • 多行 oldText 跨行但首/尾未对齐行边界 → 直接拒绝(否则会吃掉行首/行尾残留、
|
|
17
|
-
* 写出粘连内容);
|
|
18
|
-
* • 宽松阶段整块对不上、且首/尾行只是某行的一部分 → 报「片段」错而非笼统的「找不到」;
|
|
19
|
-
* • 单行片段(如 `b();`)不改变行结构,仍照旧支持。
|
|
20
|
-
*
|
|
21
|
-
* 开关:设置面板「编辑」页 `editSoftEnabled`(默认关)。关闭时该工具从活跃集移除。
|
|
22
|
-
*/
|
|
23
1
|
import { constants } from "node:fs";
|
|
24
2
|
import { access, readFile, writeFile } from "node:fs/promises";
|
|
25
3
|
import { homedir } from "node:os";
|
|
@@ -29,7 +7,6 @@ import { Type } from "typebox";
|
|
|
29
7
|
import { defineTool, generateDiffString, generateUnifiedPatch, withFileMutationQueue, } from "@earendil-works/pi-coding-agent";
|
|
30
8
|
import { pick } from "./i18n.js";
|
|
31
9
|
import { EDIT_SOFT_TOOL_NAME } from "./tool-manager.js";
|
|
32
|
-
/** 独立宽松编辑工具名(唯一登记见 tool-manager.ts;此处别名保兼容)。 */
|
|
33
10
|
export const SOFT_EDIT_TOOL_NAME = EDIT_SOFT_TOOL_NAME;
|
|
34
11
|
const replaceEditSchema = Type.Object({
|
|
35
12
|
oldText: Type.String({
|
|
@@ -55,7 +32,6 @@ function isSingleEditInput(value) {
|
|
|
55
32
|
const e = value;
|
|
56
33
|
return typeof e.oldText === "string" && typeof e.newText === "string";
|
|
57
34
|
}
|
|
58
|
-
/** 兼容几种模型把 edits 传成 JSON 字符串 / 单个对象的写法 + 遗留顶层 oldText/newText。 */
|
|
59
35
|
function prepareSoftEditArguments(input) {
|
|
60
36
|
if (!input || typeof input !== "object")
|
|
61
37
|
return input;
|
|
@@ -68,9 +44,7 @@ function prepareSoftEditArguments(input) {
|
|
|
68
44
|
else if (isSingleEditInput(parsed))
|
|
69
45
|
args.edits = [parsed];
|
|
70
46
|
}
|
|
71
|
-
catch {
|
|
72
|
-
/* 保留原值,交给校验报错 */
|
|
73
|
-
}
|
|
47
|
+
catch { }
|
|
74
48
|
}
|
|
75
49
|
else if (isSingleEditInput(args.edits)) {
|
|
76
50
|
args.edits = [args.edits];
|
|
@@ -84,9 +58,6 @@ function prepareSoftEditArguments(input) {
|
|
|
84
58
|
}
|
|
85
59
|
return args;
|
|
86
60
|
}
|
|
87
|
-
// ---------------------------------------------------------------------------
|
|
88
|
-
// 轻量 helpers(SDK 未导出,这里按等价语义重现)
|
|
89
|
-
// ---------------------------------------------------------------------------
|
|
90
61
|
function splitBom(content) {
|
|
91
62
|
return content.startsWith("\uFEFF") ? { bom: "\uFEFF", text: content.slice(1) } : { bom: "", text: content };
|
|
92
63
|
}
|
|
@@ -114,7 +85,6 @@ function normalizeShellPath(p) {
|
|
|
114
85
|
return p;
|
|
115
86
|
return `${m[1].toUpperCase()}:\\${(m[2] ?? "").replaceAll("/", "\\")}`;
|
|
116
87
|
}
|
|
117
|
-
/** 与 SDK resolveToCwd 等价:处理 ~、@ 前缀、Unicode 空格、Windows shell 路径。 */
|
|
118
88
|
function resolveToCwd(filePath, cwd) {
|
|
119
89
|
let p = filePath.replace(UNICODE_SPACES, " ");
|
|
120
90
|
if (p.startsWith("@"))
|
|
@@ -142,28 +112,18 @@ function splitLineUnits(text) {
|
|
|
142
112
|
}
|
|
143
113
|
return units;
|
|
144
114
|
}
|
|
145
|
-
/** oldText 拆成「各行核心」:去掉尾部空行(模型常带尾 \n),每行取 trim。 */
|
|
146
115
|
export function oldTextCores(oldTextLF) {
|
|
147
116
|
const parts = oldTextLF.split("\n");
|
|
148
117
|
if (parts.length > 0 && parts[parts.length - 1] === "")
|
|
149
118
|
parts.pop();
|
|
150
119
|
return parts.map((p) => p.trim());
|
|
151
120
|
}
|
|
152
|
-
/**
|
|
153
|
-
* 判断 oldText 的首行/末行是否只是「片段」(某文件行的一部分)。
|
|
154
|
-
* 宽松匹配要求每行都是完整行;当整块对不上时,若首/末行的核心确实出现在文件的
|
|
155
|
-
* **行中部**(既不在行首也不在行尾),则极可能是模型漏抄了行首/行尾。
|
|
156
|
-
*
|
|
157
|
-
* 仅在「整块核心序列一次都没命中」后才调用,因此只作诊断,不影响正常匹配。
|
|
158
|
-
*/
|
|
159
121
|
export function fragmentLineEnds(cores, units) {
|
|
160
122
|
const isMidLineFragment = (core) => {
|
|
161
123
|
if (core === "")
|
|
162
124
|
return false;
|
|
163
|
-
// 先看有没有任意一行与它整行相同:有 → 不是片段(只是缩进/上下文不对)。
|
|
164
125
|
if (units.some((u) => u.core === core))
|
|
165
126
|
return false;
|
|
166
|
-
// 再看它是否出现在某行的中部(前后都还有内容)→ 是片段。
|
|
167
127
|
return units.some((u) => {
|
|
168
128
|
const idx = u.raw.indexOf(core);
|
|
169
129
|
return idx > 0 && idx + core.length < u.raw.length;
|
|
@@ -176,53 +136,32 @@ export function fragmentLineEnds(cores, units) {
|
|
|
176
136
|
ends.push(1);
|
|
177
137
|
return ends;
|
|
178
138
|
}
|
|
179
|
-
/**
|
|
180
|
-
* 判断一段**精确命中**是否为「跨行但未对齐整行」的非法片段。
|
|
181
|
-
*
|
|
182
|
-
* 只包含单行的 oldText(如 `const x = 1; `)是安全的:替换不会改动行结构。
|
|
183
|
-
* 但若 oldText 跨越了换行、且首/尾没落在行边界(既不在行首/行尾,也没包含整行),
|
|
184
|
-
* 直接子串替换会吃掉行首/行尾的残留,写出粘连内容——例如在
|
|
185
|
-
* `foo(a);\nfoo(b);` 上把 `a);\nfoo(` 换成 `z();` 会得到 `foo(z();b);`。
|
|
186
|
-
* 这几乎总是模型漏抄行首/行尾所致,因此报错而不静默写坏。
|
|
187
|
-
*/
|
|
188
139
|
export function isMisalignedMultilineFragment(content, start, oldTextLF) {
|
|
189
140
|
if (!oldTextLF.includes("\n"))
|
|
190
|
-
return false;
|
|
141
|
+
return false;
|
|
191
142
|
const end = start + oldTextLF.length;
|
|
192
143
|
const startsAtLineStart = start === 0 || content[start - 1] === "\n";
|
|
193
144
|
const endsAtLineBoundary = end === content.length || content[end] === "\n" || content[end - 1] === "\n";
|
|
194
145
|
return !(startsAtLineStart && endsAtLineBoundary);
|
|
195
146
|
}
|
|
196
|
-
/** NOT_FOUND / NOT_UNIQUE 用异常类型区分(与内置 edit 报错风格一致)。 */
|
|
197
147
|
class SoftEditMatchError extends Error {
|
|
198
148
|
constructor(message) {
|
|
199
149
|
super(message);
|
|
200
150
|
}
|
|
201
151
|
}
|
|
202
|
-
/**
|
|
203
|
-
* 命中一个 edit:先精确,后行核心宽松。返回原文件字符区间 + 待写入文本。
|
|
204
|
-
* spans 全部相对 LF 归一化后的原文件正文。
|
|
205
|
-
*/
|
|
206
152
|
function locateReplacement(normalizedContent, oldTextLF, newTextLF, path, editIndex, lang = "en") {
|
|
207
153
|
if (oldTextLF.length === 0) {
|
|
208
154
|
throw new SoftEditMatchError(pick(lang, `edits[${editIndex}].oldText 在 ${path} 中不能为空。`, `edits[${editIndex}].oldText must not be empty in ${path}.`, "editsoft.oldtext.empty", { editIndex, path }));
|
|
209
155
|
}
|
|
210
|
-
// 1) 精确子串匹配(等价普通 edit,支持片段)
|
|
211
156
|
const exactIdx = normalizedContent.indexOf(oldTextLF);
|
|
212
|
-
// 非法片段防御:多行 oldText 若未对齐整行边界,精确子串替换会吃掉行首/行尾
|
|
213
|
-
// 残留、写出粘连内容(如 `foo(a);\nfoo(b);` 把 `a);\nfoo(` 换成 `z();` →
|
|
214
|
-
// `foo(z();b);`)。这种命中一律不走精确路径,改为交给下面的「整行宽松匹配」;
|
|
215
|
-
// 只有当整行也匹配不上时才报错拒绝(避免误伤「首行省略缩进」等合法情况)。
|
|
216
157
|
const exactMisaligned = exactIdx !== -1 && isMisalignedMultilineFragment(normalizedContent, exactIdx, oldTextLF);
|
|
217
158
|
if (exactIdx !== -1 && !exactMisaligned) {
|
|
218
|
-
// 唯一性:精确匹配出现多次 → 报错(模型应提供更多上下文)
|
|
219
159
|
const occurrences = normalizedContent.split(oldTextLF).length - 1;
|
|
220
160
|
if (occurrences > 1) {
|
|
221
161
|
throw new SoftEditMatchError(pick(lang, `在 ${path} 中找到 ${occurrences} 处 edits[${editIndex}].oldText。每个 oldText 必须唯一,请提供更多上下文。`, `Found ${occurrences} occurrences of edits[${editIndex}].oldText in ${path}. Each oldText must be unique. Please provide more context to make it unique.`, "editsoft.exact.not.unique", { path, occurrences, editIndex }));
|
|
222
162
|
}
|
|
223
163
|
return { start: exactIdx, end: exactIdx + oldTextLF.length, insertText: newTextLF };
|
|
224
164
|
}
|
|
225
|
-
// 2) 行核心宽松匹配:逐行 trim 后序列一致(忽略缩进差异)
|
|
226
165
|
const cores = oldTextCores(oldTextLF);
|
|
227
166
|
if (cores.length === 0) {
|
|
228
167
|
throw new SoftEditMatchError(pick(lang, `edits[${editIndex}].oldText 在 ${path} 中实际为空。`, `edits[${editIndex}].oldText is effectively empty in ${path}.`, "editsoft.oldtext.blank", { editIndex, path }));
|
|
@@ -242,11 +181,6 @@ function locateReplacement(normalizedContent, oldTextLF, newTextLF, path, editIn
|
|
|
242
181
|
starts.push(i);
|
|
243
182
|
}
|
|
244
183
|
if (starts.length === 0) {
|
|
245
|
-
// 非法片段诊断:宽松匹配要求 oldText 的每一行都是**完整行**。若首/尾行只是
|
|
246
|
-
// 某文件行的一部分(模型漏抄了行首/行尾,例如只给了 `a);` 而非 `foo(a);`),
|
|
247
|
-
// 逐行核心永远对不上;这里给出针对性提示,而不是笼统的「找不到」。
|
|
248
|
-
// exactMisaligned 说明精确子串能命中、但跨行且未对齐整行(会写出粘连内容),
|
|
249
|
-
// 而整行匹配又对不上 —— 这种命中绝对不能走精确路径。
|
|
250
184
|
if (exactMisaligned || fragmentLineEnds(cores, units).length > 0) {
|
|
251
185
|
throw new SoftEditMatchError(pick(lang, `在 ${path} 中找不到该文本:edits[${editIndex}].oldText 跨越多行但首/尾没有落在行边界上(首行或末行只是文件中某行的一部分),而本工具按**整行**匹配。请让 oldText 的每一行都是完整行——行首缩进可以省略,但行内容必须完整。`, `Could not find the text in ${path}: edits[${editIndex}].oldText spans multiple lines but its start/end do not fall on line boundaries (its first or last line is only part of a file line), and this tool matches whole lines. Make every line of oldText a complete line — leading indentation may be omitted, but the line content must be complete.`, "editsoft.fragment.not.supported", { path, editIndex }));
|
|
252
186
|
}
|
|
@@ -259,14 +193,12 @@ function locateReplacement(normalizedContent, oldTextLF, newTextLF, path, editIn
|
|
|
259
193
|
const ri = li + k;
|
|
260
194
|
const spanStart = units[li].start;
|
|
261
195
|
const spanEnd = units[ri - 1].end;
|
|
262
|
-
// 行尾换行平衡:若最后一行原本带 \n 而 newText 没带,补一个,避免与下一行粘连。
|
|
263
196
|
const lastNewline = units[ri - 1].newline;
|
|
264
197
|
let insertText = newTextLF;
|
|
265
198
|
if (lastNewline === "\n" && !insertText.endsWith("\n"))
|
|
266
199
|
insertText += "\n";
|
|
267
200
|
return { start: spanStart, end: spanEnd, insertText };
|
|
268
201
|
}
|
|
269
|
-
/** 对 LF 归一化内容应用一组 edit(含重叠检测),返回 {base,next}。 */
|
|
270
202
|
export function applySoftEdits(normalizedContent, edits, path, lang = "en") {
|
|
271
203
|
const replacements = [];
|
|
272
204
|
for (let i = 0; i < edits.length; i++) {
|
|
@@ -274,18 +206,12 @@ export function applySoftEdits(normalizedContent, edits, path, lang = "en") {
|
|
|
274
206
|
const newTextLF = normalizeToLF(edits[i].newText);
|
|
275
207
|
replacements.push(locateReplacement(normalizedContent, oldTextLF, newTextLF, path, i, lang));
|
|
276
208
|
}
|
|
277
|
-
// 重叠检测
|
|
278
209
|
const sorted = [...replacements].sort((a, b) => a.start - b.start);
|
|
279
210
|
for (let i = 1; i < sorted.length; i++) {
|
|
280
211
|
if (sorted[i - 1].end > sorted[i].start) {
|
|
281
212
|
throw new SoftEditMatchError(pick(lang, `在 ${path} 中的 edits 重叠。请合并为一个 edit 或定位到不相交的区域。`, `edits overlap in ${path}. Merge them into one edit or target disjoint regions.`, "editsoft.edits.overlap", { path }));
|
|
282
213
|
}
|
|
283
214
|
}
|
|
284
|
-
// 逆序应用,保持左侧偏移稳定。
|
|
285
|
-
// 关键:必须按**位置升序**(前面的 `sorted`)再逆序应用,不能按 edits 的传入
|
|
286
|
-
// 顺序逆序——模型若把靠后的 edit 写在前面,未排序的逆序应用会让后面的替换先
|
|
287
|
-
// 改变长度,前面的偏移随即串位,写出错乱内容(历史 bug:protocol.ts /
|
|
288
|
-
// use-chat.ts / ChatInput.tsx 被写坏)。内置 edit 同样先按 matchIndex 排序,此为对齐语义。
|
|
289
215
|
let result = normalizedContent;
|
|
290
216
|
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
291
217
|
const r = sorted[i];
|
|
@@ -296,11 +222,6 @@ export function applySoftEdits(normalizedContent, edits, path, lang = "en") {
|
|
|
296
222
|
}
|
|
297
223
|
return { baseContent: normalizedContent, newContent: result };
|
|
298
224
|
}
|
|
299
|
-
/**
|
|
300
|
-
* 生成 edit_soft 工具定义。与内置 edit 同结构执行体,但用宽松缩进匹配 + 原样 newText。
|
|
301
|
-
* cwd 仅供创建时固定;执行时优先 ctx.cwd(会话工作区)。
|
|
302
|
-
* getLang 为可选的服务端语言取值器(每次调用时读取,默认英文,issue #91)。
|
|
303
|
-
*/
|
|
304
225
|
export function makeEditSoftTool(fallbackCwd, getLang) {
|
|
305
226
|
return defineTool({
|
|
306
227
|
name: SOFT_EDIT_TOOL_NAME,
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* engine-capabilities.ts — 智能体底座能力声明规范与出厂事实源。
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 1. 为 pi / dsh / 通用基座(Claude Code 等)及未来第三方驱动提供标准能力声明契约;
|
|
6
|
-
* 2. 提供各内置引擎的开箱即用能力事实源(Pi 全能力、DSH 差异化子集、通用基座保守默认);
|
|
7
|
-
* 3. 辅助生成安全归一化的 AgentEngineCapabilities 对象。
|
|
8
|
-
*/
|
|
9
|
-
/** Pi 原生引擎能力:全功能全集 */
|
|
10
1
|
export const DEFAULT_PI_CAPABILITIES = Object.freeze({
|
|
11
2
|
remoteSsh: true,
|
|
12
3
|
sandboxes: true,
|
|
@@ -25,7 +16,6 @@ export const DEFAULT_PI_CAPABILITIES = Object.freeze({
|
|
|
25
16
|
steer: true,
|
|
26
17
|
ephemeralChat: true,
|
|
27
18
|
});
|
|
28
|
-
/** DSH 引擎能力:外部独立进程运行时(缺失 SSH 透明接管、conversation_read 等宿主特性) */
|
|
29
19
|
export const DEFAULT_DSH_CAPABILITIES = Object.freeze({
|
|
30
20
|
remoteSsh: false,
|
|
31
21
|
sandboxes: false,
|
|
@@ -44,7 +34,6 @@ export const DEFAULT_DSH_CAPABILITIES = Object.freeze({
|
|
|
44
34
|
steer: false,
|
|
45
35
|
ephemeralChat: false,
|
|
46
36
|
});
|
|
47
|
-
/** 通用基座保守默认能力:外部 CLI / 子进程默认仅支持纯线性消息对话 */
|
|
48
37
|
export const DEFAULT_UNIVERSAL_CAPABILITIES = Object.freeze({
|
|
49
38
|
remoteSsh: false,
|
|
50
39
|
sandboxes: false,
|
|
@@ -63,7 +52,6 @@ export const DEFAULT_UNIVERSAL_CAPABILITIES = Object.freeze({
|
|
|
63
52
|
steer: false,
|
|
64
53
|
ephemeralChat: true,
|
|
65
54
|
});
|
|
66
|
-
/** Pi Durable 引擎能力:事务化、任务图驱动的持久执行底座 */
|
|
67
55
|
export const DEFAULT_DURABLE_CAPABILITIES = Object.freeze({
|
|
68
56
|
remoteSsh: false,
|
|
69
57
|
sandboxes: false,
|
|
@@ -82,7 +70,6 @@ export const DEFAULT_DURABLE_CAPABILITIES = Object.freeze({
|
|
|
82
70
|
steer: true,
|
|
83
71
|
ephemeralChat: true,
|
|
84
72
|
});
|
|
85
|
-
/** 合并并归一化能力声明(默认回落到通用基座保守值) */
|
|
86
73
|
export function resolveEngineCapabilities(caps, base = DEFAULT_UNIVERSAL_CAPABILITIES) {
|
|
87
74
|
return {
|
|
88
75
|
...base,
|