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
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 内置定时任务调度(issue #184)。
|
|
3
|
-
*
|
|
4
|
-
* 面向普通用户的图形化调度器:任务 CRUD + cron/间隔触发 + 无头执行 +
|
|
5
|
-
* 执行历史 + 通知。底层 cron 解析复用 plugin-schedule.ts(parseCronSpec /
|
|
6
|
-
* nextCronFire),持久化走 <dataDir>/scheduler-tasks.json(全局共享,
|
|
7
|
-
* 与 client-state.json 同级),执行经调用方注入的 executor(index.ts 接
|
|
8
|
-
* AgentService.chatFromScheduler,无头伪客户端)。
|
|
9
|
-
*
|
|
10
|
-
* 定时策略:单个 10s ticker 检查到期任务(cron 下次触发 / 间隔毫秒),
|
|
11
|
-
* running 集合防重叠;catchUp "once" 在启动时补跑一次漏掉的触发。
|
|
12
|
-
*/
|
|
13
1
|
import { readFileSync } from "node:fs";
|
|
14
2
|
import { join } from "node:path";
|
|
15
3
|
import { nextCronFire, parseCronSpec } from "./plugin-schedule.js";
|
|
16
4
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
17
5
|
export const SCHEDULER_FILE = "scheduler-tasks.json";
|
|
18
|
-
/** 持久间隔底线 60s(与 host.schedule 持久任务同口径,防 token 烧穿)。 */
|
|
19
6
|
export const SCHEDULER_MIN_INTERVAL_MS = 60_000;
|
|
20
7
|
export const SCHEDULER_MAX_INTERVAL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
21
8
|
export const SCHEDULER_HISTORY_MAX = 20;
|
|
@@ -43,7 +30,6 @@ export class SchedulerValidationError extends Error {
|
|
|
43
30
|
this.name = "SchedulerValidationError";
|
|
44
31
|
}
|
|
45
32
|
}
|
|
46
|
-
/** 归一化 + 校验用户输入;非法抛 SchedulerValidationError。纯函数,可单测。 */
|
|
47
33
|
export function normalizeSchedulerInput(input, now = Date.now()) {
|
|
48
34
|
const idRaw = String(input.id ?? "").trim();
|
|
49
35
|
const id = idRaw || randomTaskId();
|
|
@@ -110,8 +96,6 @@ export function normalizeSchedulerInput(input, now = Date.now()) {
|
|
|
110
96
|
const conversationId = String(input.conversationId ?? "")
|
|
111
97
|
.trim()
|
|
112
98
|
.slice(0, 128);
|
|
113
|
-
// 落盘会话文件:稳定身份键(issue #231)。只做归一化(去首尾空白、封顶),
|
|
114
|
-
// 不校验存在性 —— 创建时刻文件可能还没落盘,触发时按它匹配不上即回落。
|
|
115
99
|
const sessionFile = String(input.sessionFile ?? "")
|
|
116
100
|
.trim()
|
|
117
101
|
.slice(0, 1024);
|
|
@@ -136,7 +120,6 @@ export function normalizeSchedulerInput(input, now = Date.now()) {
|
|
|
136
120
|
updatedAt: now,
|
|
137
121
|
};
|
|
138
122
|
}
|
|
139
|
-
/** 下次触发毫秒时间戳;非法/禁用回 null。纯函数,可单测。 */
|
|
140
123
|
export function computeNextFire(task, fromMs) {
|
|
141
124
|
try {
|
|
142
125
|
if (task.kind === "cron") {
|
|
@@ -154,7 +137,6 @@ export function computeNextFire(task, fromMs) {
|
|
|
154
137
|
return null;
|
|
155
138
|
}
|
|
156
139
|
}
|
|
157
|
-
/** 间隔任务的人类可读描述(面板显示用)。纯函数。 */
|
|
158
140
|
export function describeIntervalMs(ms) {
|
|
159
141
|
const s = Math.round(ms / 1000);
|
|
160
142
|
if (s < 60)
|
|
@@ -205,9 +187,6 @@ function sanitizeHistory(v) {
|
|
|
205
187
|
}
|
|
206
188
|
return out.sort((a, b) => b.at - a.at).slice(0, SCHEDULER_HISTORY_MAX);
|
|
207
189
|
}
|
|
208
|
-
/** 落盘会话路径是否指向同一会话(纯函数,可单测)。
|
|
209
|
-
* Windows 上 `C:\a\b` 与 `C:/a/b`、尾部分隔符差异都算同一文件;
|
|
210
|
-
* 空串永不相等(没拿到稳定键的任务不配对)。 */
|
|
211
190
|
export function sameSessionFile(a, b) {
|
|
212
191
|
const x = String(a ?? "").trim();
|
|
213
192
|
const y = String(b ?? "").trim();
|
|
@@ -231,7 +210,6 @@ export class SchedulerStore {
|
|
|
231
210
|
setExecutor(executor) {
|
|
232
211
|
this.opts.executor = executor;
|
|
233
212
|
}
|
|
234
|
-
/** 启动 ticker + catchUp 补跑(幂等)。 */
|
|
235
213
|
start() {
|
|
236
214
|
this.load();
|
|
237
215
|
if (this.started)
|
|
@@ -246,7 +224,6 @@ export class SchedulerStore {
|
|
|
246
224
|
if (next === null)
|
|
247
225
|
continue;
|
|
248
226
|
if (next <= now && task.catchUp === "once" && lastAt < now) {
|
|
249
|
-
// 重启发现漏跑:补一次,补完按这次重排。
|
|
250
227
|
this.nextFire.set(task.id, now + 5000);
|
|
251
228
|
void this.fire(task.id, false).catch((err) => this.reportFailure(err));
|
|
252
229
|
}
|
|
@@ -267,7 +244,6 @@ export class SchedulerStore {
|
|
|
267
244
|
}
|
|
268
245
|
this.started = false;
|
|
269
246
|
}
|
|
270
|
-
/** 读盘;坏文件/形状不对当空表(读路径不回写)。 */
|
|
271
247
|
load() {
|
|
272
248
|
try {
|
|
273
249
|
const parsed = JSON.parse(readFileSync(schedulerFile(this.dataDir), "utf8"));
|
|
@@ -309,9 +285,7 @@ export class SchedulerStore {
|
|
|
309
285
|
history: sanitizeHistory(r.history),
|
|
310
286
|
});
|
|
311
287
|
}
|
|
312
|
-
catch {
|
|
313
|
-
// 单条坏记录跳过,不影响其他任务
|
|
314
|
-
}
|
|
288
|
+
catch { }
|
|
315
289
|
}
|
|
316
290
|
this.tasks = next;
|
|
317
291
|
}
|
|
@@ -339,9 +313,7 @@ export class SchedulerStore {
|
|
|
339
313
|
try {
|
|
340
314
|
this.opts.onChange?.();
|
|
341
315
|
}
|
|
342
|
-
catch {
|
|
343
|
-
/* 推送失败不影响调度 */
|
|
344
|
-
}
|
|
316
|
+
catch { }
|
|
345
317
|
}
|
|
346
318
|
list() {
|
|
347
319
|
const now = Date.now();
|
|
@@ -377,10 +349,6 @@ export class SchedulerStore {
|
|
|
377
349
|
})
|
|
378
350
|
.sort((a, b) => a.name.localeCompare(b.name, "zh"));
|
|
379
351
|
}
|
|
380
|
-
/** 新建或全量更新(同名 id 覆盖);返回归一化后的任务。
|
|
381
|
-
* issue #231:面板编辑不带绑定字段(conversationId/sessionFile 缺席)时保留旧绑定 ——
|
|
382
|
-
* 否则用户在面板改个名字就会把 AI 任务的会话绑定洗掉,下次触发直接变无头。
|
|
383
|
-
* 字段显式出现(含空串)仍按全量语义覆盖。 */
|
|
384
352
|
upsert(input, origin) {
|
|
385
353
|
if (origin !== undefined && !validOrigin(origin))
|
|
386
354
|
throw new Error("Invalid scheduled-task creation origin");
|
|
@@ -409,12 +377,10 @@ export class SchedulerStore {
|
|
|
409
377
|
this.opts.validateTask?.(task);
|
|
410
378
|
const history = prev?.history ? sanitizeHistory(prev.history) : [];
|
|
411
379
|
this.save(new Map(this.tasks).set(task.id, { ...task, history }));
|
|
412
|
-
// spec/cwd/开关变了 → 按现在重排下次触发
|
|
413
380
|
this.nextFire.set(task.id, computeNextFire(task, Date.now()) ?? Date.now() + TICK_MS);
|
|
414
381
|
this.changed();
|
|
415
382
|
return task;
|
|
416
383
|
}
|
|
417
|
-
/** Commit cancellation before the caller discards transcript evidence. No awaits can race fire(). */
|
|
418
384
|
cancelUnstartedFromCalls(sessionFile, toolCallIds, commit) {
|
|
419
385
|
const next = new Map(this.tasks);
|
|
420
386
|
const removed = [];
|
|
@@ -473,9 +439,7 @@ export class SchedulerStore {
|
|
|
473
439
|
try {
|
|
474
440
|
this.opts.onTaskRemoved?.(id);
|
|
475
441
|
}
|
|
476
|
-
catch {
|
|
477
|
-
/* 回调失败不影响删除 */
|
|
478
|
-
}
|
|
442
|
+
catch { }
|
|
479
443
|
}
|
|
480
444
|
return ok;
|
|
481
445
|
}
|
|
@@ -489,9 +453,6 @@ export class SchedulerStore {
|
|
|
489
453
|
this.changed();
|
|
490
454
|
return { ...t };
|
|
491
455
|
}
|
|
492
|
-
/** 会话重绑定(issue #231):触发时按稳定键找到了新的对话句柄,把任务的
|
|
493
|
-
* 投递目标迁移过去(只改 conversationId/sessionFile/updatedAt,不碰下次触发
|
|
494
|
-
* 与历史)。无变化回 false(调用方免一次落盘+推送);未知任务回 false。 */
|
|
495
456
|
rebind(id, binding) {
|
|
496
457
|
const prev = this.tasks.get(id);
|
|
497
458
|
if (!prev || prev.target === "canvas")
|
|
@@ -523,21 +484,29 @@ export class SchedulerStore {
|
|
|
523
484
|
this.changed();
|
|
524
485
|
return true;
|
|
525
486
|
}
|
|
526
|
-
async tick() {
|
|
527
|
-
const now = Date.now();
|
|
487
|
+
async tick(now = Date.now()) {
|
|
528
488
|
for (const task of this.tasks.values()) {
|
|
529
|
-
if (!task.enabled
|
|
489
|
+
if (!task.enabled)
|
|
530
490
|
continue;
|
|
531
491
|
let next = this.nextFire.get(task.id);
|
|
532
492
|
if (next === undefined) {
|
|
533
493
|
next = computeNextFire(task, Math.max(now, task.updatedAt)) ?? now + TICK_MS;
|
|
534
494
|
this.nextFire.set(task.id, next);
|
|
535
495
|
}
|
|
536
|
-
if (
|
|
537
|
-
|
|
496
|
+
if (this.running.has(task.id)) {
|
|
497
|
+
if (next <= now) {
|
|
498
|
+
const nextSlot = computeNextFire(task, now) ?? now + TICK_MS;
|
|
499
|
+
this.nextFire.set(task.id, nextSlot);
|
|
500
|
+
this.changed();
|
|
501
|
+
this.notify("info", `定时任务「${task.name}」上一轮仍在执行中,本次定时触发已顺延至下个周期(${new Date(nextSlot).toLocaleTimeString()})。`, `Scheduled task "${task.name}" is still running from previous turn; postponed to next interval (${new Date(nextSlot).toLocaleTimeString()}).`);
|
|
502
|
+
}
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
if (next <= now) {
|
|
506
|
+
void this.fire(task.id, false, now).catch((err) => this.reportFailure(err));
|
|
507
|
+
}
|
|
538
508
|
}
|
|
539
509
|
}
|
|
540
|
-
/** 手动立即执行一次(面板 Run Now;调试用,不扰动下次触发)。 */
|
|
541
510
|
async runNow(id) {
|
|
542
511
|
const task = this.tasks.get(id);
|
|
543
512
|
if (!task)
|
|
@@ -546,12 +515,11 @@ export class SchedulerStore {
|
|
|
546
515
|
return { ok: false, error: "任务正在执行中" };
|
|
547
516
|
return this.fire(id, true);
|
|
548
517
|
}
|
|
549
|
-
async fire(id, manual) {
|
|
518
|
+
async fire(id, manual, triggerAt) {
|
|
550
519
|
const task = this.tasks.get(id);
|
|
551
520
|
if (!task)
|
|
552
521
|
return { ok: false, error: "任务不存在" };
|
|
553
522
|
const executor = this.opts.executor;
|
|
554
|
-
// Remember the attempt before any external effect, even if run-history persistence later fails.
|
|
555
523
|
if (task.origin && task.startedAt === undefined) {
|
|
556
524
|
try {
|
|
557
525
|
this.save(new Map(this.tasks).set(id, { ...task, startedAt: Date.now() }));
|
|
@@ -562,8 +530,12 @@ export class SchedulerStore {
|
|
|
562
530
|
}
|
|
563
531
|
}
|
|
564
532
|
this.running.add(id);
|
|
565
|
-
this.changed();
|
|
566
533
|
const startedAt = Date.now();
|
|
534
|
+
const scheduleBase = triggerAt !== undefined ? Math.max(triggerAt, startedAt) : startedAt;
|
|
535
|
+
if (!task.oneShot && !manual) {
|
|
536
|
+
this.nextFire.set(id, computeNextFire(task, scheduleBase) ?? scheduleBase + TICK_MS);
|
|
537
|
+
}
|
|
538
|
+
this.changed();
|
|
567
539
|
let result;
|
|
568
540
|
try {
|
|
569
541
|
result = executor
|
|
@@ -597,17 +569,21 @@ export class SchedulerStore {
|
|
|
597
569
|
this.reportFailure(err);
|
|
598
570
|
}
|
|
599
571
|
finally {
|
|
600
|
-
// 执行可能已产生外部副作用;记录写失败也不能在每个 tick 立即重试。
|
|
601
|
-
// 仅推进内存调度,使用执行期间更新后的配置,不伪造成功历史。
|
|
602
|
-
// 进程重启后仍可能补跑:本地记录与外部副作用不保证跨进程 exactly-once。
|
|
603
572
|
const cur = this.tasks.get(id);
|
|
604
573
|
if (cur && task.oneShot) {
|
|
605
|
-
// A failed history/removal write must not repeat an already attempted one-shot.
|
|
606
574
|
this.tasks.set(id, { ...cur, enabled: false });
|
|
607
575
|
this.nextFire.delete(id);
|
|
608
576
|
}
|
|
609
577
|
else if (cur && cur.enabled && !manual) {
|
|
610
|
-
|
|
578
|
+
if (cur.kind === "interval") {
|
|
579
|
+
this.nextFire.set(id, computeNextFire(cur, Date.now()) ?? Date.now() + TICK_MS);
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
const currentNext = this.nextFire.get(id);
|
|
583
|
+
if (currentNext === undefined || currentNext <= Date.now()) {
|
|
584
|
+
this.nextFire.set(id, computeNextFire(cur, Date.now()) ?? Date.now() + TICK_MS);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
611
587
|
}
|
|
612
588
|
this.running.delete(id);
|
|
613
589
|
this.changed();
|
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI commit-message generation — pure prompt assembly + response cleanup.
|
|
3
|
-
*
|
|
4
|
-
* The git gathering lives in scm.ts (scmCommitContext); the one-off model
|
|
5
|
-
* call lives in agent-service (ClientSession.scmGenCommitMessage, same
|
|
6
|
-
* completeSimple path as the vision bridge). This module owns everything
|
|
7
|
-
* deterministic so it stays unit-testable:
|
|
8
|
-
*
|
|
9
|
-
* buildCommitMsgInput(ctx, fallbackLang) → user message (null = nothing
|
|
10
|
-
* to commit — the caller turns that into a friendly error)
|
|
11
|
-
* COMMITMSG_SYSTEM_PROMPT → system prompt
|
|
12
|
-
* sanitizeCommitMessage(raw) → the single-line subject that
|
|
13
|
-
* ends up in the commit input (models are told to emit exactly that, but
|
|
14
|
-
* fences/labels/quotes/newlines are stripped defensively)
|
|
15
|
-
*
|
|
16
|
-
* Language policy: the generated message follows the repository's own commit
|
|
17
|
-
* subjects (style AND language — a repo writing "feat(xxx): 描述" keeps
|
|
18
|
-
* getting that). Only a repo with no commits yet falls back to the UI
|
|
19
|
-
* language passed as fallbackLang.
|
|
20
|
-
*/
|
|
21
1
|
import { isNotRepoError, scmCommitContext } from "./scm.js";
|
|
22
2
|
import { pick } from "./i18n.js";
|
|
23
|
-
/** SCM AI 提交信息生成超时时间(毫秒) */
|
|
24
3
|
export const SCM_COMMITMSG_TIMEOUT_MS = 60_000;
|
|
25
|
-
/** Hard cap for the generated subject — the commit input is single-line and
|
|
26
|
-
* this keeps a chatty model from filling the whole header row. */
|
|
27
4
|
export const MAX_COMMITMSG_LEN = 200;
|
|
28
|
-
/** File list cap inside the prompt (porcelain lines); the diffs carry the
|
|
29
|
-
* details, the list is orientation only. */
|
|
30
5
|
const MAX_FILE_LINES = 200;
|
|
31
6
|
export const COMMITMSG_SYSTEM_PROMPT = `You write git commit messages. You receive the pending changes of a repository and output exactly one commit message: a single subject line.
|
|
32
7
|
|
|
@@ -39,13 +14,6 @@ Rules:
|
|
|
39
14
|
6. If the repository has no commits yet, write the message in the language stated in the request.
|
|
40
15
|
|
|
41
16
|
Output ONLY the subject line.`;
|
|
42
|
-
/**
|
|
43
|
-
* Assemble the effective system prompt from the settings-panel prefs (same
|
|
44
|
-
* contract as the vision bridge's buildVisionBridgePrompt): mode "append"
|
|
45
|
-
* puts custom text after the built-in default (empty custom = pure default);
|
|
46
|
-
* mode "replace" swaps in the custom text, but an empty custom still falls
|
|
47
|
-
* back to the default (never send an empty system prompt).
|
|
48
|
-
*/
|
|
49
17
|
export function buildCommitMsgPrompt(mode, custom) {
|
|
50
18
|
const text = custom?.trim() ?? "";
|
|
51
19
|
if (mode === "replace" && text)
|
|
@@ -54,17 +22,11 @@ export function buildCommitMsgPrompt(mode, custom) {
|
|
|
54
22
|
return `${COMMITMSG_SYSTEM_PROMPT}\n\n${text}`;
|
|
55
23
|
return COMMITMSG_SYSTEM_PROMPT;
|
|
56
24
|
}
|
|
57
|
-
/** "path → [add,del]" map → compact "+12/-3 path" lines (sorted by path). */
|
|
58
25
|
function formatNumStat(stat) {
|
|
59
26
|
return Object.keys(stat)
|
|
60
27
|
.sort()
|
|
61
28
|
.map((p) => `+${stat[p][0]}/-${stat[p][1]} ${p}`);
|
|
62
29
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Assemble the user message from the gathered context. Returns null when
|
|
65
|
-
* there is nothing to describe (no staged/unstaged diff and no untracked
|
|
66
|
-
* files) — the caller replies "no changes" instead of calling the model.
|
|
67
|
-
*/
|
|
68
30
|
export function buildCommitMsgInput(ctx, fallbackLang) {
|
|
69
31
|
const parts = [];
|
|
70
32
|
if (ctx.subjects.length > 0) {
|
|
@@ -100,8 +62,6 @@ export function buildCommitMsgInput(ctx, fallbackLang) {
|
|
|
100
62
|
}
|
|
101
63
|
const untracked = ctx.files.filter((f) => f.x === "?" && f.y === "?");
|
|
102
64
|
if (untracked.length > 0 && !ctx.stagedPatch.trim()) {
|
|
103
|
-
// Untracked content never appears in `git diff` — name the files so
|
|
104
|
-
// the model knows they are part of the change set (commit-all flow).
|
|
105
65
|
parts.push(`Untracked files (new, content not shown): ${untracked
|
|
106
66
|
.map((f) => f.path)
|
|
107
67
|
.join(", ")
|
|
@@ -111,26 +71,17 @@ export function buildCommitMsgInput(ctx, fallbackLang) {
|
|
|
111
71
|
return null;
|
|
112
72
|
return parts.join("\n");
|
|
113
73
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Normalize whatever the model emitted into the single-line subject that goes
|
|
116
|
-
* into the commit input: drop fences, labels and wrapping quotes, keep only
|
|
117
|
-
* the first non-empty line, collapse whitespace, cap the length.
|
|
118
|
-
*/
|
|
119
74
|
export function sanitizeCommitMessage(raw) {
|
|
120
75
|
let text = raw.trim();
|
|
121
|
-
// ```…``` fences wrapping the whole answer.
|
|
122
76
|
const fence = text.match(/^```[a-zA-Z]*\s*\n?([\s\S]*?)\n?```$/);
|
|
123
77
|
if (fence)
|
|
124
78
|
text = fence[1].trim();
|
|
125
|
-
// Leading labels some models add despite the instructions.
|
|
126
79
|
text = text.replace(/^(commit(\s+message)?|subject|提交信息|提交消息|提交说明)\s*[::]\s*/i, "");
|
|
127
|
-
// First non-empty line only — the input field is single-line by design.
|
|
128
80
|
const firstLine = text
|
|
129
81
|
.split("\n")
|
|
130
82
|
.map((l) => l.trim())
|
|
131
83
|
.find((l) => l.length > 0) ?? "";
|
|
132
84
|
let out = firstLine.replace(/\s+/g, " ").trim();
|
|
133
|
-
// Matching wrapping quotes.
|
|
134
85
|
if (out.length >= 2) {
|
|
135
86
|
const a = out[0];
|
|
136
87
|
const b = out[out.length - 1];
|
|
@@ -142,10 +93,6 @@ export function sanitizeCommitMessage(raw) {
|
|
|
142
93
|
out = `${out.slice(0, MAX_COMMITMSG_LEN - 1).trimEnd()}…`;
|
|
143
94
|
return out;
|
|
144
95
|
}
|
|
145
|
-
/**
|
|
146
|
-
* 完整的 SCM AI 提交信息生成逻辑封装:
|
|
147
|
-
* 提取 git 差异上下文 -> 组装 prompt -> 调用模型 completeSimple -> 结果清洗校验
|
|
148
|
-
*/
|
|
149
96
|
export async function generateScmCommitMessage(opts) {
|
|
150
97
|
const { cwd, model, runtime, lang, promptMode = "append", customPrompt = "", timeoutMs = SCM_COMMITMSG_TIMEOUT_MS, } = opts;
|
|
151
98
|
try {
|
package/dist/server/scm.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read-only git queries backing the source-control panel.
|
|
3
|
-
*
|
|
4
|
-
* Replaces the old hidden-PTY + text-scraping approach: every query is a
|
|
5
|
-
* plain `execFile("git", …)` — no shell, no prompts, no echo, no sentinel
|
|
6
|
-
* parsing. Output is parsed into structured JSON on the server; the client
|
|
7
|
-
* just renders it.
|
|
8
|
-
*/
|
|
9
1
|
import { execFile } from "node:child_process";
|
|
10
2
|
import { promisify } from "node:util";
|
|
11
3
|
import { pick } from "./i18n.js";
|
|
12
4
|
import { getGlobalRemoteSshService, isRemoteWorkspaceUri, shellQuotePosix } from "./remote-ssh-service.js";
|
|
13
5
|
const exec = promisify(execFile);
|
|
14
|
-
/** Per-command timeout / output cap — a stuck repo must not hang the panel. */
|
|
15
6
|
const GIT_TIMEOUT_MS = 15_000;
|
|
16
7
|
const MAX_GIT_OUTPUT = 16 * 1024 * 1024;
|
|
17
|
-
/** Run one git command; throws Error with a readable message on failure. */
|
|
18
8
|
async function git(cwd, args, lang) {
|
|
19
9
|
const l = lang?.() ?? "en";
|
|
20
10
|
if (isRemoteWorkspaceUri(cwd)) {
|
|
@@ -49,8 +39,6 @@ async function git(cwd, args, lang) {
|
|
|
49
39
|
throw new Error(detail || pick(l, "git 命令失败", "git command failed", "scm.git.failed"));
|
|
50
40
|
}
|
|
51
41
|
}
|
|
52
|
-
/** Absolute path of the repo's git dir (handles worktrees/submodules), or
|
|
53
|
-
* null when cwd isn't inside a repository. */
|
|
54
42
|
export async function gitDirOf(cwd) {
|
|
55
43
|
if (isRemoteWorkspaceUri(cwd))
|
|
56
44
|
return null;
|
|
@@ -66,15 +54,9 @@ export async function gitDirOf(cwd) {
|
|
|
66
54
|
return null;
|
|
67
55
|
}
|
|
68
56
|
}
|
|
69
|
-
/** True when the error is "this directory isn't a git repository". */
|
|
70
57
|
export function isNotRepoError(err) {
|
|
71
58
|
return /not a git repository/i.test(err instanceof Error ? err.message : String(err));
|
|
72
59
|
}
|
|
73
|
-
/* ------------------------------------------------------------------ */
|
|
74
|
-
/* parsers */
|
|
75
|
-
/* ------------------------------------------------------------------ */
|
|
76
|
-
/** Undo git's C-style quoting for unusual file names ("a\tb" → a<TAB>b).
|
|
77
|
-
* core.quotepath=false already handles non-ASCII; this covers control chars. */
|
|
78
60
|
function unquotePath(s) {
|
|
79
61
|
if (!s.startsWith('"'))
|
|
80
62
|
return s;
|
|
@@ -163,7 +145,7 @@ function parseStatusFiles(text) {
|
|
|
163
145
|
continue;
|
|
164
146
|
if (line.length >= 3) {
|
|
165
147
|
let path = line.slice(3);
|
|
166
|
-
const arrow = path.indexOf(" -> ");
|
|
148
|
+
const arrow = path.indexOf(" -> ");
|
|
167
149
|
if (arrow >= 0)
|
|
168
150
|
path = path.slice(arrow + 4);
|
|
169
151
|
out.push({ path: unquotePath(path), x: line[0], y: line[1] });
|
|
@@ -184,7 +166,6 @@ function parseBranches(text) {
|
|
|
184
166
|
}
|
|
185
167
|
else if (ref.startsWith("refs/remotes/")) {
|
|
186
168
|
const short = ref.slice("refs/remotes/".length);
|
|
187
|
-
// Skip the "origin/HEAD -> origin/main" symlink.
|
|
188
169
|
if (short.endsWith("/HEAD"))
|
|
189
170
|
continue;
|
|
190
171
|
const slash = short.indexOf("/");
|
|
@@ -197,20 +178,17 @@ function parseBranches(text) {
|
|
|
197
178
|
}
|
|
198
179
|
return out;
|
|
199
180
|
}
|
|
200
|
-
/** Parse `git log --graph --pretty=format:%H%x09…` preserving graph prefixes. */
|
|
201
181
|
function parseCommitHistory(text) {
|
|
202
182
|
const out = [];
|
|
203
183
|
for (const line of text.split("\n")) {
|
|
204
184
|
const tab = line.indexOf("\t");
|
|
205
185
|
if (tab < 0)
|
|
206
|
-
continue;
|
|
186
|
+
continue;
|
|
207
187
|
const prefixAndHash = line.slice(0, tab);
|
|
208
188
|
const match = prefixAndHash.match(/([0-9a-f]{7,40})$/i);
|
|
209
189
|
if (!match || match.index === undefined)
|
|
210
190
|
continue;
|
|
211
191
|
const fields = line.slice(tab + 1).split("\t");
|
|
212
|
-
// An empty decoration field removes the final tab — four fields is a
|
|
213
|
-
// valid undecorated commit.
|
|
214
192
|
if (fields.length < 4)
|
|
215
193
|
continue;
|
|
216
194
|
out.push({
|
|
@@ -225,7 +203,6 @@ function parseCommitHistory(text) {
|
|
|
225
203
|
}
|
|
226
204
|
return out;
|
|
227
205
|
}
|
|
228
|
-
/** Parse `git diff --numstat` output: "12\t3\tpath" → { path: [add, del] }. */
|
|
229
206
|
function parseNumStat(text) {
|
|
230
207
|
const stats = {};
|
|
231
208
|
for (const line of text.split("\n")) {
|
|
@@ -238,7 +215,7 @@ function parseNumStat(text) {
|
|
|
238
215
|
let add = Number(line.slice(0, tab1));
|
|
239
216
|
let del = Number(line.slice(tab1 + 1, tab2));
|
|
240
217
|
if (!Number.isFinite(add))
|
|
241
|
-
add = 0;
|
|
218
|
+
add = 0;
|
|
242
219
|
if (!Number.isFinite(del))
|
|
243
220
|
del = 0;
|
|
244
221
|
const path = unquotePath(line.slice(tab2 + 1).trim());
|
|
@@ -247,9 +224,6 @@ function parseNumStat(text) {
|
|
|
247
224
|
}
|
|
248
225
|
return stats;
|
|
249
226
|
}
|
|
250
|
-
/* ------------------------------------------------------------------ */
|
|
251
|
-
/* queries */
|
|
252
|
-
/* ------------------------------------------------------------------ */
|
|
253
227
|
const HISTORY_ARGS = [
|
|
254
228
|
"log",
|
|
255
229
|
"--all",
|
|
@@ -260,12 +234,9 @@ const HISTORY_ARGS = [
|
|
|
260
234
|
"-n",
|
|
261
235
|
"120",
|
|
262
236
|
];
|
|
263
|
-
/** Commit graph for the history tab — fetched lazily so the common
|
|
264
|
-
* "changes" view never pays for it on huge repos. */
|
|
265
237
|
export async function scmHistory(cwd, lang) {
|
|
266
238
|
return parseCommitHistory(await git(cwd, HISTORY_ARGS, lang));
|
|
267
239
|
}
|
|
268
|
-
/** Status refresh payload (status + branches + numstat) — parallel. */
|
|
269
240
|
export async function scmStatus(cwd, lang) {
|
|
270
241
|
const [statusText, branchText, statText, cachedStatText] = await Promise.all([
|
|
271
242
|
git(cwd, ["status", "--porcelain=v1", "-b", "--find-renames"], lang),
|
|
@@ -277,7 +248,6 @@ export async function scmStatus(cwd, lang) {
|
|
|
277
248
|
.split("\n")
|
|
278
249
|
.find((l) => l.startsWith("## "))
|
|
279
250
|
?.slice(3) ?? "");
|
|
280
|
-
// Worktree + staged line counts, merged per path.
|
|
281
251
|
const merged = {};
|
|
282
252
|
for (const [path, pair] of Object.entries(parseNumStat(statText))) {
|
|
283
253
|
merged[path] = pair;
|
|
@@ -299,7 +269,6 @@ export async function scmStatus(cwd, lang) {
|
|
|
299
269
|
stats: merged,
|
|
300
270
|
};
|
|
301
271
|
}
|
|
302
|
-
/** Staged + worktree diffs for one file (empty strings when no diff). */
|
|
303
272
|
export async function scmFileDiff(cwd, path, lang) {
|
|
304
273
|
const [staged, worktree] = await Promise.all([
|
|
305
274
|
git(cwd, ["diff", "--cached", "--no-color", "--no-ext-diff", "--", path], lang).catch(() => ""),
|
|
@@ -307,27 +276,15 @@ export async function scmFileDiff(cwd, path, lang) {
|
|
|
307
276
|
]);
|
|
308
277
|
return { staged, worktree };
|
|
309
278
|
}
|
|
310
|
-
/** Full patch of one commit (`git show`). */
|
|
311
279
|
export async function scmCommitDetail(cwd, hash, lang) {
|
|
312
280
|
return git(cwd, ["show", "--no-color", "--no-ext-diff", "--find-renames", "--format=fuller", "--stat", "--patch", hash], lang);
|
|
313
281
|
}
|
|
314
|
-
/* ------------------------------------------------------------------ */
|
|
315
|
-
/* AI commit-message context */
|
|
316
|
-
/* ------------------------------------------------------------------ */
|
|
317
|
-
/** Cap per patch (staged / worktree) fed to the commit-message prompt —
|
|
318
|
-
* enough for the model to see what most commits are about without letting
|
|
319
|
-
* one huge repo blow up the one-off completion request. */
|
|
320
282
|
const MAX_COMMITMSG_PATCH_CHARS = 12_000;
|
|
321
|
-
/** Cap one patch at MAX_COMMITMSG_PATCH_CHARS, keeping the head (early files
|
|
322
|
-
* matter most for a commit message) and marking the cut. */
|
|
323
283
|
function capPatch(text) {
|
|
324
284
|
if (text.length <= MAX_COMMITMSG_PATCH_CHARS)
|
|
325
285
|
return text;
|
|
326
286
|
return `${text.slice(0, MAX_COMMITMSG_PATCH_CHARS)}\n… (diff truncated)`;
|
|
327
287
|
}
|
|
328
|
-
/** Gather staged/worktree patches, numstats, status and recent subjects for
|
|
329
|
-
* the AI commit-message generator. Throws the usual git errors (including
|
|
330
|
-
* "not a git repository") — the caller maps them to friendly replies. */
|
|
331
288
|
export async function scmCommitContext(cwd, lang) {
|
|
332
289
|
const [stagedPatch, worktreePatch, stagedStatText, worktreeStatText, statusText, subjectText] = await Promise.all([
|
|
333
290
|
git(cwd, ["diff", "--cached", "--no-color", "--no-ext-diff", "--find-renames"], lang).catch(() => ""),
|
|
@@ -335,8 +292,6 @@ export async function scmCommitContext(cwd, lang) {
|
|
|
335
292
|
git(cwd, ["diff", "--cached", "--numstat"], lang).catch(() => ""),
|
|
336
293
|
git(cwd, ["diff", "--numstat"], lang).catch(() => ""),
|
|
337
294
|
git(cwd, ["status", "--porcelain=v1", "--find-renames"], lang),
|
|
338
|
-
// Empty repos (no commits yet) make `git log` fail — that's a valid
|
|
339
|
-
// "no style reference" answer, not an error worth failing the request.
|
|
340
295
|
git(cwd, ["log", "-n", "15", "--pretty=format:%s"], lang).then((s) => s, () => ""),
|
|
341
296
|
]);
|
|
342
297
|
const subjects = subjectText
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sdk-builtin-extensions.ts — 动态装配与筛选 @earendil-works/pi-coding-agent SDK 内置扩展。
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 1. 继承 SDK 原生内置扩展(如 builtin:llama.cpp、builtin:codemode、builtin:tool-search);
|
|
6
|
-
* 2. 精准隔离 SDK 内置 MCP 扩展(pi-web-ui 统一使用专属 McpBridge 管理,防止 MCP 进程双重派生);
|
|
7
|
-
* 3. 严格保留 builtin: true 与 replaceable 等元数据,确保 SDK DefaultResourceLoader 正确建立
|
|
8
|
-
* builtin:<name> 字典索引(解决 Issue #755:GUI 无法发现和使用 llama.cpp 本地模型的问题);
|
|
9
|
-
* 4. 遵循与 resolve-global-sdk / patch-remote-catalog 相同的事实源,兼容全局 SDK 与自带副本。
|
|
10
|
-
*/
|
|
11
1
|
import { existsSync } from "node:fs";
|
|
12
2
|
import { dirname, join } from "node:path";
|
|
13
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
4
|
import { createCodemodeExtension, createToolSearchExtension } from "@earendil-works/pi-coding-agent";
|
|
15
5
|
let cachedEntries = null;
|
|
16
|
-
/**
|
|
17
|
-
* 解析当前生效 SDK 的 extensions/index.js 文件绝对路径。
|
|
18
|
-
*/
|
|
19
6
|
export function resolveSdkExtensionsIndexPath() {
|
|
20
7
|
try {
|
|
21
8
|
const entry = fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"));
|
|
@@ -23,16 +10,9 @@ export function resolveSdkExtensionsIndexPath() {
|
|
|
23
10
|
if (existsSync(candidate))
|
|
24
11
|
return candidate;
|
|
25
12
|
}
|
|
26
|
-
catch {
|
|
27
|
-
/* ignore resolve failure */
|
|
28
|
-
}
|
|
13
|
+
catch { }
|
|
29
14
|
return null;
|
|
30
15
|
}
|
|
31
|
-
/**
|
|
32
|
-
* 获取经过宿主门禁过滤后的 SDK 内置扩展工厂列表(带内存缓存)。
|
|
33
|
-
* - 包含:llama.cpp、codemode、tool-search(以及未来 SDK 官方新增的提供商扩展)
|
|
34
|
-
* - 剔除:mcp(由 WebUI 独立 McpBridge 接管)
|
|
35
|
-
*/
|
|
36
16
|
export async function getSdkBuiltinExtensionFactories() {
|
|
37
17
|
if (cachedEntries)
|
|
38
18
|
return cachedEntries;
|
|
@@ -43,7 +23,6 @@ export async function getSdkBuiltinExtensionFactories() {
|
|
|
43
23
|
const mod = (await import(pathToFileURL(indexPath).href));
|
|
44
24
|
if (Array.isArray(mod.builtInExtensions)) {
|
|
45
25
|
for (const ext of mod.builtInExtensions) {
|
|
46
|
-
// 严格屏蔽 SDK 内置 mcp:避免与宿主 McpBridge 重复连接和拉起 stdio 进程
|
|
47
26
|
if (ext.name === "mcp")
|
|
48
27
|
continue;
|
|
49
28
|
factories.push({
|
|
@@ -56,11 +35,8 @@ export async function getSdkBuiltinExtensionFactories() {
|
|
|
56
35
|
}
|
|
57
36
|
}
|
|
58
37
|
}
|
|
59
|
-
catch {
|
|
60
|
-
/* dynamic load failed, fall back below */
|
|
61
|
-
}
|
|
38
|
+
catch { }
|
|
62
39
|
}
|
|
63
|
-
// 兜底回退:若未成功加载任何工厂,保证核心基础设施扩展可用
|
|
64
40
|
if (factories.length === 0) {
|
|
65
41
|
factories.push({
|
|
66
42
|
name: "codemode",
|
|
@@ -79,7 +55,4 @@ export async function getSdkBuiltinExtensionFactories() {
|
|
|
79
55
|
cachedEntries = factories;
|
|
80
56
|
return factories;
|
|
81
57
|
}
|
|
82
|
-
/**
|
|
83
|
-
* 宿主层需禁用的 SDK 内置扩展名称清单(双保险,传给 disabledBuiltinExtensions)。
|
|
84
|
-
*/
|
|
85
58
|
export const SDK_DISABLED_BUILTIN_EXTENSIONS = ["mcp"];
|