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,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* canvas-orchestrator.ts — 多引擎、多模型、多目录画布协作调度器。
|
|
3
|
-
*
|
|
4
|
-
* 核心功能:
|
|
5
|
-
* 1. 管理运行中的 CanvasGraph 拓扑生命周期;
|
|
6
|
-
* 2. 调度四大引擎(Pi / DSH / Claude Code / Durable)的并发会话;
|
|
7
|
-
* 3. 隔离各节点的工作目录(相对子目录,或自动启用 Git Worktree 物理隔离);
|
|
8
|
-
* 4. 沿连线执行契约化数据流转(Handoff);
|
|
9
|
-
* 5. 审查回路与防死循环熔断保护(Review Loop Breaker)。
|
|
10
|
-
*/
|
|
11
1
|
import { existsSync, mkdirSync } from "node:fs";
|
|
12
2
|
import { isAbsolute, resolve } from "node:path";
|
|
13
3
|
import { isRemoteWorkspaceUri } from "../remote-ssh-service.js";
|
|
@@ -21,17 +11,14 @@ import { PSTACK_SKILLS_MAP } from "./pstack-skills-data.js";
|
|
|
21
11
|
import { discoverDiskSkills, readSkillInstruction } from "../skill-discovery.js";
|
|
22
12
|
import { randomUUID } from "node:crypto";
|
|
23
13
|
import { CanvasExecutionQueue, canvasCondition, canvasReadiness, isCanvasBackedge, validateCanvasTopology, } from "./canvas-scheduler.js";
|
|
14
|
+
import { CanvasRuntimeError, canvasErrorMessage, canvasRuntimeMessage } from "./canvas-runtime-messages.js";
|
|
24
15
|
const exec = promisify(execFile);
|
|
25
16
|
export class CanvasOrchestrator {
|
|
26
17
|
dataDir;
|
|
27
|
-
/** 每个节点的对话实录:key=`${graphId}:${nodeId}`,内存常驻 + 落盘持久化(canvas/logs/)。上限 300 条防爆内存。 */
|
|
28
18
|
nodeLogs = new Map();
|
|
29
|
-
/** 复用当前对话流:sink 里收到的标准 UiMessage 按节点缓存,前端抽屉直接复用 Message 组件渲染。 */
|
|
30
19
|
nodeMessages = new Map();
|
|
31
20
|
logSeq = 0;
|
|
32
21
|
baseCwd;
|
|
33
|
-
/** 运行期项目基准(graphId -> 目录):相对 cwd 相对它解析;缺省=服务启动目录。
|
|
34
|
-
* 谁先启动这次运行谁定:UI 按钮=点击者当前项目,AI 工具=所有者对话 cwd。 */
|
|
35
22
|
runBaseByGraph = new Map();
|
|
36
23
|
engineGetter;
|
|
37
24
|
broadcaster = null;
|
|
@@ -41,7 +28,6 @@ export class CanvasOrchestrator {
|
|
|
41
28
|
nodeGenerations = new Map();
|
|
42
29
|
executionQueue = new CanvasExecutionQueue(4);
|
|
43
30
|
static sharedWorkspaceQueue = new CanvasExecutionQueue(1);
|
|
44
|
-
/** Immutable rejection inputs survive resetting the producer and its forward region. */
|
|
45
31
|
feedbackArtifacts = new Map();
|
|
46
32
|
runDeadlines = new Map();
|
|
47
33
|
constructor(baseCwd, dataDir, engineGetter) {
|
|
@@ -57,23 +43,17 @@ export class CanvasOrchestrator {
|
|
|
57
43
|
try {
|
|
58
44
|
this.broadcaster?.(msg);
|
|
59
45
|
}
|
|
60
|
-
catch {
|
|
61
|
-
// 背压/断连导致广播失败不得污染调度主路径(故障注入 S3 命中)
|
|
62
|
-
}
|
|
46
|
+
catch { }
|
|
63
47
|
}
|
|
64
|
-
/** Reload after the store merges runtime fields so stale execution topology never reaches clients. */
|
|
65
48
|
broadcastCanvasRuntime(graph) {
|
|
66
49
|
try {
|
|
67
50
|
this.broadcast({ type: "canvas_graph_state", graph: loadCanvasGraph(this.dataDir, graph.id) });
|
|
68
51
|
}
|
|
69
|
-
catch {
|
|
70
|
-
// Deletion wins over late runtime publication.
|
|
71
|
-
}
|
|
52
|
+
catch { }
|
|
72
53
|
}
|
|
73
54
|
logKey(graphId, nodeId) {
|
|
74
55
|
return `${graphId}:${nodeId}`;
|
|
75
56
|
}
|
|
76
|
-
/** 读取节点对话实录(内存命中优先,否则尝试从落盘恢复) */
|
|
77
57
|
getNodeLog(graphId, nodeId) {
|
|
78
58
|
const key = this.logKey(graphId, nodeId);
|
|
79
59
|
const mem = this.nodeLogs.get(key);
|
|
@@ -90,17 +70,13 @@ export class CanvasOrchestrator {
|
|
|
90
70
|
}
|
|
91
71
|
}
|
|
92
72
|
}
|
|
93
|
-
catch {
|
|
94
|
-
// 读盘失败回落空日志
|
|
95
|
-
}
|
|
73
|
+
catch { }
|
|
96
74
|
return [];
|
|
97
75
|
}
|
|
98
|
-
/** 读取节点复用的对话流消息(与主对话同构的 UiMessage[],上限 200 条) */
|
|
99
76
|
getNodeMessages(graphId, nodeId) {
|
|
100
77
|
const mem = this.nodeMessages.get(this.logKey(graphId, nodeId));
|
|
101
78
|
return mem ? [...mem] : [];
|
|
102
79
|
}
|
|
103
|
-
/** 清空节点对话实录(内存 + 落盘) */
|
|
104
80
|
clearNodeLog(graphId, nodeId) {
|
|
105
81
|
const key = this.logKey(graphId, nodeId);
|
|
106
82
|
this.nodeLogs.delete(key);
|
|
@@ -110,12 +86,10 @@ export class CanvasOrchestrator {
|
|
|
110
86
|
if (fsExistsSync(file))
|
|
111
87
|
unlinkSync(file);
|
|
112
88
|
}
|
|
113
|
-
catch {
|
|
114
|
-
// 忽略清理失败
|
|
115
|
-
}
|
|
89
|
+
catch { }
|
|
116
90
|
}
|
|
117
91
|
/** 追加一条对话实录并广播 + 节流落盘 */
|
|
118
|
-
appendLog(graphId, nodeId, kind, text, toolName) {
|
|
92
|
+
appendLog(graphId, nodeId, kind, text, toolName, message) {
|
|
119
93
|
if (!isSafeGraphId(graphId) || !isSafeGraphId(nodeId))
|
|
120
94
|
return;
|
|
121
95
|
const clean = (text ?? "").slice(0, 2000) || "(空)";
|
|
@@ -124,6 +98,7 @@ export class CanvasOrchestrator {
|
|
|
124
98
|
ts: Date.now(),
|
|
125
99
|
kind,
|
|
126
100
|
text: clean,
|
|
101
|
+
...(message ? { message } : {}),
|
|
127
102
|
...(toolName ? { toolName: toolName.slice(0, 80) } : {}),
|
|
128
103
|
};
|
|
129
104
|
const key = this.logKey(graphId, nodeId);
|
|
@@ -136,7 +111,6 @@ export class CanvasOrchestrator {
|
|
|
136
111
|
this.broadcast({ type: "canvas_node_log", graphId, nodeId, entry });
|
|
137
112
|
if ((this.graphGenerations.get(graphId) ?? 0) !== generation)
|
|
138
113
|
return;
|
|
139
|
-
// 每 10 条落盘一次,避免高频 IO
|
|
140
114
|
if (list.length % 10 === 0 || kind === "error" || kind === "done") {
|
|
141
115
|
try {
|
|
142
116
|
const dir = pathJoin(this.dataDir, "canvas", "logs");
|
|
@@ -144,18 +118,14 @@ export class CanvasOrchestrator {
|
|
|
144
118
|
fsMkdirSync(dir, { recursive: true });
|
|
145
119
|
writeFileSync(pathJoin(dir, `${graphId}__${nodeId}.json`), JSON.stringify(list.slice(-300)));
|
|
146
120
|
}
|
|
147
|
-
catch {
|
|
148
|
-
// 落盘失败不影响主流程
|
|
149
|
-
}
|
|
121
|
+
catch { }
|
|
150
122
|
}
|
|
151
123
|
}
|
|
152
|
-
/** 缓存并转播复用的对话流消息(直接透传主对话同构 UiMessage,前端复用 Message 组件渲染) */
|
|
153
124
|
pushNodeMessages(graphId, nodeId, incoming) {
|
|
154
125
|
if (!Array.isArray(incoming) || incoming.length === 0)
|
|
155
126
|
return;
|
|
156
127
|
const key = this.logKey(graphId, nodeId);
|
|
157
128
|
const list = this.nodeMessages.get(key) ?? [];
|
|
158
|
-
// 按 id 去重追加,保持 200 条上限
|
|
159
129
|
const seen = new Set(list.map((m) => m.id));
|
|
160
130
|
for (const m of incoming) {
|
|
161
131
|
if (!m || typeof m.id !== "string" || seen.has(m.id))
|
|
@@ -174,8 +144,6 @@ export class CanvasOrchestrator {
|
|
|
174
144
|
streaming: true,
|
|
175
145
|
});
|
|
176
146
|
}
|
|
177
|
-
/** 确保该节点所需的真实工作目录(支持 Worktree 隔离) */
|
|
178
|
-
/** 有效运行基准:显式 runBase(本地绝对路径或远程 SSH URI)优先,否则服务启动目录 */
|
|
179
147
|
pickRunBase(runBase) {
|
|
180
148
|
const r = (runBase ?? "").trim();
|
|
181
149
|
if (r && (isRemoteWorkspaceUri(r) || isAbsolute(r)))
|
|
@@ -184,7 +152,7 @@ export class CanvasOrchestrator {
|
|
|
184
152
|
}
|
|
185
153
|
async resolveNodeCwd(node, runBase) {
|
|
186
154
|
if (!isSafeGraphId(node.id))
|
|
187
|
-
throw new
|
|
155
|
+
throw new CanvasRuntimeError(`Invalid canvas node id: ${node.id}`, "error.invalidNodeId", { id: node.id });
|
|
188
156
|
if (node.useWorktree)
|
|
189
157
|
return (await prepareCanvasWorkspace({
|
|
190
158
|
baseCwd: this.pickRunBase(runBase),
|
|
@@ -225,7 +193,6 @@ export class CanvasOrchestrator {
|
|
|
225
193
|
timer.unref();
|
|
226
194
|
this.runDeadlines.set(graph.id, timer);
|
|
227
195
|
}
|
|
228
|
-
/** Invalidate executions before deleting persistence. */
|
|
229
196
|
deleteGraph(graphId) {
|
|
230
197
|
if (!isSafeGraphId(graphId))
|
|
231
198
|
return false;
|
|
@@ -251,15 +218,14 @@ export class CanvasOrchestrator {
|
|
|
251
218
|
this.nodeMessages.delete(key);
|
|
252
219
|
return deleteCanvasGraph(this.dataDir, graphId);
|
|
253
220
|
}
|
|
254
|
-
/** 启动单个节点 */
|
|
255
221
|
async runNode(graph, nodeId, initialPrompt, runBase, scheduled = false) {
|
|
256
222
|
if (!fsExistsSync(pathJoin(this.dataDir, "canvas", `${graph.id}.json`)))
|
|
257
223
|
return;
|
|
258
224
|
const execKey = `${graph.id}:${nodeId}`;
|
|
259
225
|
if (this.activeExecutions.has(execKey))
|
|
260
|
-
throw new
|
|
226
|
+
throw new CanvasRuntimeError(`Canvas node already running: ${nodeId}`, "error.nodeRunning", { id: nodeId });
|
|
261
227
|
if (!scheduled && ["running", "waiting_approval"].includes(this.runningGraphs.get(graph.id)?.status ?? ""))
|
|
262
|
-
throw new
|
|
228
|
+
throw new CanvasRuntimeError("Canvas graph already running", "error.graphRunning");
|
|
263
229
|
// A separately loaded run_node must not replace an active graph object.
|
|
264
230
|
if ([...this.activeExecutions.values()].some((execution) => execution.graphId === graph.id)) {
|
|
265
231
|
graph = this.runningGraphs.get(graph.id) ?? graph;
|
|
@@ -299,6 +265,9 @@ export class CanvasOrchestrator {
|
|
|
299
265
|
if (target !== node) {
|
|
300
266
|
target.status = "idle";
|
|
301
267
|
target.error = undefined;
|
|
268
|
+
target.errorMessage = undefined;
|
|
269
|
+
target.currentAction = undefined;
|
|
270
|
+
target.currentActionMessage = undefined;
|
|
302
271
|
target.artifact = undefined;
|
|
303
272
|
target.lastOutputSummary = undefined;
|
|
304
273
|
target.aiVerdict = undefined;
|
|
@@ -317,16 +286,25 @@ export class CanvasOrchestrator {
|
|
|
317
286
|
node.actualModel = undefined;
|
|
318
287
|
node.status = "running";
|
|
319
288
|
node.error = undefined;
|
|
289
|
+
node.errorMessage = undefined;
|
|
320
290
|
node.currentAction = `[${node.engine.toUpperCase()}] 正在分配独立环境与工作目录...`;
|
|
291
|
+
node.currentActionMessage = canvasRuntimeMessage("action.allocating", { engine: node.engine.toUpperCase() });
|
|
321
292
|
saveCanvasRuntimeState(this.dataDir, graph);
|
|
322
293
|
this.broadcastCanvasRuntime(graph);
|
|
323
|
-
this.appendLog(graph.id, nodeId, "system", `启动节点「${node.title}」(${node.engine}/${node.model}),工作目录: ${node.cwd || "."}(基准: ${this.pickRunBase(runBase ?? this.runBaseByGraph.get(graph.id))}
|
|
294
|
+
this.appendLog(graph.id, nodeId, "system", `启动节点「${node.title}」(${node.engine}/${node.model}),工作目录: ${node.cwd || "."}(基准: ${this.pickRunBase(runBase ?? this.runBaseByGraph.get(graph.id))})`, undefined, canvasRuntimeMessage("log.nodeStarted", {
|
|
295
|
+
title: node.title,
|
|
296
|
+
engine: node.engine,
|
|
297
|
+
model: node.model,
|
|
298
|
+
cwd: node.cwd || ".",
|
|
299
|
+
base: this.pickRunBase(runBase ?? this.runBaseByGraph.get(graph.id)),
|
|
300
|
+
}));
|
|
324
301
|
this.broadcast({
|
|
325
302
|
type: "canvas_node_event",
|
|
326
303
|
graphId: graph.id,
|
|
327
304
|
nodeId,
|
|
328
305
|
event: "started",
|
|
329
306
|
currentAction: node.currentAction,
|
|
307
|
+
currentActionMessage: node.currentActionMessage,
|
|
330
308
|
});
|
|
331
309
|
let releaseSlot = () => { };
|
|
332
310
|
let releaseCwd = () => { };
|
|
@@ -337,7 +315,9 @@ export class CanvasOrchestrator {
|
|
|
337
315
|
try {
|
|
338
316
|
releaseSlot = await this.executionQueue.acquire(controller.signal);
|
|
339
317
|
if (["cron", "webhook", "memory", "loop"].includes(node.role))
|
|
340
|
-
throw new
|
|
318
|
+
throw new CanvasRuntimeError(`Unsupported canvas executor: ${node.role}`, "error.unsupportedExecutor", {
|
|
319
|
+
role: node.role,
|
|
320
|
+
});
|
|
341
321
|
if ((runBase ?? "").trim())
|
|
342
322
|
this.runBaseByGraph.set(graph.id, runBase);
|
|
343
323
|
const upstreamArtifacts = graph.edges
|
|
@@ -390,34 +370,36 @@ export class CanvasOrchestrator {
|
|
|
390
370
|
? `skill: ${String(node.config?.skillName || node.config?.skill || "soul")}`
|
|
391
371
|
: node.role;
|
|
392
372
|
node.currentAction = `[${node.engine.toUpperCase()}] 启动 ${node.model} 执行中 (${roleDetail})...`;
|
|
373
|
+
node.currentActionMessage = canvasRuntimeMessage("action.starting", {
|
|
374
|
+
engine: node.engine.toUpperCase(),
|
|
375
|
+
model: node.model,
|
|
376
|
+
role: roleDetail,
|
|
377
|
+
});
|
|
393
378
|
this.broadcast({
|
|
394
379
|
type: "canvas_node_event",
|
|
395
380
|
graphId: graph.id,
|
|
396
381
|
nodeId,
|
|
397
382
|
event: "action",
|
|
398
383
|
currentAction: node.currentAction,
|
|
384
|
+
currentActionMessage: node.currentActionMessage,
|
|
399
385
|
});
|
|
400
|
-
// 组装前置契约提示词(若上游边有 handoff 产物)
|
|
401
386
|
const incomingEdges = graph.edges.filter((e) => e.targetNodeId === nodeId && e.active !== false);
|
|
402
387
|
let contractContext = "";
|
|
403
388
|
for (const edge of incomingEdges) {
|
|
404
389
|
if (edge.lastHandoffSummary) {
|
|
405
|
-
const
|
|
406
|
-
contract: "
|
|
407
|
-
instruction: "AI
|
|
408
|
-
system: "
|
|
409
|
-
config: "
|
|
390
|
+
const PORT_LABELS = {
|
|
391
|
+
contract: "Task contract",
|
|
392
|
+
instruction: "AI instructions",
|
|
393
|
+
system: "Role instructions",
|
|
394
|
+
config: "Control parameters",
|
|
410
395
|
};
|
|
411
396
|
const srcTitle = graph.nodes.find((n) => n.id === edge.sourceNodeId)?.title || edge.sourceNodeId;
|
|
412
397
|
const portSuffix = edge.targetPort && edge.targetPort !== "contract"
|
|
413
|
-
? ` → ${
|
|
398
|
+
? ` → ${PORT_LABELS[edge.targetPort] || edge.targetPort}`
|
|
414
399
|
: "";
|
|
415
|
-
contractContext += `\n
|
|
400
|
+
contractContext += `\n[Directed input from “${srcTitle}”${portSuffix}]:\n${edge.lastHandoffSummary}\n`;
|
|
416
401
|
}
|
|
417
402
|
}
|
|
418
|
-
// 指令优先级:本次手动输入 > 节点持久化 instruction(AI 可输入) > systemPromptOverride > 直接使用输入 > 默认。
|
|
419
|
-
// instruction 支持 {{input}} / {{上游摘要}} / {{upstream}} / {{contract}} 变量引用上游契约产物;
|
|
420
|
-
// 留空或只写输入变量 = 直接使用输入(不再追加通用兜底,避免输入被复制两遍)。
|
|
421
403
|
const rawInstruction = initialPrompt?.trim() || node.instruction?.trim() || node.systemPromptOverride?.trim() || "";
|
|
422
404
|
let expandedInstruction = rawInstruction;
|
|
423
405
|
if (contractContext) {
|
|
@@ -428,28 +410,28 @@ export class CanvasOrchestrator {
|
|
|
428
410
|
const cfgEntries = Object.entries(node.config ?? {}).filter((entry) => entry[1] !== undefined && entry[1] !== "");
|
|
429
411
|
let configContext = "";
|
|
430
412
|
if (!isCanvasPassthroughRole(node.role) && node.role !== "transform" && cfgEntries.length > 0) {
|
|
431
|
-
configContext = `\n
|
|
413
|
+
configContext = `\n[Node-specific parameters]:\n${cfgEntries.map((entry) => `${entry[0]}=${String(entry[1])}`).join("; ")}\n`;
|
|
432
414
|
}
|
|
433
415
|
let prompt = isInputOnly
|
|
434
416
|
? `${contractContext}${configContext ? `\n${configContext}` : ""}`
|
|
435
|
-
: `${expandedInstruction || "
|
|
417
|
+
: `${expandedInstruction || "Carry out the development task according to your role."}\n${configContext}${contractContext}`;
|
|
436
418
|
if (!contractContext.trim() &&
|
|
437
419
|
!initialPrompt?.trim() &&
|
|
438
420
|
!node.instruction?.trim() &&
|
|
439
421
|
!isCanvasPassthroughRole(node.role)) {
|
|
440
|
-
prompt += `\n\n
|
|
422
|
+
prompt += `\n\n[First-node guidance]: This is the first node in the workflow. Inspect the current workspace, establish the project architecture and conventions, identify the core tasks, and provide explicit task contracts for downstream nodes.`;
|
|
441
423
|
}
|
|
442
424
|
if (node.role === "pstack") {
|
|
443
425
|
const skillKey = String(node.config?.skill ?? "poteto-mode").trim();
|
|
444
426
|
const item = PSTACK_SKILLS_MAP[skillKey] || PSTACK_SKILLS_MAP["poteto-mode"];
|
|
445
|
-
const skillTitle = item ? `${item.icon} ${item.
|
|
427
|
+
const skillTitle = item ? `${item.icon} ${item.id}` : skillKey;
|
|
446
428
|
const skillDoc = item?.content ? item.content.slice(0, 4500) : "";
|
|
447
|
-
prompt =
|
|
429
|
+
prompt = `[Pstack engineering reference · ${skillTitle}]\n${skillDoc}\n\n[Pstack execution rules]\n1. Work thoroughly and avoid AI filler (Unslop): do not produce empty descriptions or superficial code fixes.\n2. Provide reproducible evidence after making changes: test output, runtime diagnostics, or precise behavioral evidence.\n3. Follow every non-negotiable principle of the selected skill (${skillKey}) for this node's task.\n\n[Node task and context]\n${prompt}`;
|
|
448
430
|
}
|
|
449
431
|
else if (node.role === "skill") {
|
|
450
432
|
const targetSkillName = String(node.config?.skillName ?? node.config?.skill ?? "").trim();
|
|
451
433
|
let skillInstruction = "";
|
|
452
|
-
let foundSkillTitle = targetSkillName || "
|
|
434
|
+
let foundSkillTitle = targetSkillName || "Unspecified skill";
|
|
453
435
|
if (targetSkillName) {
|
|
454
436
|
const diskSkills = discoverDiskSkills({
|
|
455
437
|
cwd: resolvedCwd || this.baseCwd,
|
|
@@ -465,46 +447,49 @@ export class CanvasOrchestrator {
|
|
|
465
447
|
const pstackItem = PSTACK_SKILLS_MAP[targetSkillName.toLowerCase()];
|
|
466
448
|
if (pstackItem) {
|
|
467
449
|
skillInstruction = pstackItem.content;
|
|
468
|
-
foundSkillTitle = `${pstackItem.icon} ${pstackItem.
|
|
450
|
+
foundSkillTitle = `${pstackItem.icon} ${pstackItem.id}`;
|
|
469
451
|
}
|
|
470
452
|
}
|
|
471
453
|
}
|
|
472
|
-
prompt =
|
|
454
|
+
prompt = `[Soul of Skill · ${foundSkillTitle}]\n${skillInstruction ? `Use this skill's rules and methods as your core operating guidance:\n${skillInstruction.slice(0, 4500)}` : `Use the requirements of the "${foundSkillTitle}" skill as your operating principles.`}\n\n[Execution contract]\nPerform the work according to this skill's professional role and standards, carefully incorporating upstream deliverables.\n\n[Node task and context]\n${prompt}`;
|
|
473
455
|
}
|
|
474
456
|
let outputSummary = "";
|
|
475
|
-
// AI 条件裁决(config.aiJudge=true):条件节点走一次轻量问答做语义判定,
|
|
476
|
-
// 只能回“结论:通过/不通过”,下游按它分流;失败回落关键词。未开启还是零 token 透传。
|
|
477
457
|
const wantAiJudge = (node.role === "ai_judge" || (node.role === "condition" && node.config?.aiJudge === true)) &&
|
|
478
458
|
graph.executionMode !== "simulate";
|
|
479
459
|
let judgeModel = node.model;
|
|
480
460
|
if (wantAiJudge) {
|
|
481
|
-
const condRef = String(node.config?.condition ?? "").trim() || "
|
|
461
|
+
const condRef = String(node.config?.condition ?? "").trim() || "The upstream output meets expectations";
|
|
482
462
|
const instructionAsk = (node.instruction ?? "").trim().slice(0, 500);
|
|
483
463
|
const judgeAsk = typeof node.config?.judge === "string" && node.config.judge.trim()
|
|
484
464
|
? String(node.config.judge).trim().slice(0, 500)
|
|
485
|
-
: instructionAsk ||
|
|
465
|
+
: instructionAsk || `Determine whether the upstream output satisfies [${condRef}]`;
|
|
486
466
|
const upstreamBlock = contractContext.trim()
|
|
487
|
-
?
|
|
488
|
-
:
|
|
489
|
-
|
|
467
|
+
? `Upstream output summary:\n${contractContext.slice(0, 4000)}\nQuestion: ${judgeAsk} (use the upstream output as evidence)`
|
|
468
|
+
: `No upstream output is available. Answer this question directly: ${judgeAsk}`;
|
|
469
|
+
// These two verdict tokens are a compatibility contract with the existing decision parser.
|
|
470
|
+
prompt = `You are the workflow branch judge. Make only a binary semantic decision; do not perform other work or call tools.\n${upstreamBlock}\nThe last line must be exactly "结论:通过" or "结论:不通过". You may precede it with one line of reasoning.`;
|
|
490
471
|
judgeModel =
|
|
491
472
|
typeof node.config?.judgeModel === "string" && node.config.judgeModel.trim()
|
|
492
473
|
? node.config.judgeModel.trim().slice(0, 120)
|
|
493
474
|
: node.model;
|
|
494
|
-
this.appendLog(graph.id, nodeId, "system", `AI 裁决启动(${node.engine}/${judgeModel}):${judgeAsk.slice(0, 200)}
|
|
475
|
+
this.appendLog(graph.id, nodeId, "system", `AI 裁决启动(${node.engine}/${judgeModel}):${judgeAsk.slice(0, 200)}`, undefined, canvasRuntimeMessage("log.judgeStarted", {
|
|
476
|
+
engine: node.engine,
|
|
477
|
+
model: judgeModel,
|
|
478
|
+
question: judgeAsk.slice(0, 200),
|
|
479
|
+
}));
|
|
495
480
|
}
|
|
496
481
|
else if (!isCanvasPassthroughRole(node.role) && node.role !== "transform") {
|
|
497
|
-
prompt += `\n\n
|
|
498
|
-
1.
|
|
499
|
-
2.
|
|
500
|
-
3.
|
|
482
|
+
prompt += `\n\n[Automated workflow execution rules]:
|
|
483
|
+
1. Proceed autonomously: this is an unattended collaborative workflow. Do not stop to ask the user questions or wait for a human decision. Resolve branches using sound engineering judgment and continue.
|
|
484
|
+
2. Avoid blocking the terminal: do not leave long-running services or verification commands in the foreground. Check and resolve occupied ports (such as 3000/3001), and stop and clean up all background child processes when verification finishes.
|
|
485
|
+
3. Deliver clearly: provide a concise change summary, interface contracts, and the current status so downstream nodes or review gates can continue.`;
|
|
501
486
|
}
|
|
502
487
|
this.appendLog(graph.id, nodeId, "prompt", prompt.slice(0, 2000));
|
|
503
|
-
// 纯透传控制节点(条件/循环/人工/汇聚/记忆/结束):不启动 LLM 会话,直接透传摘要。人工审批节点停留在 waiting_approval 等待抽屉批准,不自动向下游流转。
|
|
504
488
|
if (node.role === "transform") {
|
|
505
489
|
const transformed = executeTransformNode(graph, node);
|
|
506
490
|
node.status = "done";
|
|
507
491
|
node.currentAction = "格式转换完成(本地执行)";
|
|
492
|
+
node.currentActionMessage = canvasRuntimeMessage("action.transformCompleted");
|
|
508
493
|
node.lastOutputSummary = transformed;
|
|
509
494
|
await captureControlArtifact();
|
|
510
495
|
if (!isCurrent())
|
|
@@ -522,6 +507,7 @@ export class CanvasOrchestrator {
|
|
|
522
507
|
nodeId,
|
|
523
508
|
event: "done",
|
|
524
509
|
currentAction: node.currentAction,
|
|
510
|
+
currentActionMessage: node.currentActionMessage,
|
|
525
511
|
summary: node.lastOutputSummary,
|
|
526
512
|
});
|
|
527
513
|
await this.handleDownstreamEdges(graph, node, undefined, () => lifecycleCurrent() && !controller.signal.aborted);
|
|
@@ -533,11 +519,14 @@ export class CanvasOrchestrator {
|
|
|
533
519
|
node.status = "waiting_approval";
|
|
534
520
|
node.currentAction =
|
|
535
521
|
(node.config?.approvalHint ? String(node.config.approvalHint) + " —— " : "") + "等待人工在抽屉中批准/驳回";
|
|
522
|
+
node.currentActionMessage = node.config?.approvalHint
|
|
523
|
+
? canvasRuntimeMessage("action.waitingApprovalWithHint", { hint: String(node.config.approvalHint) })
|
|
524
|
+
: canvasRuntimeMessage("action.waitingApproval");
|
|
536
525
|
node.lastOutputSummary = passthroughSummary;
|
|
537
526
|
await captureControlArtifact();
|
|
538
527
|
if (!isCurrent())
|
|
539
528
|
return;
|
|
540
|
-
this.appendLog(graph.id, nodeId, "system", "人工审批节点已就绪,等待批准");
|
|
529
|
+
this.appendLog(graph.id, nodeId, "system", "人工审批节点已就绪,等待批准", undefined, canvasRuntimeMessage("log.approvalReady"));
|
|
541
530
|
if (!isCurrent())
|
|
542
531
|
return;
|
|
543
532
|
releaseCapacity();
|
|
@@ -551,12 +540,14 @@ export class CanvasOrchestrator {
|
|
|
551
540
|
nodeId,
|
|
552
541
|
event: "paused",
|
|
553
542
|
currentAction: node.currentAction,
|
|
543
|
+
currentActionMessage: node.currentActionMessage,
|
|
554
544
|
summary: node.lastOutputSummary,
|
|
555
545
|
});
|
|
556
546
|
return;
|
|
557
547
|
}
|
|
558
548
|
node.status = "done";
|
|
559
549
|
node.currentAction = `控制节点直通 (${node.role})`;
|
|
550
|
+
node.currentActionMessage = canvasRuntimeMessage("action.passthrough", { role: node.role });
|
|
560
551
|
node.lastOutputSummary = passthroughSummary;
|
|
561
552
|
await captureControlArtifact();
|
|
562
553
|
if (!isCurrent())
|
|
@@ -574,42 +565,46 @@ export class CanvasOrchestrator {
|
|
|
574
565
|
nodeId,
|
|
575
566
|
event: "done",
|
|
576
567
|
currentAction: node.currentAction,
|
|
568
|
+
currentActionMessage: node.currentActionMessage,
|
|
577
569
|
summary: node.lastOutputSummary,
|
|
578
570
|
});
|
|
579
571
|
await this.handleDownstreamEdges(graph, node, undefined, () => lifecycleCurrent() && !controller.signal.aborted);
|
|
580
572
|
return;
|
|
581
573
|
}
|
|
582
|
-
// 双模调度:真实引擎执行 (Real Engine) vs 拓扑演练演示 (Simulation)
|
|
583
574
|
if (graph.executionMode === "simulate") {
|
|
584
|
-
await this.simulateNodeExecution(node, resolvedCwd, prompt, controller.signal, (action) => {
|
|
575
|
+
await this.simulateNodeExecution(node, resolvedCwd, prompt, controller.signal, (action, message) => {
|
|
585
576
|
if (!isCurrent())
|
|
586
577
|
return;
|
|
587
578
|
node.currentAction = action;
|
|
579
|
+
node.currentActionMessage = message;
|
|
588
580
|
this.broadcast({
|
|
589
581
|
type: "canvas_node_event",
|
|
590
582
|
graphId: graph.id,
|
|
591
583
|
nodeId,
|
|
592
584
|
event: "action",
|
|
593
585
|
currentAction: action,
|
|
586
|
+
currentActionMessage: message,
|
|
594
587
|
});
|
|
595
588
|
});
|
|
596
|
-
outputSummary = `[${node.title}]
|
|
589
|
+
outputSummary = `[${node.title}] Simulation completed, working directory: ${node.cwd || "."}`;
|
|
597
590
|
}
|
|
598
591
|
else {
|
|
599
592
|
const savedModel = node.model;
|
|
600
593
|
if (wantAiJudge && judgeModel !== node.model)
|
|
601
594
|
node.model = judgeModel;
|
|
602
595
|
try {
|
|
603
|
-
outputSummary = await this.executeRealEngineNode(graph, node, resolvedCwd, prompt, controller.signal, (action) => {
|
|
596
|
+
outputSummary = await this.executeRealEngineNode(graph, node, resolvedCwd, prompt, controller.signal, (action, message) => {
|
|
604
597
|
if (!isCurrent())
|
|
605
598
|
return;
|
|
606
599
|
node.currentAction = action;
|
|
600
|
+
node.currentActionMessage = message;
|
|
607
601
|
this.broadcast({
|
|
608
602
|
type: "canvas_node_event",
|
|
609
603
|
graphId: graph.id,
|
|
610
604
|
nodeId,
|
|
611
605
|
event: "action",
|
|
612
606
|
currentAction: action,
|
|
607
|
+
currentActionMessage: message,
|
|
613
608
|
});
|
|
614
609
|
});
|
|
615
610
|
}
|
|
@@ -633,9 +628,9 @@ export class CanvasOrchestrator {
|
|
|
633
628
|
createdAt: Date.now(),
|
|
634
629
|
workspace: workspaceArtifact,
|
|
635
630
|
};
|
|
636
|
-
// 节点完成
|
|
637
631
|
node.status = "done";
|
|
638
632
|
node.currentAction = `已完成 (${node.engine.toUpperCase()})`;
|
|
633
|
+
node.currentActionMessage = canvasRuntimeMessage("action.completed", { engine: node.engine.toUpperCase() });
|
|
639
634
|
node.lastOutputSummary = outputSummary;
|
|
640
635
|
if (wantAiJudge) {
|
|
641
636
|
const hits = [
|
|
@@ -644,10 +639,14 @@ export class CanvasOrchestrator {
|
|
|
644
639
|
const last = hits.length > 0 ? String(hits[hits.length - 1][1]).toLowerCase() : "";
|
|
645
640
|
node.aiVerdict = last ? ["通过", "成立", "是", "真", "true", "yes"].includes(last) : undefined;
|
|
646
641
|
if (node.aiVerdict === undefined)
|
|
647
|
-
throw new
|
|
642
|
+
throw new CanvasRuntimeError("AI judge returned no explicit decision", "error.judgeNoDecision");
|
|
648
643
|
this.appendLog(graph.id, nodeId, "system", node.aiVerdict === undefined
|
|
649
644
|
? "AI 裁决未给出有效结论(默认走不成立边)。"
|
|
650
|
-
: `AI 裁决结论:${node.aiVerdict ? "通过" : "不通过"}
|
|
645
|
+
: `AI 裁决结论:${node.aiVerdict ? "通过" : "不通过"}(独立判定,未混入关键词)。`, undefined, canvasRuntimeMessage(node.aiVerdict === undefined
|
|
646
|
+
? "log.judgeInvalid"
|
|
647
|
+
: node.aiVerdict
|
|
648
|
+
? "log.judgePassed"
|
|
649
|
+
: "log.judgeRejected"));
|
|
651
650
|
}
|
|
652
651
|
this.appendLog(graph.id, nodeId, "done", outputSummary.slice(0, 2000));
|
|
653
652
|
if (!isCurrent())
|
|
@@ -662,9 +661,9 @@ export class CanvasOrchestrator {
|
|
|
662
661
|
nodeId,
|
|
663
662
|
event: "done",
|
|
664
663
|
currentAction: node.currentAction,
|
|
664
|
+
currentActionMessage: node.currentActionMessage,
|
|
665
665
|
summary: node.lastOutputSummary,
|
|
666
666
|
});
|
|
667
|
-
// 触发下游交接或审查
|
|
668
667
|
await this.handleDownstreamEdges(graph, node, undefined, () => lifecycleCurrent() && !controller.signal.aborted);
|
|
669
668
|
}
|
|
670
669
|
catch (err) {
|
|
@@ -673,8 +672,10 @@ export class CanvasOrchestrator {
|
|
|
673
672
|
const msg = err.message || String(err);
|
|
674
673
|
node.status = "error";
|
|
675
674
|
node.error = msg;
|
|
675
|
+
node.errorMessage = canvasErrorMessage(err);
|
|
676
676
|
node.currentAction = `执行出错: ${msg}`;
|
|
677
|
-
|
|
677
|
+
node.currentActionMessage = node.errorMessage ?? canvasRuntimeMessage("action.failed", { error: msg });
|
|
678
|
+
this.appendLog(graph.id, node.id, "error", msg.slice(0, 2000), undefined, node.errorMessage);
|
|
678
679
|
if (!lifecycleCurrent() || controller.signal.aborted)
|
|
679
680
|
return;
|
|
680
681
|
releaseCapacity();
|
|
@@ -688,22 +689,23 @@ export class CanvasOrchestrator {
|
|
|
688
689
|
nodeId,
|
|
689
690
|
event: "error",
|
|
690
691
|
currentAction: node.currentAction,
|
|
692
|
+
currentActionMessage: node.currentActionMessage,
|
|
691
693
|
error: msg,
|
|
694
|
+
errorMessage: node.errorMessage,
|
|
692
695
|
});
|
|
693
696
|
}
|
|
694
697
|
finally {
|
|
695
698
|
releaseCapacity();
|
|
696
699
|
}
|
|
697
700
|
}
|
|
698
|
-
/** Start a fresh run; active and approval-paused runs must be resolved first. */
|
|
699
701
|
async runAll(graph, initialPrompt, runBase) {
|
|
700
702
|
if (!fsExistsSync(pathJoin(this.dataDir, "canvas", `${graph.id}.json`)))
|
|
701
703
|
return;
|
|
702
704
|
const current = this.runningGraphs.get(graph.id);
|
|
703
705
|
if (current && ["running", "waiting_approval"].includes(current.status))
|
|
704
|
-
throw new
|
|
706
|
+
throw new CanvasRuntimeError("Canvas graph already running", "error.graphRunning");
|
|
705
707
|
if ([...this.activeExecutions.values()].some((e) => e.graphId === graph.id))
|
|
706
|
-
throw new
|
|
708
|
+
throw new CanvasRuntimeError("Canvas graph already running", "error.graphRunning");
|
|
707
709
|
validateCanvasTopology(graph);
|
|
708
710
|
for (const key of this.feedbackArtifacts.keys())
|
|
709
711
|
if (key.startsWith(`${graph.id}:`))
|
|
@@ -714,7 +716,9 @@ export class CanvasOrchestrator {
|
|
|
714
716
|
for (const node of graph.nodes) {
|
|
715
717
|
node.status = "idle";
|
|
716
718
|
node.error = undefined;
|
|
719
|
+
node.errorMessage = undefined;
|
|
717
720
|
node.currentAction = undefined;
|
|
721
|
+
node.currentActionMessage = undefined;
|
|
718
722
|
node.lastOutputSummary = undefined;
|
|
719
723
|
node.artifact = undefined;
|
|
720
724
|
node.aiVerdict = undefined;
|
|
@@ -744,7 +748,6 @@ export class CanvasOrchestrator {
|
|
|
744
748
|
saveCanvasRuntimeState(this.dataDir, graph);
|
|
745
749
|
this.broadcastCanvasRuntime(graph);
|
|
746
750
|
}
|
|
747
|
-
/** A node run owns the reachable subgraph, including explicitly requested rework. */
|
|
748
751
|
runNodes(graph) {
|
|
749
752
|
if (graph.run?.scope !== "node" || !graph.run.nodeId)
|
|
750
753
|
return graph.nodes;
|
|
@@ -818,12 +821,16 @@ export class CanvasOrchestrator {
|
|
|
818
821
|
edge.active = selected;
|
|
819
822
|
edge.lastHandoffSummary = selected ? completedNode.artifact.text : undefined;
|
|
820
823
|
if (selected)
|
|
821
|
-
this.appendLog(graph.id, edge.targetNodeId, "handoff", `收到来自「${completedNode.title}」的交接:${edge.lastHandoffSummary ?? ""}
|
|
824
|
+
this.appendLog(graph.id, edge.targetNodeId, "handoff", `收到来自「${completedNode.title}」的交接:${edge.lastHandoffSummary ?? ""}`, undefined, canvasRuntimeMessage("log.handoff", {
|
|
825
|
+
title: completedNode.title,
|
|
826
|
+
summary: (edge.lastHandoffSummary ?? "").slice(0, 2000),
|
|
827
|
+
}));
|
|
822
828
|
if (!selected || !back)
|
|
823
829
|
continue;
|
|
824
830
|
if ((edge.currentLoopCount ?? 0) >= (edge.maxLoopRetries ?? 3)) {
|
|
825
831
|
completedNode.status = "waiting_approval";
|
|
826
832
|
completedNode.currentAction = "已达审查重试上限,等待人工仲裁";
|
|
833
|
+
completedNode.currentActionMessage = canvasRuntimeMessage("action.retryLimit");
|
|
827
834
|
continue;
|
|
828
835
|
}
|
|
829
836
|
const feedbackKey = `${graph.id}:${graph.run?.id}:${edge.id}`;
|
|
@@ -839,8 +846,8 @@ export class CanvasOrchestrator {
|
|
|
839
846
|
if (via === "reject" && rework.length === 0 && completedNode.status !== "waiting_approval") {
|
|
840
847
|
completedNode.status = "waiting_approval";
|
|
841
848
|
completedNode.currentAction = "Rejection requires a configured rework edge";
|
|
849
|
+
completedNode.currentActionMessage = canvasRuntimeMessage("action.reworkEdgeRequired");
|
|
842
850
|
}
|
|
843
|
-
// Reset the forward rework region, retaining the feedback contract and retry counts.
|
|
844
851
|
const reset = (id, seen = new Set()) => {
|
|
845
852
|
if (seen.has(id))
|
|
846
853
|
return;
|
|
@@ -850,6 +857,9 @@ export class CanvasOrchestrator {
|
|
|
850
857
|
this.stopNode(graph.id, id);
|
|
851
858
|
node.status = "idle";
|
|
852
859
|
node.error = undefined;
|
|
860
|
+
node.errorMessage = undefined;
|
|
861
|
+
node.currentAction = undefined;
|
|
862
|
+
node.currentActionMessage = undefined;
|
|
853
863
|
node.artifact = undefined;
|
|
854
864
|
node.lastOutputSummary = undefined;
|
|
855
865
|
node.aiVerdict = undefined;
|
|
@@ -867,7 +877,6 @@ export class CanvasOrchestrator {
|
|
|
867
877
|
return;
|
|
868
878
|
scheduled.push(this.runNode(graph, target.id, undefined, this.runBaseByGraph.get(graph.id), true));
|
|
869
879
|
}
|
|
870
|
-
// Resolve skipped branches to a fixed point before scheduling joins.
|
|
871
880
|
let changed = true;
|
|
872
881
|
while (changed) {
|
|
873
882
|
changed = false;
|
|
@@ -899,7 +908,6 @@ export class CanvasOrchestrator {
|
|
|
899
908
|
saveCanvasRuntimeState(this.dataDir, graph);
|
|
900
909
|
this.broadcastCanvasRuntime(graph);
|
|
901
910
|
}
|
|
902
|
-
/** 停止单个节点 */
|
|
903
911
|
stopNode(graphId, nodeId) {
|
|
904
912
|
const execKey = `${graphId}:${nodeId}`;
|
|
905
913
|
this.nodeGenerations.set(execKey, (this.nodeGenerations.get(execKey) ?? 0) + 1);
|
|
@@ -914,8 +922,9 @@ export class CanvasOrchestrator {
|
|
|
914
922
|
if (node) {
|
|
915
923
|
node.status = "cancelled";
|
|
916
924
|
node.currentAction = "已手动中止";
|
|
925
|
+
node.currentActionMessage = canvasRuntimeMessage("action.stopped");
|
|
917
926
|
this.settleGraph(graph);
|
|
918
|
-
this.appendLog(graphId, nodeId, "system", "已手动中止当前任务");
|
|
927
|
+
this.appendLog(graphId, nodeId, "system", "已手动中止当前任务", undefined, canvasRuntimeMessage("log.stopped"));
|
|
919
928
|
saveCanvasRuntimeState(this.dataDir, graph);
|
|
920
929
|
this.broadcastCanvasRuntime(graph);
|
|
921
930
|
this.broadcast({
|
|
@@ -924,11 +933,11 @@ export class CanvasOrchestrator {
|
|
|
924
933
|
nodeId,
|
|
925
934
|
event: "paused",
|
|
926
935
|
currentAction: node.currentAction,
|
|
936
|
+
currentActionMessage: node.currentActionMessage,
|
|
927
937
|
});
|
|
928
938
|
}
|
|
929
939
|
}
|
|
930
940
|
}
|
|
931
|
-
/** 停止全图所有正在运行的节点 */
|
|
932
941
|
stopAll(graphId) {
|
|
933
942
|
clearTimeout(this.runDeadlines.get(graphId));
|
|
934
943
|
this.runDeadlines.delete(graphId);
|
|
@@ -949,13 +958,13 @@ export class CanvasOrchestrator {
|
|
|
949
958
|
if (["running", "idle", "waiting_approval"].includes(node.status)) {
|
|
950
959
|
node.status = "cancelled";
|
|
951
960
|
node.currentAction = "已手动中止";
|
|
961
|
+
node.currentActionMessage = canvasRuntimeMessage("action.stopped");
|
|
952
962
|
}
|
|
953
963
|
}
|
|
954
964
|
saveCanvasRuntimeState(this.dataDir, graph);
|
|
955
965
|
this.broadcastCanvasRuntime(graph);
|
|
956
966
|
}
|
|
957
967
|
}
|
|
958
|
-
/** 审查门禁裁决(#707):批准/驳回落盘持久化并广播;执行中的节点同步收到审查意见 */
|
|
959
968
|
reviewNode(graphId, nodeId, decision, comment) {
|
|
960
969
|
if (!isSafeGraphId(graphId))
|
|
961
970
|
return null;
|
|
@@ -979,17 +988,24 @@ export class CanvasOrchestrator {
|
|
|
979
988
|
if (decision === "approve") {
|
|
980
989
|
node.status = "done";
|
|
981
990
|
node.currentAction = cleanComment ? `人工审查批准合流:${cleanComment}` : "人工审查批准合流";
|
|
991
|
+
node.currentActionMessage = cleanComment
|
|
992
|
+
? canvasRuntimeMessage("action.reviewApprovedComment", { comment: cleanComment })
|
|
993
|
+
: canvasRuntimeMessage("action.reviewApproved");
|
|
982
994
|
}
|
|
983
995
|
else {
|
|
984
996
|
node.status = "done";
|
|
985
997
|
node.currentAction = cleanComment ? `人工驳回:${cleanComment}` : "人工驳回:需补充完善测试与注释";
|
|
998
|
+
node.currentActionMessage = cleanComment
|
|
999
|
+
? canvasRuntimeMessage("action.reviewRejectedComment", { comment: cleanComment })
|
|
1000
|
+
: canvasRuntimeMessage("action.reviewRejected");
|
|
986
1001
|
}
|
|
987
1002
|
graph.updatedAt = Date.now();
|
|
988
1003
|
saveCanvasRuntimeState(this.dataDir, graph);
|
|
989
1004
|
this.broadcastCanvasRuntime(graph);
|
|
990
1005
|
this.runningGraphs.set(graphId, graph);
|
|
991
|
-
this.appendLog(graphId, nodeId, "review", `${decision === "approve" ? "人工审查批准合流" : "人工驳回"}${cleanComment ? `:${cleanComment}` : ""}
|
|
992
|
-
|
|
1006
|
+
this.appendLog(graphId, nodeId, "review", `${decision === "approve" ? "人工审查批准合流" : "人工驳回"}${cleanComment ? `:${cleanComment}` : ""}`, undefined, cleanComment
|
|
1007
|
+
? canvasRuntimeMessage(decision === "approve" ? "action.reviewApprovedComment" : "action.reviewRejectedComment", { comment: cleanComment })
|
|
1008
|
+
: canvasRuntimeMessage(decision === "approve" ? "action.reviewApproved" : "log.reviewRejected"));
|
|
993
1009
|
if (this.activeExecutions.has(`${graphId}:${nodeId}`)) {
|
|
994
1010
|
this.broadcast({
|
|
995
1011
|
type: "canvas_node_event",
|
|
@@ -997,19 +1013,20 @@ export class CanvasOrchestrator {
|
|
|
997
1013
|
nodeId,
|
|
998
1014
|
event: decision === "approve" ? "done" : "paused",
|
|
999
1015
|
currentAction: node.currentAction,
|
|
1016
|
+
currentActionMessage: node.currentActionMessage,
|
|
1000
1017
|
summary: node.lastOutputSummary,
|
|
1001
1018
|
});
|
|
1002
1019
|
}
|
|
1003
1020
|
void this.handleDownstreamEdges(graph, node, decision).catch((error) => {
|
|
1004
1021
|
node.status = "error";
|
|
1005
1022
|
node.error = String(error);
|
|
1023
|
+
node.errorMessage = canvasErrorMessage(error);
|
|
1006
1024
|
this.settleGraph(graph);
|
|
1007
1025
|
saveCanvasRuntimeState(this.dataDir, graph);
|
|
1008
1026
|
this.broadcastCanvasRuntime(graph);
|
|
1009
1027
|
});
|
|
1010
1028
|
return graph;
|
|
1011
1029
|
}
|
|
1012
|
-
/** 向节点插话干预 (Steer) */
|
|
1013
1030
|
async steerNode(graphId, nodeId, message) {
|
|
1014
1031
|
let graph = this.runningGraphs.get(graphId);
|
|
1015
1032
|
if (!graph) {
|
|
@@ -1025,6 +1042,7 @@ export class CanvasOrchestrator {
|
|
|
1025
1042
|
if (!node)
|
|
1026
1043
|
return;
|
|
1027
1044
|
node.currentAction = `[收到人工插话指导]: ${message.slice(0, 40)}`;
|
|
1045
|
+
node.currentActionMessage = canvasRuntimeMessage("action.steered", { preview: message.slice(0, 40) });
|
|
1028
1046
|
saveCanvasRuntimeState(this.dataDir, graph);
|
|
1029
1047
|
this.broadcastCanvasRuntime(graph);
|
|
1030
1048
|
this.appendLog(graphId, nodeId, "steer", message.slice(0, 2000));
|
|
@@ -1034,8 +1052,8 @@ export class CanvasOrchestrator {
|
|
|
1034
1052
|
nodeId,
|
|
1035
1053
|
event: "action",
|
|
1036
1054
|
currentAction: node.currentAction,
|
|
1055
|
+
currentActionMessage: node.currentActionMessage,
|
|
1037
1056
|
});
|
|
1038
|
-
// 真正投递给底层会话(若节点正在执行)
|
|
1039
1057
|
const execKey = `${graphId}:${nodeId}`;
|
|
1040
1058
|
const execution = this.activeExecutions.get(execKey);
|
|
1041
1059
|
if (execution?.session && typeof execution.session.prompt === "function") {
|
|
@@ -1043,13 +1061,13 @@ export class CanvasOrchestrator {
|
|
|
1043
1061
|
await execution.session.prompt(message);
|
|
1044
1062
|
if (execution.abortController?.signal.aborted || this.activeExecutions.get(execKey) !== execution)
|
|
1045
1063
|
return;
|
|
1046
|
-
this.appendLog(graphId, nodeId, "system", "已将插话实时投递进正在运行的智能体会话。");
|
|
1064
|
+
this.appendLog(graphId, nodeId, "system", "已将插话实时投递进正在运行的智能体会话。", undefined, canvasRuntimeMessage("log.steerDelivered"));
|
|
1047
1065
|
}
|
|
1048
1066
|
catch (err) {
|
|
1049
1067
|
if (execution.abortController?.signal.aborted || this.activeExecutions.get(execKey) !== execution)
|
|
1050
1068
|
return;
|
|
1051
1069
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1052
|
-
this.appendLog(graphId, nodeId, "error", `插话投递底层会话失败: ${errMsg}
|
|
1070
|
+
this.appendLog(graphId, nodeId, "error", `插话投递底层会话失败: ${errMsg}`, undefined, canvasRuntimeMessage("log.steerFailed", { error: errMsg.slice(0, 2000) }));
|
|
1053
1071
|
}
|
|
1054
1072
|
}
|
|
1055
1073
|
else if (node.status !== "running") {
|
|
@@ -1061,7 +1079,6 @@ export class CanvasOrchestrator {
|
|
|
1061
1079
|
}
|
|
1062
1080
|
}
|
|
1063
1081
|
}
|
|
1064
|
-
/** 重置全图节点状态为 idle */
|
|
1065
1082
|
resetStatus(graph) {
|
|
1066
1083
|
this.stopAll(graph.id);
|
|
1067
1084
|
graph.status = "idle";
|
|
@@ -1069,7 +1086,9 @@ export class CanvasOrchestrator {
|
|
|
1069
1086
|
node.status = "idle";
|
|
1070
1087
|
node.aiVerdict = undefined;
|
|
1071
1088
|
node.error = undefined;
|
|
1089
|
+
node.errorMessage = undefined;
|
|
1072
1090
|
node.currentAction = undefined;
|
|
1091
|
+
node.currentActionMessage = undefined;
|
|
1073
1092
|
node.lastOutputSummary = undefined;
|
|
1074
1093
|
}
|
|
1075
1094
|
for (const edge of graph.edges) {
|
|
@@ -1079,18 +1098,17 @@ export class CanvasOrchestrator {
|
|
|
1079
1098
|
saveCanvasRuntimeState(this.dataDir, graph);
|
|
1080
1099
|
this.broadcastCanvasRuntime(graph);
|
|
1081
1100
|
}
|
|
1082
|
-
/** 节点执行过程模拟与调度心跳(具备取消信号响应) */
|
|
1083
1101
|
async simulateNodeExecution(node, _cwd, _prompt, signal, onAction) {
|
|
1084
1102
|
const steps = [
|
|
1085
|
-
`[${node.engine.toUpperCase()}] 分析任务上下文与关联代码库...`,
|
|
1086
|
-
`[${node.engine.toUpperCase()}] 规划模块变更方案与接口契约...`,
|
|
1087
|
-
`[${node.engine.toUpperCase()}] 写入并应用变更...`,
|
|
1088
|
-
`[${node.engine.toUpperCase()}] 验证输出结果与测试检查...`,
|
|
1103
|
+
[`[${node.engine.toUpperCase()}] 分析任务上下文与关联代码库...`, "action.simulateAnalyze"],
|
|
1104
|
+
[`[${node.engine.toUpperCase()}] 规划模块变更方案与接口契约...`, "action.simulatePlan"],
|
|
1105
|
+
[`[${node.engine.toUpperCase()}] 写入并应用变更...`, "action.simulateApply"],
|
|
1106
|
+
[`[${node.engine.toUpperCase()}] 验证输出结果与测试检查...`, "action.simulateVerify"],
|
|
1089
1107
|
];
|
|
1090
|
-
for (const step of steps) {
|
|
1108
|
+
for (const [step, key] of steps) {
|
|
1091
1109
|
if (signal.aborted)
|
|
1092
1110
|
return;
|
|
1093
|
-
onAction(step);
|
|
1111
|
+
onAction(step, canvasRuntimeMessage(key, { engine: node.engine.toUpperCase() }));
|
|
1094
1112
|
const stepDelay = process.env.NODE_ENV === "test" || process.env.VITEST ? 20 : 600;
|
|
1095
1113
|
await new Promise((resolve, reject) => {
|
|
1096
1114
|
const timer = setTimeout(resolve, stepDelay);
|
|
@@ -1101,25 +1119,18 @@ export class CanvasOrchestrator {
|
|
|
1101
1119
|
});
|
|
1102
1120
|
}
|
|
1103
1121
|
}
|
|
1104
|
-
/** 真实智能体引擎执行通道(接入真实的会话、模型调用与代码修改) */
|
|
1105
1122
|
async executeRealEngineNode(graph, node, resolvedCwd, prompt, signal, onAction) {
|
|
1106
1123
|
if (!this.engineGetter) {
|
|
1107
|
-
throw new
|
|
1124
|
+
throw new CanvasRuntimeError("引擎服务提供者未注入", "error.engineProviderMissing");
|
|
1108
1125
|
}
|
|
1109
1126
|
const engineSvc = this.engineGetter(node.engine);
|
|
1110
1127
|
if (!engineSvc) {
|
|
1111
|
-
throw new
|
|
1128
|
+
throw new CanvasRuntimeError(`找不到智能体引擎:${node.engine}`, "error.engineMissing", { engine: node.engine });
|
|
1112
1129
|
}
|
|
1113
1130
|
const clientId = `canvas:${graph.id}:${node.id}`;
|
|
1114
1131
|
let collectedText = "";
|
|
1115
|
-
onAction(`[${node.engine.toUpperCase()}]
|
|
1116
|
-
// sink 具名持有:finally 必须用同一引用 detach,否则旧闭包永久残留串台(#698)
|
|
1117
|
-
// 复用当前对话流:snapshot/appended 的标准 UiMessage 直接缓存 + 转播,抽屉复用 Message 组件渲染;
|
|
1118
|
-
// 工具调用与文本增量同时记一条轻量协同事件,保证调用/错误清晰可见。
|
|
1132
|
+
onAction(`[${node.engine.toUpperCase()}] 正在接入真实引擎运行时...`, canvasRuntimeMessage("action.connecting", { engine: node.engine.toUpperCase() }));
|
|
1119
1133
|
const seenToolIds = new Set();
|
|
1120
|
-
// 本轮运行期间从直播帧里看到的 errorMessage(与快照索引无关,压缩/翻页也不会丢)。
|
|
1121
|
-
// 只收「本轮新增」的消息:attach / 首帧可能是带全量 history 的 snapshot,
|
|
1122
|
-
// 否则该节点上一次留下的旧报错会被当成本轮失败(换模型后仍报旧错)。
|
|
1123
1134
|
let sinkError;
|
|
1124
1135
|
const baselineMsgIds = new Set();
|
|
1125
1136
|
let captureErrors = false;
|
|
@@ -1130,7 +1141,10 @@ export class CanvasOrchestrator {
|
|
|
1130
1141
|
const delta = msg.delta || "";
|
|
1131
1142
|
collectedText += delta;
|
|
1132
1143
|
if (collectedText.length % 50 === 0) {
|
|
1133
|
-
onAction(`[${node.engine.toUpperCase()}] 正在生成: ${collectedText.slice(-30).replace(/\n/g, " ")}
|
|
1144
|
+
onAction(`[${node.engine.toUpperCase()}] 正在生成: ${collectedText.slice(-30).replace(/\n/g, " ")}...`, canvasRuntimeMessage("action.generating", {
|
|
1145
|
+
engine: node.engine.toUpperCase(),
|
|
1146
|
+
preview: collectedText.slice(-30).replace(/\n/g, " "),
|
|
1147
|
+
}));
|
|
1134
1148
|
}
|
|
1135
1149
|
}
|
|
1136
1150
|
else if (msg.type === "snapshot" || msg.type === "snapshot_delta") {
|
|
@@ -1146,9 +1160,9 @@ export class CanvasOrchestrator {
|
|
|
1146
1160
|
seenToolIds.add(tid);
|
|
1147
1161
|
this.appendLog(graph.id, node.id, "tool", m.isError
|
|
1148
1162
|
? `工具 ${m.toolName} 报错${m.errorMessage ? `:${m.errorMessage.slice(0, 500)}` : ""}`
|
|
1149
|
-
: `正在调用工具: ${m.toolName}`, m.toolName);
|
|
1163
|
+
: `正在调用工具: ${m.toolName}`, m.toolName, canvasRuntimeMessage(m.isError ? (m.errorMessage ? "log.toolFailedDetail" : "log.toolFailed") : "log.tool", { tool: m.toolName, ...(m.isError && m.errorMessage ? { error: m.errorMessage.slice(0, 500) } : {}) }));
|
|
1150
1164
|
}
|
|
1151
|
-
onAction(`[${node.engine.toUpperCase()}] 正在调用工具: ${m.toolName}
|
|
1165
|
+
onAction(`[${node.engine.toUpperCase()}] 正在调用工具: ${m.toolName}`, canvasRuntimeMessage("action.tool", { engine: node.engine.toUpperCase(), tool: m.toolName }));
|
|
1152
1166
|
}
|
|
1153
1167
|
else if (m.errorMessage) {
|
|
1154
1168
|
if (captureErrors && !baselineMsgIds.has(m.id))
|
|
@@ -1165,7 +1179,7 @@ export class CanvasOrchestrator {
|
|
|
1165
1179
|
const cs = await engineSvc.attach(clientId, sink);
|
|
1166
1180
|
const checkCurrent = () => {
|
|
1167
1181
|
if (signal.aborted || this.activeExecutions.get(execKey) !== execution)
|
|
1168
|
-
throw new
|
|
1182
|
+
throw new CanvasRuntimeError("任务已被手动中止", "error.aborted");
|
|
1169
1183
|
};
|
|
1170
1184
|
if (!signal.aborted && this.activeExecutions.get(execKey) === execution && execution) {
|
|
1171
1185
|
execution.session = cs;
|
|
@@ -1176,26 +1190,23 @@ export class CanvasOrchestrator {
|
|
|
1176
1190
|
await cs.setCwd(resolvedCwd);
|
|
1177
1191
|
}
|
|
1178
1192
|
checkCurrent();
|
|
1179
|
-
// 真实应用模型切换(若模型不存在或 Key 无效,真实报错)
|
|
1180
|
-
// 归一化双前缀:历史存量可能是 opencode-go/opencode-go/xxx,压成 opencode-go/xxx 再切换。
|
|
1181
1193
|
if (node.model) {
|
|
1182
1194
|
if (typeof cs.switchModelOrThrow !== "function")
|
|
1183
|
-
throw new
|
|
1195
|
+
throw new CanvasRuntimeError(`Engine cannot select model: ${node.model}`, "error.modelSelection", {
|
|
1196
|
+
model: node.model,
|
|
1197
|
+
});
|
|
1184
1198
|
await cs.switchModelOrThrow(normalizeCanvasModelId(node.model));
|
|
1185
1199
|
}
|
|
1186
1200
|
node.actualEngine = node.engine;
|
|
1187
1201
|
node.actualModel = node.model;
|
|
1188
1202
|
checkCurrent();
|
|
1189
|
-
// 真实应用思考强度
|
|
1190
1203
|
if (node.thinkingLevel && typeof cs.setThinking === "function") {
|
|
1191
1204
|
try {
|
|
1192
1205
|
cs.setThinking(node.thinkingLevel);
|
|
1193
1206
|
}
|
|
1194
1207
|
catch { }
|
|
1195
1208
|
}
|
|
1196
|
-
onAction(`[${node.engine.toUpperCase()}]
|
|
1197
|
-
// 本轮起点快照:报错检测只看本次运行新增的消息,
|
|
1198
|
-
// 避免把该节点历史运行留下的旧报错当成本轮失败。
|
|
1209
|
+
onAction(`[${node.engine.toUpperCase()}] 开始执行任务...`, canvasRuntimeMessage("action.running", { engine: node.engine.toUpperCase() }));
|
|
1199
1210
|
const preRunMsgs = canvasSnapshotMessages(cs);
|
|
1200
1211
|
for (const m of preRunMsgs)
|
|
1201
1212
|
baselineMsgIds.add(m.id);
|
|
@@ -1215,41 +1226,35 @@ export class CanvasOrchestrator {
|
|
|
1215
1226
|
signal.removeEventListener("abort", abortSession);
|
|
1216
1227
|
}
|
|
1217
1228
|
checkCurrent();
|
|
1218
|
-
// 等待执行完成(带超时和取消监听)
|
|
1219
1229
|
const startTime = Date.now();
|
|
1220
1230
|
const maxWaitMs = 15 * 60 * 1000;
|
|
1221
1231
|
while (!signal.aborted) {
|
|
1222
1232
|
await new Promise((r) => setTimeout(r, 1200));
|
|
1223
1233
|
if (signal.aborted) {
|
|
1224
1234
|
await cs.abort().catch(() => { });
|
|
1225
|
-
throw new
|
|
1235
|
+
throw new CanvasRuntimeError("任务已被手动中止", "error.aborted");
|
|
1226
1236
|
}
|
|
1227
1237
|
let isStreaming = false;
|
|
1228
1238
|
let turnError;
|
|
1229
1239
|
if (typeof cs.readConversationForPlugins === "function") {
|
|
1230
1240
|
const snap = cs.readConversationForPlugins();
|
|
1231
1241
|
isStreaming = snap?.isStreaming === true;
|
|
1232
|
-
// 注意:PluginConversationSnapshot 并无 `lastError` 字段(旧写法恒为 undefined),
|
|
1233
|
-
// 于是 API 报错(如 403 RegionError)被当成执行成功、节点照样标 done。
|
|
1234
|
-
// 与定时任务桥(agent-service-daemon)同口径:读尾部 assistant 消息的 errorMessage;
|
|
1235
|
-
// 自动重试中的失败消息会被服务端隐藏,中止回合不算报错。
|
|
1236
1242
|
turnError =
|
|
1237
1243
|
tailAssistantError(canvasSnapshotMessages(cs).slice(baselineMsgCount)) ??
|
|
1238
1244
|
(sinkError && !CANVAS_ABORT_MESSAGES.test(sinkError.trim()) ? sinkError : undefined);
|
|
1239
1245
|
}
|
|
1240
1246
|
if (turnError) {
|
|
1241
|
-
throw new
|
|
1247
|
+
throw new CanvasRuntimeError(`引擎执行失败:${turnError}`, "error.engineFailed", { error: turnError });
|
|
1242
1248
|
}
|
|
1243
1249
|
if (!isStreaming && Date.now() - startTime > 3000) {
|
|
1244
1250
|
break;
|
|
1245
1251
|
}
|
|
1246
1252
|
if (Date.now() - startTime > maxWaitMs) {
|
|
1247
1253
|
await cs.abort().catch(() => { });
|
|
1248
|
-
throw new
|
|
1254
|
+
throw new CanvasRuntimeError("任务执行超时 (15分钟)", "error.timeout");
|
|
1249
1255
|
}
|
|
1250
1256
|
}
|
|
1251
1257
|
checkCurrent();
|
|
1252
|
-
// 真实检测代码变更统计(仅本地项目支持本地 git diff)
|
|
1253
1258
|
let diffSummary = "";
|
|
1254
1259
|
try {
|
|
1255
1260
|
if (!isRemoteWorkspaceUri(resolvedCwd)) {
|
|
@@ -1259,18 +1264,15 @@ export class CanvasOrchestrator {
|
|
|
1259
1264
|
windowsHide: true,
|
|
1260
1265
|
});
|
|
1261
1266
|
if (diffStat.trim()) {
|
|
1262
|
-
diffSummary = `\n
|
|
1267
|
+
diffSummary = `\n[Code change statistics]:\n${diffStat.trim()}`;
|
|
1263
1268
|
}
|
|
1264
1269
|
}
|
|
1265
1270
|
}
|
|
1266
1271
|
catch { }
|
|
1267
|
-
// 交付正文:优先用流式增量累积,其次取本轮新增的 assistant 正文。
|
|
1268
|
-
// (部分引擎/重连路径只走 snapshot 增量、没有 message_delta,collectedText 会是空的,
|
|
1269
|
-
// 旧逻辑于是把下游交接内容写成「交付完成(未产生文件修改)」的占位文案)
|
|
1270
1272
|
const replyText = (collectedText.trim() || extractRunReplyText(canvasSnapshotMessages(cs).slice(baselineMsgCount))).trim();
|
|
1271
1273
|
if (replyText)
|
|
1272
1274
|
return `${replyText}${diffSummary}`;
|
|
1273
|
-
return `[${node.title}]
|
|
1275
|
+
return `[${node.title}] Delivery completed${diffSummary || " (no file changes)"}`;
|
|
1274
1276
|
}
|
|
1275
1277
|
finally {
|
|
1276
1278
|
if (execution) {
|
|
@@ -1280,7 +1282,6 @@ export class CanvasOrchestrator {
|
|
|
1280
1282
|
}
|
|
1281
1283
|
}
|
|
1282
1284
|
}
|
|
1283
|
-
/** 读一次会话快照里的消息列表(快照失败/引擎不支持时返回空数组,不抛出)。 */
|
|
1284
1285
|
function canvasSnapshotMessages(cs) {
|
|
1285
1286
|
const reader = cs
|
|
1286
1287
|
?.readConversationForPlugins;
|
|
@@ -1294,9 +1295,7 @@ function canvasSnapshotMessages(cs) {
|
|
|
1294
1295
|
return [];
|
|
1295
1296
|
}
|
|
1296
1297
|
}
|
|
1297
|
-
/** SDK 主动中止的精确文案(与 web/src/aborted-turn.ts 同口径,中止不是真实报错) */
|
|
1298
1298
|
const CANVAS_ABORT_MESSAGES = /^(This operation was aborted|Request aborted|任务已被手动中止)$/;
|
|
1299
|
-
/** 末尾 assistant 回合若是真实报错,返回其 errorMessage;正常收尾或中止返回 undefined。 */
|
|
1300
1299
|
function tailAssistantError(msgs) {
|
|
1301
1300
|
for (let i = msgs.length - 1; i >= 0; i--) {
|
|
1302
1301
|
const m = msgs[i];
|
|
@@ -1311,7 +1310,6 @@ function tailAssistantError(msgs) {
|
|
|
1311
1310
|
}
|
|
1312
1311
|
return undefined;
|
|
1313
1312
|
}
|
|
1314
|
-
/** 从本轮新增消息里取最后一条 assistant 正文(text 块拼接),作为交付摘要兜底。 */
|
|
1315
1313
|
function extractRunReplyText(msgs) {
|
|
1316
1314
|
for (let i = msgs.length - 1; i >= 0; i--) {
|
|
1317
1315
|
const m = msgs[i];
|
|
@@ -1327,7 +1325,6 @@ function extractRunReplyText(msgs) {
|
|
|
1327
1325
|
}
|
|
1328
1326
|
return "";
|
|
1329
1327
|
}
|
|
1330
|
-
/** 纯透传控制节点集合(与前端 CanvasTypes.PASSTHROUGH_ROLES 保持一致) */
|
|
1331
1328
|
const CANVAS_PASSTHROUGH_ROLES = new Set([
|
|
1332
1329
|
"condition",
|
|
1333
1330
|
"loop",
|
|
@@ -1342,7 +1339,6 @@ const CANVAS_PASSTHROUGH_ROLES = new Set([
|
|
|
1342
1339
|
function isCanvasPassthroughRole(role) {
|
|
1343
1340
|
return CANVAS_PASSTHROUGH_ROLES.has(role);
|
|
1344
1341
|
}
|
|
1345
|
-
/** 格式转换节点:本地确定性执行,无需 LLM。text2json / json2text / template。 */
|
|
1346
1342
|
function executeTransformNode(graph, node) {
|
|
1347
1343
|
const cfg = node.config ?? {};
|
|
1348
1344
|
const mode = String(cfg["mode"] ?? "text2json");
|
|
@@ -1356,7 +1352,7 @@ function executeTransformNode(graph, node) {
|
|
|
1356
1352
|
try {
|
|
1357
1353
|
if (mode === "json2text") {
|
|
1358
1354
|
if (!fallbackInput)
|
|
1359
|
-
return "
|
|
1355
|
+
return "[Format conversion " + node.title + "] Empty input; no output";
|
|
1360
1356
|
try {
|
|
1361
1357
|
const v = JSON.parse(fallbackInput);
|
|
1362
1358
|
if (Array.isArray(v))
|
|
@@ -1378,7 +1374,7 @@ function executeTransformNode(graph, node) {
|
|
|
1378
1374
|
return tpl.split("{{input}}").join(fallbackInput).split("{{上游摘要}}").join(fallbackInput);
|
|
1379
1375
|
}
|
|
1380
1376
|
if (!fallbackInput)
|
|
1381
|
-
return "
|
|
1377
|
+
return "[Format conversion " + node.title + "] Empty input; no output";
|
|
1382
1378
|
try {
|
|
1383
1379
|
return JSON.stringify(JSON.parse(fallbackInput), null, 2);
|
|
1384
1380
|
}
|
|
@@ -1387,10 +1383,9 @@ function executeTransformNode(graph, node) {
|
|
|
1387
1383
|
}
|
|
1388
1384
|
}
|
|
1389
1385
|
catch (err) {
|
|
1390
|
-
return "
|
|
1386
|
+
return "[Format conversion " + node.title + "] Conversion failed: " + err.message;
|
|
1391
1387
|
}
|
|
1392
1388
|
}
|
|
1393
|
-
/** 归一化画布模型 ID:历史存量可能是 provider/provider/xxx,压成 provider/xxx */
|
|
1394
1389
|
function normalizeCanvasModelId(raw) {
|
|
1395
1390
|
const t = (raw ?? "").trim();
|
|
1396
1391
|
const slash = t.indexOf("/");
|
|
@@ -1408,43 +1403,34 @@ function buildPassthroughSummary(node, contractContext, initialPrompt) {
|
|
|
1408
1403
|
const cfgText = Object.entries(cfg)
|
|
1409
1404
|
.map(([k, v]) => `${k}=${String(v)}`)
|
|
1410
1405
|
.slice(0, 8)
|
|
1411
|
-
.join("
|
|
1412
|
-
const contract = contractContext
|
|
1406
|
+
.join("; ");
|
|
1407
|
+
const contract = contractContext || "(No upstream input; passing through directly)";
|
|
1413
1408
|
switch (node.role) {
|
|
1414
1409
|
case "condition":
|
|
1415
|
-
return
|
|
1410
|
+
return `[Condition branch ${node.title}] Decision configuration: ${cfgText || "No expression configured; using the true branch by default"}\nUpstream deliverables:\n${contract}`;
|
|
1416
1411
|
case "loop":
|
|
1417
|
-
return
|
|
1412
|
+
return `[Loop control ${node.title}] Loop configuration: ${cfgText || "Up to 3 attempts by default (circuit breaker)"}\nUpstream deliverables:\n${contract}`;
|
|
1418
1413
|
case "human":
|
|
1419
|
-
return
|
|
1414
|
+
return `[Human approval ${node.title}] ${cfgText ? `Approval hint: ${cfgText}` : ""}\nWaiting for approval or rejection in the node drawer. Upstream deliverables:\n${contract}`;
|
|
1420
1415
|
case "trigger": {
|
|
1421
1416
|
const popup = (initialPrompt ?? "").trim();
|
|
1422
1417
|
const payload = popup || String(cfg["payload"] ?? "").trim() || String(node.instruction ?? "").trim();
|
|
1423
1418
|
const extra = contractContext || "";
|
|
1424
1419
|
if (payload)
|
|
1425
|
-
return
|
|
1426
|
-
|
|
1427
|
-
"】任务内容:\n" +
|
|
1428
|
-
payload +
|
|
1429
|
-
(extra ? "\n上游输入:\n" + extra : ""));
|
|
1430
|
-
return ("【手动触发 · 业务需求输入 " + node.title + "】" + (extra ? "上游输入:\n" + extra : "(无载荷,直接启动)"));
|
|
1420
|
+
return `[Manual trigger · Task input ${node.title}] Task:\n${payload}${extra ? "\nUpstream input:\n" + extra : ""}`;
|
|
1421
|
+
return `[Manual trigger · Task input ${node.title}]${extra ? "Upstream input:\n" + extra : "(No payload; starting directly)"}`;
|
|
1431
1422
|
}
|
|
1432
1423
|
case "cron":
|
|
1433
|
-
return
|
|
1434
|
-
node.title +
|
|
1435
|
-
"】计划:" +
|
|
1436
|
-
(cfgText || "未配置 Cron(默认手动拉起)") +
|
|
1437
|
-
"\n透传上游产物:\n" +
|
|
1438
|
-
contract);
|
|
1424
|
+
return `[Scheduled trigger ${node.title}] Schedule: ${cfgText || "No Cron configured (manual start by default)"}\nUpstream deliverables:\n${contract}`;
|
|
1439
1425
|
case "webhook":
|
|
1440
|
-
return
|
|
1426
|
+
return `[Webhook trigger ${node.title}] Connection configuration: ${cfgText || "No path configured"}\nUpstream deliverables:\n${contract}`;
|
|
1441
1427
|
case "merge":
|
|
1442
|
-
return
|
|
1428
|
+
return `[Merge ${node.title}] Combined upstream deliverables:\n${contract}`;
|
|
1443
1429
|
case "memory":
|
|
1444
|
-
return
|
|
1430
|
+
return `[Memory ${node.title}] Memory key: ${cfgText || "default"}\nSnapshot:\n${contract}`;
|
|
1445
1431
|
case "end":
|
|
1446
|
-
return
|
|
1432
|
+
return `[Workflow end ${node.title}] Final delivery summary:\n${contract}`;
|
|
1447
1433
|
default:
|
|
1448
|
-
return
|
|
1434
|
+
return `[Control node ${node.title}] Pass-through:\n${contract}`;
|
|
1449
1435
|
}
|
|
1450
1436
|
}
|