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
|
@@ -10,8 +10,6 @@ import { selectTaskContext } from "./task-context-budget.js";
|
|
|
10
10
|
import { registerBotExecution } from "./bot-execution.js";
|
|
11
11
|
import { DeviceExecutionError, executionFailure } from "./execution-failure.js";
|
|
12
12
|
import { projectToolLifecycle } from "./task-progress.js";
|
|
13
|
-
// Process-local guards survive executor replacement. They deliberately never retry an
|
|
14
|
-
// uncertain attempt. Durable delivery must additionally deduplicate in its task store.
|
|
15
13
|
const attempted = new Set();
|
|
16
14
|
const busyExecutions = new Set();
|
|
17
15
|
const TIMEOUT_MS = 20 * 60 * 1000;
|
|
@@ -35,11 +33,25 @@ function samePath(a, b) {
|
|
|
35
33
|
}
|
|
36
34
|
export function taskPrompt(task) {
|
|
37
35
|
const context = task.taskState ? selectTaskContext(task.taskState) : undefined;
|
|
36
|
+
const isCode = (task.executionMode ?? task.contract?.executionMode) === "code";
|
|
37
|
+
const effectiveText = isCode && task.contract?.goal ? task.contract.goal : task.text;
|
|
38
|
+
const contractInfo = task.contract
|
|
39
|
+
? {
|
|
40
|
+
contractId: task.contract.id,
|
|
41
|
+
contractRevision: task.contract.revision,
|
|
42
|
+
contractDigest: task.contract.digest,
|
|
43
|
+
executionMode: task.contract.executionMode,
|
|
44
|
+
goal: task.contract.goal,
|
|
45
|
+
constraints: task.contract.constraints,
|
|
46
|
+
acceptanceCriteria: task.contract.acceptanceCriteria,
|
|
47
|
+
baseline: task.contract.baseline,
|
|
48
|
+
}
|
|
49
|
+
: undefined;
|
|
38
50
|
return [
|
|
39
51
|
`Device task ${JSON.stringify(task.id)}, attempt ${JSON.stringify(task.attemptId)}.`,
|
|
40
52
|
`Local system (measured by this bridge): ${os.platform()} / ${os.arch()}.`,
|
|
41
53
|
JSON.stringify({
|
|
42
|
-
text:
|
|
54
|
+
text: effectiveText,
|
|
43
55
|
taskState: context?.state,
|
|
44
56
|
taskStateSelection: context?.selection,
|
|
45
57
|
roomId: task.roomId ?? null,
|
|
@@ -50,25 +62,26 @@ export function taskPrompt(task) {
|
|
|
50
62
|
requestId: task.requestId,
|
|
51
63
|
parentTaskId: task.parentTaskId,
|
|
52
64
|
resultOfTaskId: task.resultOfTaskId,
|
|
53
|
-
handoff: task.handoff ?? null,
|
|
65
|
+
handoff: isCode ? null : (task.handoff ?? null),
|
|
66
|
+
contract: contractInfo,
|
|
67
|
+
executionMode: isCode ? "code" : "chat",
|
|
54
68
|
...(task.attenuatedTools && task.attenuatedTools.length ? { attenuatedTools: task.attenuatedTools } : {}),
|
|
55
69
|
}),
|
|
56
70
|
].join("\n\n");
|
|
57
71
|
}
|
|
58
|
-
/** Connects as an independent client; never changes approval settings or retries.
|
|
59
|
-
* close() cancels only this client's locked task conversation. Failures reject with
|
|
60
|
-
* a bounded report; completed sessions remain persisted for local inspection.
|
|
61
|
-
* close() is permanent: after a disconnect, create a fresh executor and explicitly
|
|
62
|
-
* create a new task. Reconnection does not resume or retry an interrupted task.
|
|
63
|
-
*/
|
|
64
72
|
export function createDeviceTaskExecutor(options) {
|
|
65
73
|
const origin = originUrl(options.localOrigin);
|
|
66
74
|
if (!isAbsolute(options.cwd))
|
|
67
75
|
throw new Error("cwd must be an absolute local path");
|
|
76
|
+
if (options.executionCwd !== undefined && !isAbsolute(options.executionCwd)) {
|
|
77
|
+
throw new Error("executionCwd must be an absolute local path");
|
|
78
|
+
}
|
|
68
79
|
const cwd = resolve(options.cwd);
|
|
80
|
+
const effectiveCwd = options.executionCwd ? resolve(options.executionCwd) : cwd;
|
|
69
81
|
const root = executionRoot(cwd);
|
|
70
82
|
let closed = false;
|
|
71
83
|
let cancel;
|
|
84
|
+
let activeSend;
|
|
72
85
|
let stopped = Promise.resolve();
|
|
73
86
|
return {
|
|
74
87
|
run(task) {
|
|
@@ -78,6 +91,10 @@ export function createDeviceTaskExecutor(options) {
|
|
|
78
91
|
return Promise.reject(new DeviceTaskError("目标设备未开启群任务执行权限。请在该设备的设备中心 → 连接设置中开启“允许智能体任务与文件导入”。 / Local task execution is disabled.", "Local task execution is disabled"));
|
|
79
92
|
if (!task.id || !task.attemptId || !task.text?.trim())
|
|
80
93
|
return Promise.reject(new Error("Invalid task"));
|
|
94
|
+
const isCodeMode = (task.executionMode ?? options.executionMode ?? task.contract?.executionMode) === "code";
|
|
95
|
+
if (isCodeMode && task.resume) {
|
|
96
|
+
return Promise.reject(new DeviceTaskError("Code execution mode refuses resuming old sessions in first slice"));
|
|
97
|
+
}
|
|
81
98
|
if ([...busyExecutions].some((entry) => entry.origin === origin.origin && (entry.botId === task.botId || executionRootsOverlap(entry.root, root))))
|
|
82
99
|
return Promise.reject(new DeviceTaskError("目标设备正在执行另一个群任务,请稍后再试。 / Local task executor busy.", "Local task executor busy"));
|
|
83
100
|
const key = JSON.stringify([origin.origin, task.id]);
|
|
@@ -107,6 +124,13 @@ export function createDeviceTaskExecutor(options) {
|
|
|
107
124
|
planOnly: Boolean(task.planOnly),
|
|
108
125
|
attenuatedTools: task.attenuatedTools,
|
|
109
126
|
sourceBotId: task.sourceBotId,
|
|
127
|
+
executionCwd: effectiveCwd,
|
|
128
|
+
executionMode: isCodeMode ? "code" : "chat",
|
|
129
|
+
workspaceHandleId: options.workspaceHandleId,
|
|
130
|
+
workspaceCapability: options.workspaceCapability,
|
|
131
|
+
deviceId: task.deviceId,
|
|
132
|
+
taskId: task.id,
|
|
133
|
+
attemptId: task.attemptId,
|
|
110
134
|
});
|
|
111
135
|
attempted.add(key);
|
|
112
136
|
const lock = { origin: origin.origin, botId: task.botId, root };
|
|
@@ -136,8 +160,6 @@ export function createDeviceTaskExecutor(options) {
|
|
|
136
160
|
let idleConfirmed = false;
|
|
137
161
|
let stopUnconfirmed = false;
|
|
138
162
|
let interactions;
|
|
139
|
-
// Immediate notifications can precede snapshots. Keep them until an
|
|
140
|
-
// explicit resolution or a snapshot-observed wait has disappeared.
|
|
141
163
|
const humanWaits = new Set();
|
|
142
164
|
let snapshotWaits = new Set();
|
|
143
165
|
let queuedQuestions = new Set();
|
|
@@ -194,6 +216,7 @@ export function createDeviceTaskExecutor(options) {
|
|
|
194
216
|
if (ws.readyState === WebSocket.OPEN)
|
|
195
217
|
ws.send(JSON.stringify(message));
|
|
196
218
|
};
|
|
219
|
+
activeSend = send;
|
|
197
220
|
const context = () => `Task: ${task.id}\nAttempt: ${task.attemptId}\nLocal system: ${os.platform()} / ${os.arch()}\nLocal UI: ${origin.origin}/\nClient: ${clientId}\nConversation: ${conversationId ?? "not created"}`;
|
|
198
221
|
const finish = (error, body = "", failurePhase) => {
|
|
199
222
|
if (settled)
|
|
@@ -201,13 +224,8 @@ export function createDeviceTaskExecutor(options) {
|
|
|
201
224
|
settled = true;
|
|
202
225
|
interactions?.close();
|
|
203
226
|
options.registerInteractionAnswer?.(undefined);
|
|
227
|
+
activeSend = undefined;
|
|
204
228
|
capability.revoke();
|
|
205
|
-
// 锁的语义是「这个 bot/root 上还有一条任务在跑」,而 run 一旦 settle(capability
|
|
206
|
-
// 已撤销、不再有任何写入路径),它就不再是在跑。旧实现只在连接 close 时才放锁:
|
|
207
|
-
// ① 用户/守护重试一条刚结束的任务,在 close 到达前一律被判「本地执行器忙」;
|
|
208
|
-
// ② 单测里上一条 run 的 close 还没到,下一条就被误判 busy(CI 随机红)。
|
|
209
|
-
// 这里在 settle 时就放锁(幂等,后面 confirmStopped 的 delete 变成 no-op);
|
|
210
|
-
// 同 workspace 并发写的护栏仍然是 capability.revoke() + 新的 bot lease。
|
|
211
229
|
busyExecutions.delete(lock);
|
|
212
230
|
try {
|
|
213
231
|
if (sessionBound)
|
|
@@ -220,8 +238,6 @@ export function createDeviceTaskExecutor(options) {
|
|
|
220
238
|
sessionBound = false;
|
|
221
239
|
}
|
|
222
240
|
clearTimeout(timer);
|
|
223
|
-
// abort has no conversationId in the wire protocol. Only send while
|
|
224
|
-
// the private connection still points at the conversation we prompted.
|
|
225
241
|
cancel = undefined;
|
|
226
242
|
if (!prompted || idleConfirmed)
|
|
227
243
|
confirmStopped();
|
|
@@ -470,15 +486,13 @@ export function createDeviceTaskExecutor(options) {
|
|
|
470
486
|
confirmStopped();
|
|
471
487
|
return;
|
|
472
488
|
}
|
|
473
|
-
// Initialization/new_chat failures can arrive as snapshots before a
|
|
474
|
-
// task conversation exists. Do not wait for a successful transition.
|
|
475
489
|
const snapshotError = Reflect.get(state, "error");
|
|
476
490
|
if (state.errorMessage || (typeof snapshotError === "string" && snapshotError)) {
|
|
477
491
|
finish(state.errorMessage || snapshotError);
|
|
478
492
|
return;
|
|
479
493
|
}
|
|
480
494
|
if (phase === "initial" || (phase === "cwd" && cwdDone)) {
|
|
481
|
-
if (resolve(state.cwd) !==
|
|
495
|
+
if (resolve(state.cwd) !== effectiveCwd) {
|
|
482
496
|
if (phase === "cwd") {
|
|
483
497
|
finish("Workspace switch did not reach requested cwd");
|
|
484
498
|
return;
|
|
@@ -504,7 +518,7 @@ export function createDeviceTaskExecutor(options) {
|
|
|
504
518
|
}
|
|
505
519
|
else if (state.messages.length || state.historyTotal)
|
|
506
520
|
return;
|
|
507
|
-
if (state.isEphemeral || resolve(state.cwd) !==
|
|
521
|
+
if (state.isEphemeral || resolve(state.cwd) !== effectiveCwd) {
|
|
508
522
|
finish("Task session is not persistent in requested cwd");
|
|
509
523
|
return;
|
|
510
524
|
}
|
|
@@ -513,8 +527,6 @@ export function createDeviceTaskExecutor(options) {
|
|
|
513
527
|
finish("New session requires local human input");
|
|
514
528
|
return;
|
|
515
529
|
}
|
|
516
|
-
// AgentSession.sessionId delegates to sessionManager.getSessionId(),
|
|
517
|
-
// the same SDK identifier captured by device_collab tool context.
|
|
518
530
|
if (!state.sessionId) {
|
|
519
531
|
finish("Task session has no SDK session ID");
|
|
520
532
|
return;
|
|
@@ -532,7 +544,6 @@ export function createDeviceTaskExecutor(options) {
|
|
|
532
544
|
finish("Task session ownership registration failed");
|
|
533
545
|
return;
|
|
534
546
|
}
|
|
535
|
-
// A callback may synchronously close the executor.
|
|
536
547
|
if (settled)
|
|
537
548
|
return;
|
|
538
549
|
priorMessageIds = new Set(state.messages.map((m) => m.id));
|
|
@@ -553,7 +564,6 @@ export function createDeviceTaskExecutor(options) {
|
|
|
553
564
|
conversationId: conversationId,
|
|
554
565
|
isCurrent: () => !settled && currentId === conversationId && state?.sessionId === sdkSessionId,
|
|
555
566
|
send: (message) => {
|
|
556
|
-
// The bridge has validated task/attempt/conversation and consumed the request ID.
|
|
557
567
|
binding.authorizeInteractionReply(message);
|
|
558
568
|
send(message);
|
|
559
569
|
},
|
|
@@ -575,7 +585,7 @@ export function createDeviceTaskExecutor(options) {
|
|
|
575
585
|
finish("Task SDK session ownership changed");
|
|
576
586
|
return;
|
|
577
587
|
}
|
|
578
|
-
if (resolve(state.cwd) !==
|
|
588
|
+
if (resolve(state.cwd) !== effectiveCwd ||
|
|
579
589
|
state.isEphemeral ||
|
|
580
590
|
(options.resumePath && !samePath(state.sessionFile, options.resumePath))) {
|
|
581
591
|
finish("Task transcript or fixed workspace ownership changed");
|
|
@@ -591,8 +601,6 @@ export function createDeviceTaskExecutor(options) {
|
|
|
591
601
|
return;
|
|
592
602
|
}
|
|
593
603
|
}
|
|
594
|
-
// Revisions, get_state responses, transport heartbeats and usage-only
|
|
595
|
-
// snapshots are not evidence that the task is making progress.
|
|
596
604
|
const fingerprint = createHash("sha256")
|
|
597
605
|
.update(JSON.stringify([state.messages.map((m) => [m.id, m.content]), state.streamingMessage?.content]))
|
|
598
606
|
.digest("hex");
|
|
@@ -714,8 +722,15 @@ export function createDeviceTaskExecutor(options) {
|
|
|
714
722
|
});
|
|
715
723
|
});
|
|
716
724
|
},
|
|
725
|
+
steer(text) {
|
|
726
|
+
if (closed || !activeSend)
|
|
727
|
+
return false;
|
|
728
|
+
activeSend({ type: "prompt", text, steer: true });
|
|
729
|
+
return true;
|
|
730
|
+
},
|
|
717
731
|
close() {
|
|
718
732
|
closed = true;
|
|
733
|
+
activeSend = undefined;
|
|
719
734
|
cancel?.();
|
|
720
735
|
return stopped;
|
|
721
736
|
},
|
|
@@ -13,8 +13,6 @@ export const identity = (s) => `${s.dev}:${s.ino}:${s.size}:${s.mtimeMs}:${s.cti
|
|
|
13
13
|
export function checkSignal(signal) {
|
|
14
14
|
signal?.throwIfAborted();
|
|
15
15
|
}
|
|
16
|
-
/** Portable paths only. Case-fold duplicates even on case-sensitive hosts so a
|
|
17
|
-
* bundle retains the same meaning when sent to Windows/macOS. */
|
|
18
16
|
export function deniedPart(part) {
|
|
19
17
|
if (/^(\.git|node_modules)$/i.test(part))
|
|
20
18
|
return "ignored";
|
|
@@ -53,7 +51,6 @@ export function within(root, path) {
|
|
|
53
51
|
const rel = relative(root, path);
|
|
54
52
|
return rel === "" || (!isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`));
|
|
55
53
|
}
|
|
56
|
-
/** Reject symlinks/junctions at every existing component, including ancestors. */
|
|
57
54
|
export async function checkChain(path, allowMissing = false, signal) {
|
|
58
55
|
checkSignal(signal);
|
|
59
56
|
const absolute = resolve(path);
|
|
@@ -81,13 +78,11 @@ export async function checkChain(path, allowMissing = false, signal) {
|
|
|
81
78
|
throw new Error("Real path changed");
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
|
-
/** Deterministic JSON tuple hash for manifests */
|
|
85
81
|
export function computeManifestHash(files) {
|
|
86
82
|
const sorted = [...files].sort((a, b) => a.path.localeCompare(b.path));
|
|
87
83
|
const tuples = sorted.map((f) => [f.path, f.size, f.sha256]);
|
|
88
84
|
return hash(JSON.stringify(tuples));
|
|
89
85
|
}
|
|
90
|
-
/** Atomic metadata-preserving save for bytes, shared between file-sync and transfer-stream. */
|
|
91
86
|
export async function saveBytesPreservingMetadata({ path, bytes, baseline, signal, }) {
|
|
92
87
|
checkSignal(signal);
|
|
93
88
|
if (!["linux", "darwin", "freebsd", "win32"].includes(process.platform))
|
|
@@ -17,10 +17,6 @@ export const DEVICE_FILE_SYNC_LIMITS = Object.freeze({
|
|
|
17
17
|
});
|
|
18
18
|
import { hash, missing, same, identity, checkSignal, deniedPart, safePath, within, checkChain, } from "./file-sync-paths.js";
|
|
19
19
|
const run = promisify(execFile);
|
|
20
|
-
/** Local capability: root never comes from an incoming bundle. No execution,
|
|
21
|
-
* deletion or implicit directory traversal (recursive export is opt-in). Staged transfers are process-local;
|
|
22
|
-
* close/cancel remove only this instance's private transfer directories. Node
|
|
23
|
-
* path checks cannot exclude a hostile OS user racing filesystem operations. */
|
|
24
20
|
export function createDeviceFileSync(config) {
|
|
25
21
|
const effectiveLimits = { ...DEVICE_FILE_SYNC_LIMITS, ...config.limits };
|
|
26
22
|
const root = resolve(config.root);
|
|
@@ -94,7 +90,6 @@ export function createDeviceFileSync(config) {
|
|
|
94
90
|
active(signal);
|
|
95
91
|
if (!opened.isFile() || identity(opened) !== identity(before))
|
|
96
92
|
throw new Error("File changed while opening");
|
|
97
|
-
// Fixed buffer prevents unbounded allocation if a local writer grows it.
|
|
98
93
|
const buffer = Buffer.alloc(before.size + 1);
|
|
99
94
|
let count = 0;
|
|
100
95
|
while (count < buffer.length) {
|
|
@@ -234,8 +229,6 @@ export function createDeviceFileSync(config) {
|
|
|
234
229
|
throw error;
|
|
235
230
|
}
|
|
236
231
|
}
|
|
237
|
-
/** Same metadata/atomic-replacement policy as file-save.ts, extended to bytes.
|
|
238
|
-
* No direct-write fallback; metadata preservation failure rejects this file. */
|
|
239
232
|
async function overwrite(path, bytes, baseline, signal) {
|
|
240
233
|
if (!["linux", "darwin", "freebsd", "win32"].includes(process.platform))
|
|
241
234
|
throw new Error("Metadata-preserving saves unsupported on this platform");
|
|
@@ -271,7 +264,6 @@ export function createDeviceFileSync(config) {
|
|
|
271
264
|
await checkChain(dir);
|
|
272
265
|
if (process.platform === "win32") {
|
|
273
266
|
const script = "$ErrorActionPreference='Stop'; try { [IO.File]::Replace($env:PI_SAVE_SOURCE,$env:PI_SAVE_TARGET,$env:PI_SAVE_BACKUP,$false) } catch { [Console]::Error.WriteLine($_.Exception.ToString()); exit 1 }";
|
|
274
|
-
// Once committing, do not interrupt ReplaceFile: its completion must be known.
|
|
275
267
|
await run("powershell.exe", [
|
|
276
268
|
"-NoLogo",
|
|
277
269
|
"-NoProfile",
|
|
@@ -375,7 +367,6 @@ export function createDeviceFileSync(config) {
|
|
|
375
367
|
if (!entry)
|
|
376
368
|
break;
|
|
377
369
|
countVisit();
|
|
378
|
-
// Reject links even when their names would otherwise be excluded.
|
|
379
370
|
if (entry.isSymbolicLink())
|
|
380
371
|
throw new Error("Symlink paths are denied");
|
|
381
372
|
names.push(entry.name);
|
|
@@ -540,7 +531,6 @@ export function createDeviceFileSync(config) {
|
|
|
540
531
|
report.rejected.push({ path: file.path, reason });
|
|
541
532
|
}
|
|
542
533
|
}
|
|
543
|
-
// Keep rejected transfers available for a deliberate new preview/retry.
|
|
544
534
|
if (!report.rejected.length) {
|
|
545
535
|
try {
|
|
546
536
|
await drop(id);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// Serialize explicitly so object insertion order cannot change equality. Array order is significant.
|
|
2
1
|
function chunkKey(message) {
|
|
3
2
|
return JSON.stringify([
|
|
4
3
|
message.id,
|
|
@@ -13,13 +12,6 @@ function chunkKey(message) {
|
|
|
13
12
|
message.targetBotIds,
|
|
14
13
|
]);
|
|
15
14
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Previous must aggregate ONLY exact chunks still present in the active model context, with
|
|
18
|
-
* the newest delivered throughMessageId. A persisted transcript or last planned snapshot
|
|
19
|
-
* cannot establish that evidence, especially after compaction. Omit previous when uncertain.
|
|
20
|
-
* This filters history only: callers must always retain the complete current task text.
|
|
21
|
-
* A snapshot remains bounded by current.truncated/retentionLimit; it never claims full history.
|
|
22
|
-
*/
|
|
23
15
|
export function planGroupContext(current, previous) {
|
|
24
16
|
if (!previous || previous.roomId !== current.roomId) {
|
|
25
17
|
return { ...current, delivery: { mode: "snapshot" } };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { planGroupContext } from "./group-context-delta.js";
|
|
2
2
|
export const GROUP_CONTEXT_CUSTOM_TYPE = "device-group-context";
|
|
3
|
-
/** Pure measurement of a planner result; does not change coverage or drop rows. */
|
|
4
3
|
export function extractGroupContextMetrics(current, delivered, payload, mode, requestOnly = false) {
|
|
5
4
|
const sourceBytes = current.messages.reduce((bytes, row) => bytes + Buffer.byteLength(row.text, "utf8"), 0);
|
|
6
5
|
const deliveredBytes = delivered.reduce((bytes, row) => bytes + Buffer.byteLength(row.text, "utf8"), 0);
|
|
@@ -23,10 +22,8 @@ export function extractGroupContextMetrics(current, delivered, payload, mode, re
|
|
|
23
22
|
const METRIC_SESSION_LIMIT = 50;
|
|
24
23
|
const METRIC_SAMPLE_LIMIT = 100;
|
|
25
24
|
const metricSessions = new Map();
|
|
26
|
-
/** Process-local bounded diagnostics only; never used as delivery evidence. */
|
|
27
25
|
export function recordGroupContextMetrics(sessionId, metrics) {
|
|
28
26
|
const samples = metricSessions.get(sessionId) ?? [];
|
|
29
|
-
// Explicit scalar projection prevents extra caller properties retaining content/credentials.
|
|
30
27
|
samples.push({
|
|
31
28
|
version: 1,
|
|
32
29
|
sourceMessages: metrics.sourceMessages,
|
|
@@ -48,7 +45,6 @@ export function recordGroupContextMetrics(sessionId, metrics) {
|
|
|
48
45
|
if (metricSessions.size > METRIC_SESSION_LIMIT)
|
|
49
46
|
metricSessions.delete(metricSessions.keys().next().value);
|
|
50
47
|
}
|
|
51
|
-
/** Detached chronological snapshot; old sessions/samples may have been evicted. */
|
|
52
48
|
export function getGroupContextMetrics(sessionId) {
|
|
53
49
|
return {
|
|
54
50
|
version: 1,
|
|
@@ -57,7 +53,6 @@ export function getGroupContextMetrics(sessionId) {
|
|
|
57
53
|
sampleCount: metricSessions.get(sessionId)?.length ?? 0,
|
|
58
54
|
durableDeliveries: (metricSessions.get(sessionId) ?? []).filter((sample) => !sample.requestOnly).length,
|
|
59
55
|
requests: (metricSessions.get(sessionId) ?? []).filter((sample) => sample.requestOnly).length,
|
|
60
|
-
// Inspection stays small enough for tool receipts; counters cover the retained 100 samples.
|
|
61
56
|
lastSample: metricSessions.get(sessionId)?.at(-1) ? { ...metricSessions.get(sessionId).at(-1) } : null,
|
|
62
57
|
samples: (metricSessions.get(sessionId) ?? []).slice(-10).map((sample) => ({ ...sample })),
|
|
63
58
|
};
|
|
@@ -108,8 +103,6 @@ function taskContext(value) {
|
|
|
108
103
|
value.messages.every(historyMessage));
|
|
109
104
|
}
|
|
110
105
|
function parseContext(content) {
|
|
111
|
-
// Custom messages can store either a string or text blocks. Images and other blocks
|
|
112
|
-
// cannot establish exact JSON delivery evidence; details never reach the model.
|
|
113
106
|
if (Array.isArray(content)) {
|
|
114
107
|
if (!content.every((block) => record(block) && block.type === "text" && typeof block.text === "string"))
|
|
115
108
|
return undefined;
|
|
@@ -145,7 +138,6 @@ function coverage(current, messages, botId, request = false) {
|
|
|
145
138
|
for (const message of messages) {
|
|
146
139
|
if (!record(message) || message.role !== "custom" || message.customType !== GROUP_CONTEXT_CUSTOM_TYPE)
|
|
147
140
|
continue;
|
|
148
|
-
// Request repairs are never durable delivery evidence.
|
|
149
141
|
if (!request && record(message.details) && message.details.requestOnly === true)
|
|
150
142
|
continue;
|
|
151
143
|
if (botId !== undefined &&
|
|
@@ -156,8 +148,6 @@ function coverage(current, messages, botId, request = false) {
|
|
|
156
148
|
continue;
|
|
157
149
|
if (metadata(context) === metadata(current))
|
|
158
150
|
metadataPresent = true;
|
|
159
|
-
// Keep at most the current window's exact chunks, rather than accumulating the
|
|
160
|
-
// full session history. Let the planner define chunk equality in one place.
|
|
161
151
|
const candidates = context.messages.filter((row) => currentIds.has(row.id));
|
|
162
152
|
const missing = new Set(planGroupContext(current, { ...context, throughMessageId: null, messages: candidates }).messages);
|
|
163
153
|
for (const row of current.messages)
|
|
@@ -167,7 +157,6 @@ function coverage(current, messages, botId, request = false) {
|
|
|
167
157
|
}
|
|
168
158
|
return { previous, metadataPresent };
|
|
169
159
|
}
|
|
170
|
-
/** Only active projected custom-message content establishes durable delivery coverage. */
|
|
171
160
|
export function groupContextMessage(current, messages, botId) {
|
|
172
161
|
const planned = planGroupContext(current, coverage(current, messages, botId).previous);
|
|
173
162
|
const content = JSON.stringify(planned);
|
|
@@ -182,9 +171,6 @@ export function groupContextMessage(current, messages, botId) {
|
|
|
182
171
|
},
|
|
183
172
|
};
|
|
184
173
|
}
|
|
185
|
-
/** Repair the final request after SDK compaction/routing, without altering the transcript.
|
|
186
|
-
* Anchor continuity is irrelevant here: actual exact chunk coverage determines missing rows.
|
|
187
|
-
*/
|
|
188
174
|
export function repairGroupContextRequest(current, messages, botId) {
|
|
189
175
|
const { previous, metadataPresent } = coverage(current, messages, botId, true);
|
|
190
176
|
const missing = planGroupContext(current, previous && { ...previous, throughMessageId: null }).messages;
|
|
@@ -20,8 +20,6 @@ function cursor(roomId, id, end) {
|
|
|
20
20
|
function invalidCursor() {
|
|
21
21
|
throw Object.assign(new Error("History cursor expired or invalid; read the latest page again"), { status: 409 });
|
|
22
22
|
}
|
|
23
|
-
/** Stable message anchors survive appends. Clear/retention makes old anchors fail explicitly.
|
|
24
|
-
* Oversized messages are paged in reverse text chunks, without dropping their middle. */
|
|
25
23
|
export function groupHistoryPage(roomId, messages, before, budget = PAGE_BYTES) {
|
|
26
24
|
const rows = messages.filter((message) => message.roomId === roomId);
|
|
27
25
|
let index = rows.length - 1;
|
|
@@ -71,7 +69,6 @@ export function groupHistoryPage(roomId, messages, before, budget = PAGE_BYTES)
|
|
|
71
69
|
}
|
|
72
70
|
if (page.messages.length)
|
|
73
71
|
break;
|
|
74
|
-
// Keep the latest suffix of a large row; subsequent pages return every earlier chunk.
|
|
75
72
|
let low = 0, high = end;
|
|
76
73
|
while (low < high) {
|
|
77
74
|
const mid = Math.floor((low + high) / 2);
|
|
@@ -81,7 +78,6 @@ export function groupHistoryPage(roomId, messages, before, budget = PAGE_BYTES)
|
|
|
81
78
|
low = mid + 1;
|
|
82
79
|
}
|
|
83
80
|
let start = low;
|
|
84
|
-
// Never divide a UTF-16 surrogate pair across chunks.
|
|
85
81
|
if (start > 0 && /[\uDC00-\uDFFF]/.test(row.text[start] ?? ""))
|
|
86
82
|
start++;
|
|
87
83
|
if (start >= end || !fits([project(row, start, end)]))
|
|
@@ -96,13 +92,7 @@ export function groupHistoryPage(roomId, messages, before, budget = PAGE_BYTES)
|
|
|
96
92
|
}
|
|
97
93
|
return page;
|
|
98
94
|
}
|
|
99
|
-
/** Mention tokens look like `@Name` or `@Name(<uuid>)`; the canonical id form wins over a bare name. */
|
|
100
95
|
const MENTION = /@([^\s()@]+)(?:\(([A-Za-z0-9-]{8,})\))?/g;
|
|
101
|
-
/**
|
|
102
|
-
* Resolve human @mentions against current room membership. The Hub owns dispatch semantics: clients may
|
|
103
|
-
* send explicit target ids, but a message that only names Bots in its text must not silently fall back to
|
|
104
|
-
* the primary Bot. Ambiguous names (two members sharing one) are ignored rather than guessed.
|
|
105
|
-
*/
|
|
106
96
|
export function groupMentionTargets(text, room, bots, limit) {
|
|
107
97
|
const members = room.botIds
|
|
108
98
|
.map((id) => ({ id, name: bots.find((bot) => bot.id === id)?.name?.trim() ?? "" }))
|
|
@@ -125,18 +115,13 @@ export function groupMentionTargets(text, room, bots, limit) {
|
|
|
125
115
|
const sorted = hits.sort((a, b) => a.index - b.index).map((hit) => hit.id);
|
|
126
116
|
return limit && limit > 0 ? sorted.slice(0, limit) : sorted;
|
|
127
117
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Compact verbose technical execution errors and internal stack traces to free up valuable context budget.
|
|
130
|
-
*/
|
|
131
118
|
export function compactHistoryNoise(text) {
|
|
132
119
|
if (!text.includes("Device task failed") && !text.includes("Error:") && !text.includes(" at ")) {
|
|
133
120
|
return text;
|
|
134
121
|
}
|
|
135
|
-
// Extract structured summary from Device task failed reports, stripping giant Node/V8 stack traces
|
|
136
122
|
const failMatch = text.match(/Device task failed\s*\[phase=([^;]+);\s*category=([^\]]+)\]\.\s*(.*)/s);
|
|
137
123
|
if (failMatch) {
|
|
138
124
|
const [, phase, category, detail] = failMatch;
|
|
139
|
-
// Keep up to first 300 chars of detail, stripping stack frames
|
|
140
125
|
const cleanDetail = detail
|
|
141
126
|
.split("\n")
|
|
142
127
|
.filter((line) => !line.trim().startsWith("at ") && !line.includes("node:internal"))
|
|
@@ -145,7 +130,6 @@ export function compactHistoryNoise(text) {
|
|
|
145
130
|
.slice(0, 300);
|
|
146
131
|
return `[Device task failed: phase=${phase}, category=${category}] ${cleanDetail || "Remote execution failed."}`;
|
|
147
132
|
}
|
|
148
|
-
// Strip giant stack frames from generic error logs in context
|
|
149
133
|
if (text.includes(" at ")) {
|
|
150
134
|
const lines = text.split("\n");
|
|
151
135
|
const filtered = lines.filter((l) => !l.trim().startsWith("at ") && !l.includes("node:internal"));
|
|
@@ -155,7 +139,6 @@ export function compactHistoryNoise(text) {
|
|
|
155
139
|
}
|
|
156
140
|
return text;
|
|
157
141
|
}
|
|
158
|
-
/** Captured at dispatch, before any parallel recipient can publish a response. */
|
|
159
142
|
export function groupTaskContext(room, bots, messages, budget = GROUP_CONTEXT_BYTES) {
|
|
160
143
|
const members = room.botIds.map((id) => ({ id, name: bots.find((bot) => bot.id === id)?.name ?? id }));
|
|
161
144
|
const metadata = {
|
|
@@ -165,12 +148,10 @@ export function groupTaskContext(room, bots, messages, budget = GROUP_CONTEXT_BY
|
|
|
165
148
|
throughMessageId: messages.filter((message) => message.roomId === room.id).at(-1)?.id ?? null,
|
|
166
149
|
};
|
|
167
150
|
const blackboardPayload = room.blackboard ? { blackboard: room.blackboard } : {};
|
|
168
|
-
// Allocate budget hierarchically: reserve space for metadata and blackboard consensus first.
|
|
169
151
|
const nonHistoryBytes = Buffer.byteLength(JSON.stringify({ ...metadata, ...blackboardPayload })) + 64;
|
|
170
152
|
const historyBudget = Math.max(512, budget - nonHistoryBytes);
|
|
171
153
|
let page = groupHistoryPage(room.id, messages, undefined, historyBudget);
|
|
172
154
|
let result = { ...page, ...metadata, ...blackboardPayload };
|
|
173
|
-
// Ensure absolute compliance with the total budget ceiling even with JSON structure serialization overhead
|
|
174
155
|
while (Buffer.byteLength(JSON.stringify(result)) > budget && page.messages.length > 0) {
|
|
175
156
|
page = { ...page, messages: page.messages.slice(1), truncated: true };
|
|
176
157
|
result = { ...page, ...metadata, ...blackboardPayload };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { projectTaskActivity, validTaskProgress } from "./task-progress.js";
|
|
2
|
-
/** Ephemeral progress, separate from durable task reports. Slow consumers reconnect. */
|
|
3
2
|
export function createGroupEvents(store, journalManager) {
|
|
4
3
|
let closed = false;
|
|
5
4
|
const progress = new Map();
|
|
@@ -89,7 +88,6 @@ export function createGroupEvents(store, journalManager) {
|
|
|
89
88
|
sequence: event.sequence,
|
|
90
89
|
};
|
|
91
90
|
progress.set(task.id, p);
|
|
92
|
-
// Persist progress into durable journal
|
|
93
91
|
if (journalManager && !closed) {
|
|
94
92
|
const appendPromise = journalManager
|
|
95
93
|
.append(task.id, {
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* server/device-center/group-plan-guard.ts
|
|
3
|
-
*
|
|
4
|
-
* 群任务计划模式(Plan Mode)服务端硬门禁与审批状态机。
|
|
5
|
-
*
|
|
6
|
-
* 核心原则:
|
|
7
|
-
* 1. 事实单源:复用 server/plan-mode.ts 的只读白名单判定(readOnlyToolCallAllowed)
|
|
8
|
-
* 与 bash 只读语法校验(bashCommandIsReadOnly / bashCommandHasSupportedSyntax)。
|
|
9
|
-
* 2. 严格闭门门禁(Fail-Closed):除明确白名单中的只读工具外,其余未知工具(含第三方插件)
|
|
10
|
-
* 在计划模式下全部拦截拒绝,绝不默认放行。
|
|
11
|
-
* 3. device_collab 动作细分:只允许只读动作(read_history/context_metrics 等),
|
|
12
|
-
* 写文件(sync_files)、派发与交付等写动作一律硬拦截。
|
|
13
|
-
* 4. 服务端原子校验:计划批准仅允许从 "ready" 转移至 "approved",拒绝 draft 或重复批准。
|
|
14
|
-
*/
|
|
15
1
|
import { validateTaskPlan } from "./task-plan.js";
|
|
16
2
|
import { isConversationTool } from "../conversation-tool-names.js";
|
|
17
3
|
import { readOnlyToolCallAllowed, PLAN_MODE_BLOCKED_TOOL_NAMES, planModeDenial, bashCommandIsReadOnly, bashCommandHasSupportedSyntax, } from "../plan-mode.js";
|
|
18
|
-
/** device_collab 允许在计划模式下调用的安全只读 action 白名单 */
|
|
19
4
|
const DEVICE_COLLAB_READ_ONLY_ACTIONS = new Set([
|
|
20
5
|
"read_history",
|
|
21
6
|
"context_metrics",
|
|
@@ -24,29 +9,19 @@ const DEVICE_COLLAB_READ_ONLY_ACTIONS = new Set([
|
|
|
24
9
|
"current_task",
|
|
25
10
|
"transfer_preview",
|
|
26
11
|
]);
|
|
27
|
-
/** bash 类工具名 */
|
|
28
12
|
const BASH_TOOL_NAMES = new Set(["bash", "terminal_bash", "command"]);
|
|
29
|
-
/**
|
|
30
|
-
* 判断工具在计划模式下的目录注册期是否应被直接隐藏
|
|
31
|
-
*/
|
|
32
13
|
export function isGroupToolForbiddenInPlanCatalog(toolName, isPlanOnly) {
|
|
33
14
|
if (!isPlanOnly)
|
|
34
15
|
return false;
|
|
35
16
|
const name = (toolName || "").trim().toLowerCase();
|
|
36
17
|
return PLAN_MODE_BLOCKED_TOOL_NAMES.has(name) && !isConversationTool(name);
|
|
37
18
|
}
|
|
38
|
-
/**
|
|
39
|
-
* 校验群任务执行时的工具调用是否被计划模式拦截
|
|
40
|
-
* @returns undefined 表示放行;返回 PlanModeDenial 表示被硬门禁拦截
|
|
41
|
-
*/
|
|
42
19
|
export function checkGroupTaskPlanGuard(toolName, params, isPlanOnly) {
|
|
43
20
|
if (!isPlanOnly) {
|
|
44
|
-
return undefined;
|
|
21
|
+
return undefined;
|
|
45
22
|
}
|
|
46
23
|
const name = (toolName || "").trim().toLowerCase();
|
|
47
|
-
// This is execution authorization; catalog filtering uses its own explicit API.
|
|
48
24
|
params ??= {};
|
|
49
|
-
// 1. plan_update 允许用于制定和更新计划本身
|
|
50
25
|
if (name === "plan_update") {
|
|
51
26
|
const steps = params && typeof params === "object" ? params.steps : undefined;
|
|
52
27
|
if (!validateTaskPlan({ state: "ready", steps }))
|
|
@@ -57,7 +32,6 @@ export function checkGroupTaskPlanGuard(toolName, params, isPlanOnly) {
|
|
|
57
32
|
};
|
|
58
33
|
return undefined;
|
|
59
34
|
}
|
|
60
|
-
// 2. device_collab 工具动作级细分拦截
|
|
61
35
|
if (name === "device_collab") {
|
|
62
36
|
const p = params && typeof params === "object" ? params : {};
|
|
63
37
|
const action = typeof p.action === "string" ? p.action.trim().toLowerCase() : "";
|
|
@@ -70,7 +44,6 @@ export function checkGroupTaskPlanGuard(toolName, params, isPlanOnly) {
|
|
|
70
44
|
reasonEn: `Group plan mode: device_collab(action="${action || "unknown"}") is prohibited. Only read-only actions are permitted during planning.`,
|
|
71
45
|
};
|
|
72
46
|
}
|
|
73
|
-
// 3. bash / 终端命令只读检查
|
|
74
47
|
if (BASH_TOOL_NAMES.has(name)) {
|
|
75
48
|
const p = params && typeof params === "object" ? params : {};
|
|
76
49
|
const cmd = typeof p.command === "string" ? p.command : typeof p.cmd === "string" ? p.cmd : "";
|
|
@@ -90,26 +63,19 @@ export function checkGroupTaskPlanGuard(toolName, params, isPlanOnly) {
|
|
|
90
63
|
reasonEn: `Group plan mode: command "${cmd.slice(0, 80)}" contains write operations or unsupported syntax. Use read-only commands or record changes in the plan.`,
|
|
91
64
|
};
|
|
92
65
|
}
|
|
93
|
-
// 4. 复用宿主已有的通用计划门禁判定
|
|
94
66
|
const generalDenial = planModeDenial(name, params);
|
|
95
67
|
if (generalDenial) {
|
|
96
68
|
return generalDenial;
|
|
97
69
|
}
|
|
98
|
-
// 5. 严格闭门门禁:白名单判定
|
|
99
70
|
if (readOnlyToolCallAllowed(name, params)) {
|
|
100
71
|
return undefined;
|
|
101
72
|
}
|
|
102
|
-
// 未在白名单中的未知工具(含第三方插件)一律拦截
|
|
103
73
|
return {
|
|
104
74
|
kind: "bypass-tool",
|
|
105
75
|
reason: `群计划模式:工具 "${name}" 未在只读白名单中,已被硬门禁拦截。请使用只读工具进行调研。`,
|
|
106
76
|
reasonEn: `Group plan mode: tool "${name}" is not in the read-only allowlist and has been blocked. Use read-only tools for research.`,
|
|
107
77
|
};
|
|
108
78
|
}
|
|
109
|
-
/**
|
|
110
|
-
* 服务端原子批准群任务计划
|
|
111
|
-
* 只有处于 ready 状态且具有步骤的计划才能被批准;draft 或已 approved 明确拒绝
|
|
112
|
-
*/
|
|
113
79
|
export function atomicApproveGroupPlan(current, approver = "user", now = Date.now()) {
|
|
114
80
|
if (!current) {
|
|
115
81
|
return { ok: false, error: "No plan found to approve" };
|