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,86 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CanvasRuntimeError } from "./canvas-runtime-messages.js";
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
-
import { mkdir, readFile, realpath,
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
signal?.throwIfAborted();
|
|
7
|
-
}
|
|
8
|
-
function safeId(value) {
|
|
9
|
-
if (!/^[a-zA-Z0-9_-][a-zA-Z0-9_.-]{0,127}$/.test(value) || value === "." || value === "..") {
|
|
10
|
-
throw new Error(`Invalid canvas workspace identifier: ${value}`);
|
|
11
|
-
}
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
function inside(root, path) {
|
|
15
|
-
const rel = relative(root, path);
|
|
16
|
-
return !isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`);
|
|
17
|
-
}
|
|
18
|
-
async function canonicalPath(path) {
|
|
19
|
-
try {
|
|
20
|
-
return await realpath(path);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
if (error.code !== "ENOENT")
|
|
24
|
-
throw error;
|
|
25
|
-
const parent = resolve(path, "..");
|
|
26
|
-
if (parent === path)
|
|
27
|
-
throw error;
|
|
28
|
-
return join(await canonicalPath(parent), relative(parent, path));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async function git(cwd, args, signal, index, input) {
|
|
32
|
-
checkSignal(signal);
|
|
33
|
-
// Never let an inherited Git context redirect commands to the user's other repository/index.
|
|
34
|
-
const env = { ...process.env };
|
|
35
|
-
for (const key of Object.keys(env)) {
|
|
36
|
-
if (/^GIT_/i.test(key))
|
|
37
|
-
delete env[key];
|
|
38
|
-
}
|
|
39
|
-
if (index)
|
|
40
|
-
env.GIT_INDEX_FILE = index;
|
|
41
|
-
const stdout = await new Promise((done, reject) => {
|
|
42
|
-
const child = execFile("git", ["-c", "core.hooksPath=", ...args], {
|
|
43
|
-
cwd,
|
|
44
|
-
signal,
|
|
45
|
-
windowsHide: true,
|
|
46
|
-
timeout: 60_000,
|
|
47
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
48
|
-
env,
|
|
49
|
-
}, (error, stdout) => (error ? reject(error) : done(stdout)));
|
|
50
|
-
// Apply the bytes we validated, rather than reopening an attacker-replaceable path.
|
|
51
|
-
child.stdin?.on("error", () => {
|
|
52
|
-
/* execFile reports process failure. */
|
|
53
|
-
});
|
|
54
|
-
child.stdin?.end(input);
|
|
55
|
-
});
|
|
56
|
-
checkSignal(signal);
|
|
57
|
-
return stdout;
|
|
58
|
-
}
|
|
3
|
+
import { mkdir, readFile, realpath, writeFile } from "node:fs/promises";
|
|
4
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
5
|
+
import { canonicalPath, checkSignal, createDetachedWorktree, git, inside, safeId, snapshotTree, verifyWorktreeIdentity, } from "../workspace-handle.js";
|
|
59
6
|
function workspaceDir(workspace, kind) {
|
|
60
7
|
return join(resolve(workspace.dataDir), "canvas", kind, safeId(workspace.graphId), safeId(workspace.runId), safeId(workspace.nodeId));
|
|
61
8
|
}
|
|
62
|
-
/** Build a tree without touching the user's index, branch, or commit history. Ignored files are excluded. */
|
|
63
|
-
async function snapshotTree(cwd, dataDir, signal) {
|
|
64
|
-
const scratch = join(resolve(dataDir), "canvas", "indexes");
|
|
65
|
-
await mkdir(scratch, { recursive: true });
|
|
66
|
-
const index = join(scratch, randomUUID());
|
|
67
|
-
try {
|
|
68
|
-
await git(cwd, ["read-tree", "HEAD"], signal, index);
|
|
69
|
-
await git(cwd, ["add", "-A", "--", "."], signal, index);
|
|
70
|
-
return (await git(cwd, ["write-tree"], signal, index)).trim();
|
|
71
|
-
}
|
|
72
|
-
finally {
|
|
73
|
-
await rm(index, { force: true });
|
|
74
|
-
await rm(`${index}.lock`, { force: true });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
9
|
function layersOf(artifacts) {
|
|
78
10
|
const layers = new Map();
|
|
79
11
|
for (const artifact of artifacts) {
|
|
80
12
|
for (const layer of artifact.layers) {
|
|
81
13
|
const prior = layers.get(layer.id);
|
|
82
14
|
if (prior && prior.sha256 !== layer.sha256)
|
|
83
|
-
throw new
|
|
15
|
+
throw new CanvasRuntimeError(`Conflicting canvas artifact identity: ${layer.id}`, "error.artifactIdentityConflict", { id: layer.id });
|
|
84
16
|
if (!prior)
|
|
85
17
|
layers.set(layer.id, layer);
|
|
86
18
|
}
|
|
@@ -88,48 +20,43 @@ function layersOf(artifacts) {
|
|
|
88
20
|
return [...layers.values()];
|
|
89
21
|
}
|
|
90
22
|
async function trustedArtifactPath(workspace, path, nodeId) {
|
|
91
|
-
// graph/run come from the service's prepare arguments, never imported artifact metadata.
|
|
92
23
|
const root = join(workspace.dataDir, "canvas", "artifacts");
|
|
93
24
|
const runRoot = join(root, workspace.graphId, workspace.runId);
|
|
94
25
|
const resolved = resolve(path);
|
|
95
26
|
const parts = relative(runRoot, resolved).split(sep);
|
|
96
27
|
if (parts.length !== 2 || (nodeId && parts[0] !== nodeId) || !/^[a-zA-Z0-9-]+\.patch$/.test(parts[1] ?? "")) {
|
|
97
|
-
throw new
|
|
28
|
+
throw new CanvasRuntimeError("Untrusted canvas artifact path", "error.untrustedArtifactPath");
|
|
98
29
|
}
|
|
99
30
|
safeId(parts[0]);
|
|
100
31
|
if (!inside(runRoot, resolved) || (await realpath(resolved)) !== resolved || (await realpath(root)) !== root) {
|
|
101
|
-
throw new
|
|
32
|
+
throw new CanvasRuntimeError("Untrusted canvas artifact path: canonical location mismatch", "error.artifactLocationMismatch");
|
|
102
33
|
}
|
|
103
34
|
return resolved;
|
|
104
35
|
}
|
|
36
|
+
const workspaceIdentities = new WeakMap();
|
|
105
37
|
async function assertWorkspaceIdentity(workspace, signal) {
|
|
106
38
|
const expected = workspaceDir(workspace, "workspaces");
|
|
107
39
|
if (!workspace.worktreePath ||
|
|
108
40
|
!workspace.repoRoot ||
|
|
109
41
|
resolve(workspace.worktreePath) !== expected ||
|
|
110
42
|
(await realpath(expected)) !== expected) {
|
|
111
|
-
throw new
|
|
43
|
+
throw new CanvasRuntimeError("Canvas worktree identity mismatch: canonical path changed", "error.worktreePathChanged");
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const identity = workspaceIdentities.get(workspace);
|
|
47
|
+
if (!identity)
|
|
48
|
+
throw new CanvasRuntimeError("Unregistered canvas workspace", "error.workspaceUnregistered");
|
|
49
|
+
await verifyWorktreeIdentity(expected, workspace.repoRoot, signal, identity.gitDir, identity.commonDir);
|
|
112
50
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const sourceCommon = (await git(workspace.repoRoot, ["rev-parse", "--path-format=absolute", "--git-common-dir"], signal)).trim();
|
|
116
|
-
const gitDir = (await git(expected, ["rev-parse", "--absolute-git-dir"], signal)).trim();
|
|
117
|
-
const canonicalGitDir = await realpath(gitDir);
|
|
118
|
-
const canonicalCommon = await realpath(common);
|
|
119
|
-
if (resolve(top) !== expected ||
|
|
120
|
-
canonicalCommon !== (await realpath(sourceCommon)) ||
|
|
121
|
-
canonicalGitDir === canonicalCommon ||
|
|
122
|
-
!inside(join(canonicalCommon, "worktrees"), canonicalGitDir) ||
|
|
123
|
-
resolve((await readFile(join(canonicalGitDir, "gitdir"), "utf8")).trim()) !== join(expected, ".git")) {
|
|
124
|
-
throw new Error("Canvas worktree identity mismatch: Git repository changed");
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new CanvasRuntimeError("Canvas worktree identity mismatch: Git repository changed", "error.worktreeRepoChanged", undefined, { cause: error });
|
|
125
53
|
}
|
|
126
54
|
}
|
|
127
|
-
/** No fallback: an isolation request either returns a detached worktree or throws. */
|
|
128
55
|
export async function prepareCanvasWorkspace(options) {
|
|
129
56
|
checkSignal(options.signal);
|
|
130
57
|
for (const value of [options.baseCwd, options.cwd ?? ""]) {
|
|
131
58
|
if (/^(?:ssh:\/\/|[^/\\]+@[^:]+:)/i.test(value))
|
|
132
|
-
throw new
|
|
59
|
+
throw new CanvasRuntimeError("Remote SSH canvas workspaces are not supported", "error.remoteUnsupported");
|
|
133
60
|
}
|
|
134
61
|
const baseCwd = resolve(options.baseCwd);
|
|
135
62
|
const cwd = resolve(baseCwd, options.cwd ?? ".");
|
|
@@ -151,32 +78,32 @@ export async function prepareCanvasWorkspace(options) {
|
|
|
151
78
|
}
|
|
152
79
|
catch (error) {
|
|
153
80
|
checkSignal(options.signal);
|
|
154
|
-
throw new
|
|
81
|
+
throw new CanvasRuntimeError("Canvas isolation requires a local Git repository", "error.localGitRequired", undefined, { cause: error });
|
|
155
82
|
}
|
|
156
83
|
repoRoot = await realpath(repoRoot);
|
|
157
84
|
const canonicalCwd = await canonicalPath(cwd);
|
|
158
85
|
workspace.dataDir = await canonicalPath(workspace.dataDir);
|
|
159
86
|
if (!inside(repoRoot, canonicalCwd))
|
|
160
|
-
throw new
|
|
87
|
+
throw new CanvasRuntimeError("Canvas cwd must be within the baseline repository", "error.cwdOutsideRepo");
|
|
161
88
|
if (inside(repoRoot, workspace.dataDir))
|
|
162
|
-
throw new
|
|
89
|
+
throw new CanvasRuntimeError("Canvas isolation dataDir must be outside the baseline repository", "error.dataDirInsideRepo");
|
|
163
90
|
if ((await git(repoRoot, ["status", "--porcelain", "--untracked-files=all"], options.signal)).trim()) {
|
|
164
|
-
throw new
|
|
91
|
+
throw new CanvasRuntimeError("Canvas isolation refuses a dirty baseline; commit or stash changes explicitly first", "error.dirtyBaseline");
|
|
165
92
|
}
|
|
166
93
|
const requestedBase = options.baseCommit ?? upstreamArtifacts[0]?.baseCommit ?? "HEAD";
|
|
167
94
|
if (requestedBase.startsWith("-"))
|
|
168
|
-
throw new
|
|
95
|
+
throw new CanvasRuntimeError("Invalid canvas base commit", "error.invalidBaseCommit");
|
|
169
96
|
const baseCommit = (await git(repoRoot, ["rev-parse", "--verify", `${requestedBase}^{commit}`], options.signal)).trim();
|
|
170
97
|
for (const artifact of upstreamArtifacts) {
|
|
171
98
|
if (resolve(artifact.repoRoot) !== resolve(repoRoot) || artifact.baseCommit !== baseCommit) {
|
|
172
|
-
throw new
|
|
99
|
+
throw new CanvasRuntimeError("Canvas upstream artifacts must share the repository and baseline commit", "error.upstreamBaselineMismatch");
|
|
173
100
|
}
|
|
174
101
|
}
|
|
175
102
|
const patches = [];
|
|
176
103
|
for (const artifact of upstreamArtifacts) {
|
|
177
104
|
if ((artifact.graphId && artifact.graphId !== workspace.graphId) ||
|
|
178
105
|
(artifact.runId && artifact.runId !== workspace.runId)) {
|
|
179
|
-
throw new
|
|
106
|
+
throw new CanvasRuntimeError("Untrusted canvas artifact graph/run", "error.untrustedArtifactRun");
|
|
180
107
|
}
|
|
181
108
|
await trustedArtifactPath(workspace, artifact.patchPath, artifact.nodeId);
|
|
182
109
|
}
|
|
@@ -187,20 +114,21 @@ export async function prepareCanvasWorkspace(options) {
|
|
|
187
114
|
!nodeId ||
|
|
188
115
|
!/^[a-f0-9]{40,64}$/.test(tree ?? "") ||
|
|
189
116
|
extra.length) {
|
|
190
|
-
throw new
|
|
117
|
+
throw new CanvasRuntimeError("Untrusted canvas artifact layer identity", "error.untrustedArtifactLayer");
|
|
191
118
|
}
|
|
192
119
|
const patchPath = await trustedArtifactPath(workspace, layer.patchPath, safeId(nodeId));
|
|
193
120
|
const bytes = await readFile(patchPath, { signal: options.signal });
|
|
194
121
|
if (createHash("sha256").update(bytes).digest("hex") !== layer.sha256)
|
|
195
|
-
throw new
|
|
122
|
+
throw new CanvasRuntimeError(`Canvas artifact checksum mismatch: ${layer.id}`, "error.artifactChecksum", {
|
|
123
|
+
id: layer.id,
|
|
124
|
+
});
|
|
196
125
|
patches.push({ layer, bytes });
|
|
197
126
|
}
|
|
198
127
|
const worktreePath = workspaceDir(workspace, "workspaces");
|
|
199
128
|
await mkdir(resolve(worktreePath, ".."), { recursive: true });
|
|
200
129
|
if ((await canonicalPath(worktreePath)) !== worktreePath)
|
|
201
|
-
throw new
|
|
202
|
-
await
|
|
203
|
-
// Once created, failures deliberately retain the workspace for inspection. Never remove dirty outputs.
|
|
130
|
+
throw new CanvasRuntimeError("Canvas worktree path is redirected", "error.worktreeRedirected");
|
|
131
|
+
await createDetachedWorktree(repoRoot, worktreePath, baseCommit, options.signal);
|
|
204
132
|
for (const { layer, bytes } of patches) {
|
|
205
133
|
checkSignal(options.signal);
|
|
206
134
|
if (!bytes.length)
|
|
@@ -211,16 +139,14 @@ export async function prepareCanvasWorkspace(options) {
|
|
|
211
139
|
}
|
|
212
140
|
catch (error) {
|
|
213
141
|
checkSignal(options.signal);
|
|
214
|
-
throw new
|
|
215
|
-
cause: error,
|
|
216
|
-
});
|
|
142
|
+
throw new CanvasRuntimeError(`Canvas upstream artifact conflict: ${layer.id}; workspace retained at ${worktreePath}`, "error.artifactConflict", { id: layer.id, path: worktreePath }, { cause: error });
|
|
217
143
|
}
|
|
218
144
|
}
|
|
219
145
|
const preparedCwd = join(worktreePath, relative(repoRoot, canonicalCwd));
|
|
220
146
|
if (!inside(worktreePath, await canonicalPath(preparedCwd)))
|
|
221
|
-
throw new
|
|
147
|
+
throw new CanvasRuntimeError("Canvas integrated cwd escapes its worktree", "error.cwdEscapesWorktree");
|
|
222
148
|
checkSignal(options.signal);
|
|
223
|
-
|
|
149
|
+
const prepared = {
|
|
224
150
|
...workspace,
|
|
225
151
|
cwd: preparedCwd,
|
|
226
152
|
repoRoot,
|
|
@@ -228,8 +154,10 @@ export async function prepareCanvasWorkspace(options) {
|
|
|
228
154
|
baseCommit,
|
|
229
155
|
inputTree: await snapshotTree(worktreePath, workspace.dataDir, options.signal),
|
|
230
156
|
};
|
|
157
|
+
const identity = await verifyWorktreeIdentity(worktreePath, repoRoot, options.signal);
|
|
158
|
+
workspaceIdentities.set(prepared, { gitDir: identity.gitDir, commonDir: identity.commonDir });
|
|
159
|
+
return prepared;
|
|
231
160
|
}
|
|
232
|
-
/** Includes tracked changes, deletions, and non-ignored untracked files, including binary additions. */
|
|
233
161
|
export async function captureCanvasWorkspaceArtifact(workspace, options = {}) {
|
|
234
162
|
checkSignal(options.signal);
|
|
235
163
|
if (!workspace.isolated ||
|
|
@@ -237,7 +165,7 @@ export async function captureCanvasWorkspaceArtifact(workspace, options = {}) {
|
|
|
237
165
|
!workspace.repoRoot ||
|
|
238
166
|
!workspace.baseCommit ||
|
|
239
167
|
!workspace.inputTree) {
|
|
240
|
-
throw new
|
|
168
|
+
throw new CanvasRuntimeError("Canvas artifact capture requires a prepared isolated workspace", "error.captureRequiresWorkspace");
|
|
241
169
|
}
|
|
242
170
|
await assertWorkspaceIdentity(workspace, options.signal);
|
|
243
171
|
const outputTree = await snapshotTree(workspace.worktreePath, workspace.dataDir, options.signal);
|
|
@@ -246,7 +174,7 @@ export async function captureCanvasWorkspaceArtifact(workspace, options = {}) {
|
|
|
246
174
|
const directory = workspaceDir(workspace, "artifacts");
|
|
247
175
|
await mkdir(directory, { recursive: true });
|
|
248
176
|
if ((await realpath(directory)) !== directory)
|
|
249
|
-
throw new
|
|
177
|
+
throw new CanvasRuntimeError("Untrusted canvas artifact output directory", "error.untrustedArtifactOutput");
|
|
250
178
|
// Immutable capture paths keep already-prepared consumers independent of subsequent captures.
|
|
251
179
|
const patchPath = join(directory, `${randomUUID()}.patch`);
|
|
252
180
|
checkSignal(options.signal);
|
|
@@ -267,18 +195,18 @@ export async function captureCanvasWorkspaceArtifact(workspace, options = {}) {
|
|
|
267
195
|
layers: [...layersOf(workspace.upstreamArtifacts), layer],
|
|
268
196
|
};
|
|
269
197
|
}
|
|
270
|
-
/** Explicit clean-only cleanup. Artifacts are never deleted, and dirty worktrees are retained. */
|
|
271
198
|
export async function cleanupCanvasWorkspace(workspace, options = {}) {
|
|
272
199
|
checkSignal(options.signal);
|
|
273
200
|
if (!workspace.isolated || !workspace.worktreePath || !workspace.repoRoot || !workspace.baseCommit)
|
|
274
201
|
return;
|
|
275
202
|
if (resolve(workspace.worktreePath) !== workspaceDir(workspace, "workspaces"))
|
|
276
|
-
throw new
|
|
203
|
+
throw new CanvasRuntimeError("Invalid canvas cleanup path", "error.invalidCleanupPath");
|
|
277
204
|
await assertWorkspaceIdentity(workspace, options.signal);
|
|
278
205
|
const head = (await git(workspace.worktreePath, ["rev-parse", "HEAD"], options.signal)).trim();
|
|
279
206
|
if (head !== workspace.baseCommit ||
|
|
280
207
|
(await git(workspace.worktreePath, ["status", "--porcelain", "--untracked-files=all"], options.signal)).trim()) {
|
|
281
|
-
throw new
|
|
208
|
+
throw new CanvasRuntimeError("Canvas workspace has pending artifacts or commits; retained for explicit adoption", "error.pendingArtifacts");
|
|
282
209
|
}
|
|
283
210
|
await git(workspace.repoRoot, ["worktree", "remove", workspace.worktreePath], options.signal);
|
|
211
|
+
workspaceIdentities.delete(workspace);
|
|
284
212
|
}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// claim-files-tool.ts — 文件认领(claim_files):并行冲突的「事前打招呼」
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// 触碰集是事后信息(写完才知道),claim 是事前意图("我要改这几个文件")。
|
|
5
|
-
// advisory 语义:认领只出现在提醒/files/list 里升级措辞,不拦 edit/bash ——
|
|
6
|
-
// 强制锁会死锁(见 claim-store.ts 文件头)。先到先得;自己的可刷新,
|
|
7
|
-
// 别人的动不了;过期自动释放 + 发 prompt 心跳续期 + 对话关闭释放。
|
|
8
|
-
//
|
|
9
|
-
// 开关走统一工具 tab(AGENT_TOOL_CATALOG 目录 + 设置页开关行;ActiveSet 门控,
|
|
10
|
-
// live 生效):认领是纯 advisory(关掉只会少提醒),默认开。DSH 引擎无 customTool
|
|
11
|
-
// 注册面,只有 pi 引擎对话能认领(提醒是服务端算的,DSH 照样能看到别人的认领)。
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
1
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
14
2
|
import { Type } from "typebox";
|
|
15
3
|
import { pick } from "./i18n.js";
|
|
16
4
|
import { CLAIM_FILES_TOOL_NAME } from "./tool-manager.js";
|
|
17
5
|
import { CLAIM_TTL_MS, resolveClaimPath } from "./claim-store.js";
|
|
18
|
-
/** 工具名(唯一定义在 tool-manager.ts,本模块 re-export 供单测沿用,模式同 present-files-tool.ts)。 */
|
|
19
6
|
export { CLAIM_FILES_TOOL_NAME };
|
|
20
7
|
function fmtTtl(ms) {
|
|
21
8
|
const m = Math.round(ms / 60000);
|
|
@@ -31,7 +18,7 @@ export function makeClaimFilesTool(host, lang) {
|
|
|
31
18
|
name: CLAIM_FILES_TOOL_NAME,
|
|
32
19
|
label: "Claim files to avoid parallel conflicts",
|
|
33
20
|
description: "Declare files you are about to edit so parallel runs in the same project steer clear (advisory — never blocks edits). " +
|
|
34
|
-
"Claims
|
|
21
|
+
"Claims release when the run ends (completion, error, or stop); prompts refresh their 30-minute fallback expiry. " +
|
|
35
22
|
"Paths must stay inside the project.",
|
|
36
23
|
promptSnippet: "reserve files you are about to edit (parallel-run guard)",
|
|
37
24
|
parameters: Type.Object({
|
|
@@ -104,7 +91,6 @@ export function makeClaimFilesTool(host, lang) {
|
|
|
104
91
|
conflicts: conflicts.map((c) => ({ path: c.path, ownerTitle: c.claim.ownerTitle })),
|
|
105
92
|
});
|
|
106
93
|
}
|
|
107
|
-
// release 指定 paths:只放自己的,别人的动不了(返回里如实说)。
|
|
108
94
|
const n = store.release(cwd, self.convId, rawPaths);
|
|
109
95
|
return text(pick(getLang(), n > 0
|
|
110
96
|
? `已释放 ${n} 条你名下的认领(别人的动不了,也没动)。`
|
|
@@ -1,38 +1,12 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// claim-store.ts — 文件认领表(claim store)+ 触碰 sidecar
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// 背景:触碰集是「事后诸葛亮」(写完才知道),并行冲突要的是「事前打招呼」。
|
|
5
|
-
// claim = 某对话声明「我要改这几个文件」,其他对话在提醒/files/status 里看到
|
|
6
|
-
// 并绕行。注意这只是 advisory(建议):提醒措辞升级,但不拦 edit/bash ——
|
|
7
|
-
// 强制锁会引入死锁与 stall(见设计说明), first-wins + 过期自动释放是唯一的
|
|
8
|
-
// 防腐机制(fail-open:丢认领只会少一条提醒,绝不卡死任何人)。
|
|
9
|
-
//
|
|
10
|
-
// 存放:
|
|
11
|
-
// - 认领表全局共享(跨浏览器标签页可见)→ AgentService 级单例,落盘
|
|
12
|
-
// <dataDir>/claims.json(SubagentTemplatesStore 同款 best-effort 持久化:
|
|
13
|
-
// 写坏/读坏绝不弄崩 server,坏文件直接丢弃重建)。
|
|
14
|
-
// - 触碰 sidecar 按会话落盘(<转录文件>.touches.json):压缩后旧消息被摘要
|
|
15
|
-
// 替代,sidecar 让 files/status 在压缩后仍有答案;只读小文件,不扫全量转录。
|
|
16
|
-
// inMemory 子代理没有转录文件 → 无 sidecar,走实时消息(老样子)。
|
|
17
|
-
//
|
|
18
|
-
// key 口径:认领按「项目 cwd」分表(默认不跨项目);路径一律存绝对路径
|
|
19
|
-
// (认领时按 conv cwd resolve),比对时触碰路径同样 resolve 后比较 —— 后缀
|
|
20
|
-
// 模糊匹配继续禁用(假阳性比漏报更糟,见 conversation-touches 文件头)。
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
1
|
import { readFileSync, statSync, unlinkSync } from "node:fs";
|
|
23
2
|
import { resolve, sep } from "node:path";
|
|
24
3
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
25
4
|
import { normalizeTouchPath, unionTouchLists } from "./conversation-touches.js";
|
|
26
|
-
/** 认领默认 TTL:30 分钟(每次发 prompt 心跳续期,对话关闭时释放)。 */
|
|
27
5
|
export const CLAIM_TTL_MS = 30 * 60 * 1000;
|
|
28
|
-
/** 认领 TTL 上下限(工具参数钳制用)。 */
|
|
29
6
|
export const CLAIM_TTL_MIN_MS = 60 * 1000;
|
|
30
7
|
export const CLAIM_TTL_MAX_MS = 8 * 60 * 60 * 1000;
|
|
31
|
-
/** sidecar 条目上限(防无界增长;超了按 lastTs 掐尾)。 */
|
|
32
8
|
export const SIDECAR_MAX_ENTRIES = 500;
|
|
33
|
-
/** claims.json 版本(以后改格式时迁移用)。 */
|
|
34
9
|
const CLAIMS_FILE_VERSION = 1;
|
|
35
|
-
/** cwd 分表键:绝对归一(大小写不归一,见 touches 局限 3)。 */
|
|
36
10
|
function cwdKey(cwd) {
|
|
37
11
|
try {
|
|
38
12
|
return resolve(cwd);
|
|
@@ -41,7 +15,6 @@ function cwdKey(cwd) {
|
|
|
41
15
|
return cwd;
|
|
42
16
|
}
|
|
43
17
|
}
|
|
44
|
-
/** 认领路径合法性:必须落在 conv cwd 内(../ 逃逸拒绝,由工具转报错)。 */
|
|
45
18
|
export function resolveClaimPath(raw, cwd) {
|
|
46
19
|
if (typeof raw !== "string" || !raw.trim())
|
|
47
20
|
return undefined;
|
|
@@ -69,7 +42,6 @@ function isValidClaim(c) {
|
|
|
69
42
|
typeof o.claimedAt === "number" &&
|
|
70
43
|
typeof o.expiresAt === "number");
|
|
71
44
|
}
|
|
72
|
-
/** 项目级认领表(AgentService 级单例;I/O 全 best-effort)。 */
|
|
73
45
|
export class ClaimStore {
|
|
74
46
|
file;
|
|
75
47
|
tables = new Map();
|
|
@@ -77,7 +49,6 @@ export class ClaimStore {
|
|
|
77
49
|
this.file = file;
|
|
78
50
|
this.load();
|
|
79
51
|
}
|
|
80
|
-
/** 认领:先到先得。别人(含过期前)的 → conflicts;自己的 → 刷新 note/过期。 */
|
|
81
52
|
claim(cwd, owner, inputs, now = Date.now()) {
|
|
82
53
|
const key = cwdKey(cwd);
|
|
83
54
|
this.sweepTable(key, now);
|
|
@@ -87,7 +58,7 @@ export class ClaimStore {
|
|
|
87
58
|
for (const input of inputs) {
|
|
88
59
|
const abs = resolveClaimPath(input.path, cwd);
|
|
89
60
|
if (!abs)
|
|
90
|
-
continue;
|
|
61
|
+
continue;
|
|
91
62
|
const ttl = typeof input.ttlMs === "number" && Number.isFinite(input.ttlMs)
|
|
92
63
|
? Math.min(CLAIM_TTL_MAX_MS, Math.max(CLAIM_TTL_MIN_MS, Math.floor(input.ttlMs)))
|
|
93
64
|
: CLAIM_TTL_MS;
|
|
@@ -114,7 +85,6 @@ export class ClaimStore {
|
|
|
114
85
|
this.save();
|
|
115
86
|
return { claimed, conflicts };
|
|
116
87
|
}
|
|
117
|
-
/** 释放:只放自己的(别人的动不了);paths 空 = 全放。返回释放条数。 */
|
|
118
88
|
release(cwd, ownerConvId, paths, now = Date.now()) {
|
|
119
89
|
const key = cwdKey(cwd);
|
|
120
90
|
this.sweepTable(key, now);
|
|
@@ -135,7 +105,6 @@ export class ClaimStore {
|
|
|
135
105
|
this.save();
|
|
136
106
|
return n;
|
|
137
107
|
}
|
|
138
|
-
/** 按 owner 全放(对话关闭/释放时调)。返回释放条数。 */
|
|
139
108
|
releaseByOwner(ownerConvId, now = Date.now()) {
|
|
140
109
|
let n = 0;
|
|
141
110
|
for (const [key, table] of this.tables) {
|
|
@@ -148,7 +117,6 @@ export class ClaimStore {
|
|
|
148
117
|
this.save();
|
|
149
118
|
return n;
|
|
150
119
|
}
|
|
151
|
-
/** 心跳续期:该 owner 的全部认领延长 TTL(发 prompt 时调)。返回续期条数。 */
|
|
152
120
|
touch(ownerConvId, now = Date.now()) {
|
|
153
121
|
let n = 0;
|
|
154
122
|
for (const [key, table] of this.tables) {
|
|
@@ -164,7 +132,6 @@ export class ClaimStore {
|
|
|
164
132
|
this.save();
|
|
165
133
|
return n;
|
|
166
134
|
}
|
|
167
|
-
/** 读某项目认领表(已扫过期,返回副本,调用方随便改)。 */
|
|
168
135
|
list(cwd, now = Date.now()) {
|
|
169
136
|
const key = cwdKey(cwd);
|
|
170
137
|
this.sweepTable(key, now);
|
|
@@ -186,7 +153,7 @@ export class ClaimStore {
|
|
|
186
153
|
raw = readFileSync(this.file, "utf8");
|
|
187
154
|
}
|
|
188
155
|
catch {
|
|
189
|
-
return;
|
|
156
|
+
return;
|
|
190
157
|
}
|
|
191
158
|
try {
|
|
192
159
|
const data = JSON.parse(raw);
|
|
@@ -206,7 +173,6 @@ export class ClaimStore {
|
|
|
206
173
|
}
|
|
207
174
|
}
|
|
208
175
|
catch {
|
|
209
|
-
// 坏文件丢弃(下次 save 覆盖重建),绝不抛错
|
|
210
176
|
this.tables.clear();
|
|
211
177
|
}
|
|
212
178
|
}
|
|
@@ -214,12 +180,9 @@ export class ClaimStore {
|
|
|
214
180
|
try {
|
|
215
181
|
writeJsonAtomicSync(this.file, { version: CLAIMS_FILE_VERSION, tables: Object.fromEntries(this.tables) });
|
|
216
182
|
}
|
|
217
|
-
catch {
|
|
218
|
-
// 持久化故障绝不能弄崩 server(内存表照常用)
|
|
219
|
-
}
|
|
183
|
+
catch { }
|
|
220
184
|
}
|
|
221
185
|
}
|
|
222
|
-
/** 触碰集里命中认领表的条目(双方都 resolve 成绝对路径后比较)。 */
|
|
223
186
|
export function matchClaims(touches, claims, cwd) {
|
|
224
187
|
if (!Array.isArray(touches) || !Array.isArray(claims) || touches.length === 0 || claims.length === 0)
|
|
225
188
|
return [];
|
|
@@ -242,7 +205,6 @@ export function matchClaims(touches, claims, cwd) {
|
|
|
242
205
|
function sidecarPath(sessionFile) {
|
|
243
206
|
return `${sessionFile}.touches.json`;
|
|
244
207
|
}
|
|
245
|
-
/** 读触碰 sidecar(同步小文件;不存在/坏了 → undefined,调用方回落现算)。 */
|
|
246
208
|
export function readTouchSidecar(sessionFile) {
|
|
247
209
|
if (typeof sessionFile !== "string" || !sessionFile)
|
|
248
210
|
return undefined;
|
|
@@ -270,7 +232,6 @@ export function readTouchSidecar(sessionFile) {
|
|
|
270
232
|
return undefined;
|
|
271
233
|
}
|
|
272
234
|
}
|
|
273
|
-
/** 写触碰 sidecar(读-合并-写;空集不写;全 best-effort, never throw)。 */
|
|
274
235
|
export async function mergeTouchSidecar(sessionFile, fresh) {
|
|
275
236
|
if (typeof sessionFile !== "string" || !sessionFile)
|
|
276
237
|
return;
|
|
@@ -280,18 +241,13 @@ export async function mergeTouchSidecar(sessionFile, fresh) {
|
|
|
280
241
|
const merged = unionTouchLists(readTouchSidecar(sessionFile) ?? [], fresh).slice(0, SIDECAR_MAX_ENTRIES);
|
|
281
242
|
writeJsonAtomicSync(sidecarPath(sessionFile), { version: 1, updatedAt: Date.now(), files: merged });
|
|
282
243
|
}
|
|
283
|
-
catch {
|
|
284
|
-
// sidecar 只是加速+防压缩丢失,写坏了下次重算
|
|
285
|
-
}
|
|
244
|
+
catch { }
|
|
286
245
|
}
|
|
287
|
-
/** 删 sidecar(会话删除时顺带;不存在不报错)。 */
|
|
288
246
|
export function removeTouchSidecar(sessionFile) {
|
|
289
247
|
if (typeof sessionFile !== "string" || !sessionFile)
|
|
290
248
|
return;
|
|
291
249
|
try {
|
|
292
250
|
unlinkSync(sidecarPath(sessionFile));
|
|
293
251
|
}
|
|
294
|
-
catch {
|
|
295
|
-
// 不存在或删不掉都无所谓
|
|
296
|
-
}
|
|
252
|
+
catch { }
|
|
297
253
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* client-id-utils — 伪客户端 ID 判断与插件调用工作区校验。
|
|
3
|
-
*
|
|
4
|
-
* 负责:
|
|
5
|
-
* - isPseudoClientId: 判断是否为插件或定时任务的无头伪客户端(sink 常驻)
|
|
6
|
-
* - checkPluginCwd: 校验插件指定的工作目录合法性(防止 Windows SystemRoot 误操作)
|
|
7
|
-
*
|
|
8
|
-
* 从 agent-service.ts 抽出为独立模块。
|
|
9
|
-
*/
|
|
10
1
|
import { statSync } from "node:fs";
|
|
11
2
|
import { resolve, sep } from "node:path";
|
|
12
|
-
/** issue #226:插件无头调用的工作目录校验(纯函数,可单测)。
|
|
13
|
-
* 存在性语义与定时任务一致(须存在且为目录,不默默跑错目录);另在
|
|
14
|
-
* Windows 下拒绝 SystemRoot 及其子树(如 C:\Windows\System32)——后台服务/
|
|
15
|
-
* 快捷方式启动时宿主 cwd 常飘到 system32,直接跑就是高危误操作。 */
|
|
16
3
|
export function checkPluginCwd(cwd) {
|
|
17
4
|
const trimmed = String(cwd ?? "").trim();
|
|
18
5
|
if (!trimmed)
|
|
@@ -45,15 +32,12 @@ export function checkPluginCwd(cwd) {
|
|
|
45
32
|
}
|
|
46
33
|
return { ok: true, abs };
|
|
47
34
|
}
|
|
48
|
-
/** Private Bot execution IDs carry process-local authority and must never join browser adoption. */
|
|
49
35
|
export function isDeviceTaskClientId(id) {
|
|
50
36
|
return id.startsWith("device-task-");
|
|
51
37
|
}
|
|
52
|
-
/** Private execution channels and pseudo clients cannot adopt or be adopted by browsers. */
|
|
53
38
|
export function isOrphanAdoptionExcludedClientId(id) {
|
|
54
39
|
return isDeviceTaskClientId(id) || isPseudoClientId(id);
|
|
55
40
|
}
|
|
56
|
-
/** 插件/调度/Canvas伪客户端:sink 常驻或后台辅助专用通道,不参与聊天会话认领与感知。 */
|
|
57
41
|
export function isPseudoClientId(id) {
|
|
58
42
|
return (id.startsWith("plugin:") || id.startsWith("scheduler:") || id.startsWith("canvas:") || id.startsWith("canvas-"));
|
|
59
43
|
}
|