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,35 +1,12 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// conversation-read-tool.ts — 让 AI(含子代理)读取别的对话
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// 背景:用户在左栏有「运行的对话」(含子代理)与「历史对话」,也常想让 AI
|
|
5
|
-
// 「结合另一个对话的内容回答」。此前 AI 既不知道别的对话的 id,也没有干净的
|
|
6
|
-
// 读取通道(只能用 read/bash 翻转录 jsonl,既难找路径又难解析)。
|
|
7
|
-
//
|
|
8
|
-
// 本工具提供只读双通道:
|
|
9
|
-
// action=list → 运行中对话(本标签页的全部 conversation,含子代理)+
|
|
10
|
-
// 历史会话转录(scope=current 仅当前项目,all 跨全部项目);
|
|
11
|
-
// action=read → 按 id 读运行中对话的实时消息(含未落盘的),或按 path 读
|
|
12
|
-
// 历史转录(只接受会话列表里的路径,任意文件不给读)。
|
|
13
|
-
//
|
|
14
|
-
// 转录文本走 transcriptText/formatTranscript 纯函数(有单测);文件解析走
|
|
15
|
-
// parseTranscriptLines(jsonl 逐行,坏行跳过)。输出按条数 + 字符数双封顶,
|
|
16
|
-
// 长对话分多次 offset 翻页。跨标签页的实时运行读不到——以落盘历史为准,
|
|
17
|
-
// description 里会告诉模型这一点。
|
|
18
|
-
//
|
|
19
|
-
// 文案约定:工具 definition(description/promptSnippet/promptGuidelines)为纯英文;per-call
|
|
20
|
-
// 返回文本按 lang 取 pick(lang, zh, en, key, vars),缺表回落英文内联。
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
1
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
23
2
|
import { Type } from "typebox";
|
|
24
3
|
import { pick } from "./i18n.js";
|
|
25
4
|
import { extractTouches, formatTouchEntry, formatTouchesCompact, toolCallRefsOfContent, unionTouchLists, } from "./conversation-touches.js";
|
|
26
|
-
/** 由 content 块提 toolCalls 字段(additive;格式化输出不受影响,见接口注释)。 */
|
|
27
5
|
function fillToolCalls(target, content) {
|
|
28
6
|
const refs = toolCallRefsOfContent(content);
|
|
29
7
|
if (refs.length > 0)
|
|
30
8
|
target.toolCalls = refs;
|
|
31
9
|
}
|
|
32
|
-
/** AgentMessage → 转录最小结构(角色原样保留,内容不动,格式化延后)。 */
|
|
33
10
|
export function toTranscriptInput(m) {
|
|
34
11
|
const role = m.role;
|
|
35
12
|
const r = typeof role === "string" ? role : "unknown";
|
|
@@ -55,7 +32,6 @@ export function toTranscriptInput(m) {
|
|
|
55
32
|
base.timestamp = anyM.timestamp;
|
|
56
33
|
return base;
|
|
57
34
|
}
|
|
58
|
-
/** 内容块 → 纯文本:text 拼接;图片占位;具名块(toolCall 等)留名;其余占位。 */
|
|
59
35
|
function textOfContent(content) {
|
|
60
36
|
if (typeof content === "string")
|
|
61
37
|
return content;
|
|
@@ -81,7 +57,6 @@ function textOfContent(content) {
|
|
|
81
57
|
}
|
|
82
58
|
return parts.join("\n");
|
|
83
59
|
}
|
|
84
|
-
/** 附件 aside 的短名(details.name/path),非附件返回空。 */
|
|
85
60
|
function attachmentName(details) {
|
|
86
61
|
if (!details || typeof details !== "object")
|
|
87
62
|
return "";
|
|
@@ -92,7 +67,6 @@ function attachmentName(details) {
|
|
|
92
67
|
return d.path.split(/[\\/]/).pop() ?? d.path;
|
|
93
68
|
return "";
|
|
94
69
|
}
|
|
95
|
-
/** 单条转录消息 → 可读文本行(角色标签 + 内容,不截断,截断由 format 统一做)。 */
|
|
96
70
|
export function transcriptText(m) {
|
|
97
71
|
switch (m.role) {
|
|
98
72
|
case "bashExecution":
|
|
@@ -121,13 +95,11 @@ export function transcriptText(m) {
|
|
|
121
95
|
}
|
|
122
96
|
}
|
|
123
97
|
}
|
|
124
|
-
/** 角色标签(列表行里的序号前缀用)。 */
|
|
125
98
|
function roleLabel(m) {
|
|
126
99
|
if (m.role === "toolResult")
|
|
127
100
|
return `tool result${m.toolName ? ` (${m.toolName})` : ""}`;
|
|
128
101
|
return m.role;
|
|
129
102
|
}
|
|
130
|
-
/** 单条消息截断:超出部分标注剩余字符数(调用方一眼知道丢了多少)。 */
|
|
131
103
|
export function truncateCounted(s, cap) {
|
|
132
104
|
if (s.length <= cap)
|
|
133
105
|
return s;
|
|
@@ -136,7 +108,6 @@ export function truncateCounted(s, cap) {
|
|
|
136
108
|
function trunc(s, cap) {
|
|
137
109
|
return truncateCounted(s, cap);
|
|
138
110
|
}
|
|
139
|
-
/** 转录分页格式化:序号形如 [12/135 user],尾部带翻页提示位(调用方拼 header)。 */
|
|
140
111
|
export function formatTranscript(messages, opts) {
|
|
141
112
|
const total = messages.length;
|
|
142
113
|
const offset = Math.max(0, Math.floor(opts?.offset ?? 0));
|
|
@@ -160,10 +131,6 @@ export function formatTranscript(messages, opts) {
|
|
|
160
131
|
text = "";
|
|
161
132
|
return { text, total, from, to, truncated };
|
|
162
133
|
}
|
|
163
|
-
/**
|
|
164
|
-
* 转录 jsonl → 转录消息(message 条目取 message;compaction/branch_summary
|
|
165
|
-
* 取 summary;坏行跳过)。纯函数:文件读取由宿主做,单测直接喂文本。
|
|
166
|
-
*/
|
|
167
134
|
export function parseTranscriptLines(text) {
|
|
168
135
|
const out = [];
|
|
169
136
|
for (const line of text.split("\n")) {
|
|
@@ -204,11 +171,9 @@ export function parseTranscriptLines(text) {
|
|
|
204
171
|
}
|
|
205
172
|
return out;
|
|
206
173
|
}
|
|
207
|
-
/** 大小写不敏感子串(空 query 全匹配)。 */
|
|
208
174
|
function matchesHay(hay, q) {
|
|
209
175
|
return q === "" || hay.toLowerCase().includes(q);
|
|
210
176
|
}
|
|
211
|
-
/** read 选择器(纯函数):view → query → last 的顺序固定,见注释。 */
|
|
212
177
|
export function selectReadMessages(messages, opts) {
|
|
213
178
|
const list = Array.isArray(messages) ? messages : [];
|
|
214
179
|
const view = opts?.view === "full" ? "full" : "chat";
|
|
@@ -217,8 +182,6 @@ export function selectReadMessages(messages, opts) {
|
|
|
217
182
|
let selected = inView;
|
|
218
183
|
let hitIndices = [];
|
|
219
184
|
if (q) {
|
|
220
|
-
// 在 view 内按转录文本搜:hitIndices 只记命中(报数/定位用),
|
|
221
|
-
// selected 是命中 ±1 条上下文展开(去重保序)。
|
|
222
185
|
const hits = [];
|
|
223
186
|
const keep = new Set();
|
|
224
187
|
for (let i = 0; i < inView.length; i++) {
|
|
@@ -236,7 +199,6 @@ export function selectReadMessages(messages, opts) {
|
|
|
236
199
|
const n = Math.min(200, Math.max(1, Math.floor(last)));
|
|
237
200
|
if (selected.length > n) {
|
|
238
201
|
selected = selected.slice(selected.length - n);
|
|
239
|
-
// last 裁掉上下文外层时命中序号跟走(只留仍在选区内的)。
|
|
240
202
|
if (hitIndices.length > 0) {
|
|
241
203
|
const keep = new Set(selected);
|
|
242
204
|
hitIndices = hitIndices.filter((i) => keep.has(inView[i]));
|
|
@@ -245,7 +207,6 @@ export function selectReadMessages(messages, opts) {
|
|
|
245
207
|
}
|
|
246
208
|
return { selected, totalInView: inView.length, hitIndices };
|
|
247
209
|
}
|
|
248
|
-
/** 工具参数里的一句话提示(path/command,单行 ≤80 字符;拿不到就空串)。 */
|
|
249
210
|
function toolHint(args) {
|
|
250
211
|
if (!args || typeof args !== "object")
|
|
251
212
|
return "";
|
|
@@ -259,7 +220,6 @@ function toolHint(args) {
|
|
|
259
220
|
}
|
|
260
221
|
return "";
|
|
261
222
|
}
|
|
262
|
-
/** action=status 的摘要器(纯函数):只读转录,不碰 host。 */
|
|
263
223
|
export function summarizeConversation(messages) {
|
|
264
224
|
const list = Array.isArray(messages) ? messages : [];
|
|
265
225
|
let lastTool;
|
|
@@ -311,7 +271,6 @@ export function summarizeConversation(messages) {
|
|
|
311
271
|
}
|
|
312
272
|
return { lastTool, lastAssistant, waitingQuestion: lastAskIdx >= 0 && lastAskResultIdx < lastAskIdx };
|
|
313
273
|
}
|
|
314
|
-
/** read 的附加说明行:query 命中位置 + chat 视图裁剪说明(纯函数)。 */
|
|
315
274
|
export function readExtraLines(L, query, sel, rawTotal, view) {
|
|
316
275
|
const lines = [];
|
|
317
276
|
const q = query.trim();
|
|
@@ -325,8 +284,6 @@ export function readExtraLines(L, query, sel, rawTotal, view) {
|
|
|
325
284
|
}
|
|
326
285
|
return lines.length > 0 ? `\n${lines.join("\n")}` : "";
|
|
327
286
|
}
|
|
328
|
-
/** 认领行格式化(files/status 共用,纯函数;head 文案各调用方自己 pick)。
|
|
329
|
-
* style: bullets = 独立成行(files 块用);inline = 行内逗分(status 一行用)。 */
|
|
330
287
|
export function formatClaimLines(claims, maxItems = 5, style = "bullets") {
|
|
331
288
|
const list = Array.isArray(claims) ? claims : [];
|
|
332
289
|
const shown = list.slice(0, Math.max(1, Math.floor(maxItems)));
|
|
@@ -348,16 +305,11 @@ export function filterHistory(list, query) {
|
|
|
348
305
|
return list;
|
|
349
306
|
return list.filter((s) => matchesHay(s.path, q) || matchesHay(s.name ?? "", q) || matchesHay(s.firstMessage, q));
|
|
350
307
|
}
|
|
351
|
-
/** 短 id/路径展示(列表行里路径太长只留尾部)。 */
|
|
352
308
|
export function shortPath(p, keep = 48) {
|
|
353
309
|
return p.length <= keep ? p : `…${p.slice(p.length - keep)}`;
|
|
354
310
|
}
|
|
355
|
-
/** action=list 的默认条数:历史默认 15(以前无上限,几百条一次吐完);
|
|
356
|
-
* 运行中默认不限但给上限(并发对话再多也不会撑爆 details 的 64KB)。 */
|
|
357
311
|
export const HISTORY_LIST_DEFAULT = 15;
|
|
358
312
|
export const RUNNING_LIST_CAP = 50;
|
|
359
|
-
/** action=read 单条消息默认截断(约 600 字符,超出标 “… +N chars”;
|
|
360
|
-
* 以前默认 2000,一条 bash 输出就能吃掉整个 maxChars 预算)。 */
|
|
361
313
|
export const READ_PER_MSG_CAP = 600;
|
|
362
314
|
export function makeConversationReadTool(host, lang, extras) {
|
|
363
315
|
const getLang = lang ?? (() => "en");
|
|
@@ -415,7 +367,6 @@ export function makeConversationReadTool(host, lang, extras) {
|
|
|
415
367
|
const cap = typeof p.limit === "number" && Number.isFinite(p.limit)
|
|
416
368
|
? Math.min(200, Math.max(1, Math.floor(p.limit)))
|
|
417
369
|
: undefined;
|
|
418
|
-
// kind 过滤掉的一整节直接不取不展(不为了它多一次 I/O)。
|
|
419
370
|
const running = kind === "history" ? [] : filterRunning(host.listRunningConversations(), query);
|
|
420
371
|
const history = kind === "running" ? [] : filterHistory(await host.listHistorySessions(scope, ctx.cwd), query);
|
|
421
372
|
const shownRunning = running.slice(0, cap ?? RUNNING_LIST_CAP);
|
|
@@ -423,7 +374,6 @@ export function makeConversationReadTool(host, lang, extras) {
|
|
|
423
374
|
const L = getLang();
|
|
424
375
|
const runLines = shownRunning.map((c) => `- ${c.id} · ${c.title} · ${c.isSubagent ? (L === "zh" ? "子代理" : "subagent") : L === "zh" ? "对话" : "chat"}${c.isStreaming ? (L === "zh" ? "(进行中)" : " (streaming)") : ""} · ${c.messageCount} msgs · ${c.cwd}`);
|
|
425
376
|
const histLines = shownHistory.map((s) => `- ${shortPath(s.path)} · ${s.name || s.firstMessage || (L === "zh" ? "(空对话)" : "(empty)")}${s.messageCount ? ` · ${s.messageCount} msgs` : ""}`);
|
|
426
|
-
// 超出 cap 时给计数 + 收窄指引(静默丢弃是大忌:调用方会以为这就是全量)。
|
|
427
377
|
if (running.length > shownRunning.length) {
|
|
428
378
|
runLines.push(pick(L, `… 还有 ${running.length - shownRunning.length} 条运行中(用 query 或 limit 收窄)。`, `… ${running.length - shownRunning.length} more running (narrow with query or limit).`, "convread.list.running.more", { n: running.length - shownRunning.length }));
|
|
429
379
|
}
|
|
@@ -447,8 +397,6 @@ export function makeConversationReadTool(host, lang, extras) {
|
|
|
447
397
|
: kind === "running"
|
|
448
398
|
? `${head}\n${runHead}\n${runLines.join("\n") || empty}`
|
|
449
399
|
: `${head}\n${runHead}\n${runLines.join("\n") || empty}\n${histHead}\n${histLines.join("\n") || empty}`;
|
|
450
|
-
// details 同样有界:只带展示出的条目(历史的 firstMessage 再掐到 160
|
|
451
|
-
// 字符),以前整量 history 进 details 会撑爆 64KB 被整段丢弃。
|
|
452
400
|
return text(`${sections}\n${tail}`, {
|
|
453
401
|
scope,
|
|
454
402
|
kind,
|
|
@@ -548,7 +496,6 @@ export function makeConversationReadTool(host, lang, extras) {
|
|
|
548
496
|
if ((id && path) || (!id && !path)) {
|
|
549
497
|
return text(pick(getLang(), `action=${action} 需要且只需要 id 或 path 其中之一(id 读运行中对话,path 读历史转录)。`, `action=${action} needs exactly one of id or path (id = running conversation, path = history transcript).`, action === "files" ? "convread.files.bad.args" : "convread.status.bad.args"));
|
|
550
498
|
}
|
|
551
|
-
// 取数(错误复用 read 的 not found 文案:同一个“找不到”语义)。
|
|
552
499
|
let title = "";
|
|
553
500
|
let cwd = "";
|
|
554
501
|
let messages = [];
|
|
@@ -574,7 +521,6 @@ export function makeConversationReadTool(host, lang, extras) {
|
|
|
574
521
|
const where = id ? { id } : { path };
|
|
575
522
|
if (action === "files") {
|
|
576
523
|
const fq = (typeof p.query === "string" ? p.query : "").trim().toLowerCase();
|
|
577
|
-
// sidecar(压缩前的触碰)∪ 实时转录:union 语义,见 unionTouchLists。
|
|
578
524
|
const all = unionTouchLists(host.readTouchSidecar?.(id, path) ?? [], extractTouches(messages));
|
|
579
525
|
const filtered = fq ? all.filter((t) => t.path.toLowerCase().includes(fq)) : all;
|
|
580
526
|
const listedClaims = (() => {
|
|
@@ -612,7 +558,6 @@ export function makeConversationReadTool(host, lang, extras) {
|
|
|
612
558
|
claims: listedClaims.map((c) => ({ path: c.path, ownerTitle: c.ownerTitle })),
|
|
613
559
|
});
|
|
614
560
|
}
|
|
615
|
-
// action === "status":一两行摘要,读全文前的低成本侦察。
|
|
616
561
|
const sum = summarizeConversation(messages);
|
|
617
562
|
const touched = unionTouchLists(host.readTouchSidecar?.(id, path) ?? [], extractTouches(messages)).slice(0, 6);
|
|
618
563
|
let statusClaims = [];
|
|
@@ -632,12 +577,9 @@ export function makeConversationReadTool(host, lang, extras) {
|
|
|
632
577
|
const touchLine = touched.length > 0
|
|
633
578
|
? pick(L, `最近动过:${formatTouchesCompact(touched, { maxItems: 5 })}。`, `Recently touched: ${formatTouchesCompact(touched, { maxItems: 5 })}.`, "convread.status.touched", { files: formatTouchesCompact(touched, { maxItems: 5 }) })
|
|
634
579
|
: pick(L, `最近没动过文件。`, `No files touched recently.`, "convread.status.touched.none");
|
|
635
|
-
// 等问卷只能从转录推断(ask_user_question 调了没回);DSH 问卷不走
|
|
636
|
-
// 工具调用,推断不出 —— 文案写“转录显示”,不夸大。
|
|
637
580
|
const waitLine = sum.waitingQuestion
|
|
638
581
|
? `\n${pick(L, `⚠ 转录显示它在等用户回答问卷(先回它,再干别的)。`, `⚠ The transcript shows it waiting for a question answer (answer first).`, "convread.status.waiting")}`
|
|
639
582
|
: "";
|
|
640
|
-
// 认领只在有的时候占一行(没有就不提,省 token)。
|
|
641
583
|
const linesZh = formatClaimLines(statusClaims, 3, "inline").join("、");
|
|
642
584
|
const linesEn = formatClaimLines(statusClaims, 3, "inline").join("; ");
|
|
643
585
|
const claimLine = statusClaims.length > 0
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SUBAGENT_TOOL_NAMES } from "./tool-manager.js";
|
|
2
|
-
/** Both public names share the same execution and permission boundary. */
|
|
3
2
|
export const CONVERSATION_TOOL_NAMES = SUBAGENT_TOOL_NAMES;
|
|
4
3
|
export const READ_ONLY_CONVERSATION_ACTIONS = ["get_result", "list", "templates", "read", "files", "status"];
|
|
5
4
|
export function isReadOnlyConversationAction(action) {
|
|
@@ -1,47 +1,3 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// conversation-touches.ts — 会话「触碰文件集」提取(纯函数,零 node 依赖)
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// 背景:同项目多对话并行时,服务端完全知道「谁碰过哪些文件」(实时消息与落盘
|
|
5
|
-
// 转录里都有工具调用记录),但既没算也没给 AI,导致 AI 只能靠猜冲突。本模块
|
|
6
|
-
// 只实现一次触碰集解析器,三处复用:并行提醒(agent-service.ts)、
|
|
7
|
-
// conversation_read 的 action:"files" 与 action:"status"。
|
|
8
|
-
//
|
|
9
|
-
// 输入形状(两条路都已核实,见下「数据来源」):
|
|
10
|
-
// - 实时路:session.agent.state.messages(SDK AgentMessage),assistant 消息
|
|
11
|
-
// 的 content 里是 {type:"toolCall", id, name, arguments} 块;
|
|
12
|
-
// - 历史路:转录 jsonl 的 message.content,原样保留同一形状(parseTranscript
|
|
13
|
-
// Lines 透传 content)。
|
|
14
|
-
// 注意:textOfContent 只在「渲染文本」里丢了参数(仍渲染 `[tool call: name]`),
|
|
15
|
-
// content 结构里的 arguments 一直都在。所以 toolCalls 字段是 additive 的便捷
|
|
16
|
-
// 访问点(一处解析、多处复用,并行 toolCall 也能表示),不是新数据源;取不到
|
|
17
|
-
// 时回落扫 content,再取不到就给空集 —— 绝不伪造。
|
|
18
|
-
//
|
|
19
|
-
// 提取规则(只算写,不算读 —— 这是准确性的关键):
|
|
20
|
-
// 写工具白名单:edit / write / edit_soft(参数 path;兼容 file_path/filePath
|
|
21
|
-
// 别名)。白名单之外的一切工具调用一律忽略,所以 read/ls/glob/grep 等读操作
|
|
22
|
-
// 天然不算 —— 不需要也不维护「读工具黑名单」。
|
|
23
|
-
// bash 高置信度写入迹象(拿不准就丢,宁可漏报不要假阳性):
|
|
24
|
-
// - 重定向 `>` / `>>` 的目标词(含 `2> file` 这类 fd 前缀;排除 `>&N`、
|
|
25
|
-
// /dev/null、NUL、&N;heredoc `<<`/`<<<` 不算写入);
|
|
26
|
-
// - rm / rmdir / mkdir / touch 的非 flag 参数;
|
|
27
|
-
// - cp / mv 只取最后一个非 flag 参数(目标端;源端是读/被删,不算写)。
|
|
28
|
-
// 解析是轻量分词器(引号/转义感知,`;`/`&&`/`||`/`|`/`&`/`(`/`)` 切分命令
|
|
29
|
-
// 段),不是完整 shell 解析器。
|
|
30
|
-
//
|
|
31
|
-
// 已知局限(如实记录,调用方展示时不要夸大):
|
|
32
|
-
// 1. 压缩(compaction)后旧消息被摘要替代,压缩前的触碰会丢失 —— 触碰集是
|
|
33
|
-
// 「当前可见转录」的下界,不是全集。
|
|
34
|
-
// 2. 相对路径按字面记录(edit 常给绝对路径、bash 常给相对路径),跨会话交集
|
|
35
|
-
// 可能因此漏报;但绝不做后缀模糊匹配(同名不同目录会假阳性,比漏报更糟)。
|
|
36
|
-
// 3. 路径归一化只做:去首尾空白、反斜杠转斜杠、去 `./` 前缀。Windows 大小写
|
|
37
|
-
// 不敏感不做归一。
|
|
38
|
-
// 4. powershell/cmd 风格写入(Set-Content/Out-File/del/copy)、git apply、
|
|
39
|
-
// tee 落盘、xargs/timeout/nice 等包装词之后的子命令 —— 一律不提取
|
|
40
|
-
// (sudo/env/command/time/nohup/doas 这几个常见包装词能跳过)。
|
|
41
|
-
// 5. 引号内的 `>`(如 echo "a > b")不提取;但 `eval`/`sh -c` 套娃串内的重定
|
|
42
|
-
// 向会被当成普通命令解析 —— 置信度下降,属已知噪声源。
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
/** 工具调用的参数键:SDK 用 arguments,兼容 input/args 两种历史写法。 */
|
|
45
1
|
function argsOfBlock(blk) {
|
|
46
2
|
if (typeof blk.arguments !== "undefined")
|
|
47
3
|
return blk.arguments;
|
|
@@ -49,7 +5,6 @@ function argsOfBlock(blk) {
|
|
|
49
5
|
return blk.input;
|
|
50
6
|
return blk.args;
|
|
51
7
|
}
|
|
52
|
-
/** content 块数组里工具调用的 (name, args) 对(非 toolCall 块跳过)。 */
|
|
53
8
|
export function toolCallRefsOfContent(content) {
|
|
54
9
|
if (!Array.isArray(content))
|
|
55
10
|
return [];
|
|
@@ -68,7 +23,6 @@ export function toolCallRefsOfContent(content) {
|
|
|
68
23
|
}
|
|
69
24
|
return out;
|
|
70
25
|
}
|
|
71
|
-
/** 一条消息的全部工具调用:优先已解析的 toolCalls 字段,回落扫 content。 */
|
|
72
26
|
export function toolCallsOf(m) {
|
|
73
27
|
if (!m || typeof m !== "object")
|
|
74
28
|
return [];
|
|
@@ -77,7 +31,6 @@ export function toolCallsOf(m) {
|
|
|
77
31
|
}
|
|
78
32
|
return toolCallRefsOfContent(m.content);
|
|
79
33
|
}
|
|
80
|
-
/** 写工具白名单:只有这些工具的目标路径才算「写」。 */
|
|
81
34
|
const WRITE_TOOL_NAMES = new Set(["edit", "write", "edit_soft"]);
|
|
82
35
|
function pathOfWriteArgs(args) {
|
|
83
36
|
if (!args || typeof args !== "object")
|
|
@@ -90,14 +43,12 @@ function pathOfWriteArgs(args) {
|
|
|
90
43
|
}
|
|
91
44
|
return undefined;
|
|
92
45
|
}
|
|
93
|
-
/** 路径轻归一(见文件头局限 3):只做无损、低风险的规范化。 */
|
|
94
46
|
export function normalizeTouchPath(p) {
|
|
95
47
|
let s = p.trim().replace(/\\/g, "/");
|
|
96
48
|
while (s.startsWith("./"))
|
|
97
49
|
s = s.slice(2);
|
|
98
50
|
return s;
|
|
99
51
|
}
|
|
100
|
-
/** patch 补丁文本 → 目标路径集合(段头 [path#TAG]/[path] + MV 目标)。 */
|
|
101
52
|
export function patchWriteTargets(patchText) {
|
|
102
53
|
const out = [];
|
|
103
54
|
for (const m of patchText.matchAll(/^\s*\[([^#\]\r\n]+)(?:#[0-9A-Fa-f]{4})?\]\s*$/gm)) {
|
|
@@ -107,10 +58,6 @@ export function patchWriteTargets(patchText) {
|
|
|
107
58
|
out.push(m[1]);
|
|
108
59
|
return out;
|
|
109
60
|
}
|
|
110
|
-
// ---------------------------------------------------------------------------
|
|
111
|
-
// bash 命令解析(高置信度写入迹象,见文件头规则)
|
|
112
|
-
// ---------------------------------------------------------------------------
|
|
113
|
-
/** shell 分词:引号/反斜杠转义感知,引号剥掉(`echo "a > b"` 的 > 不会误报)。 */
|
|
114
61
|
function tokenizeShell(cmd) {
|
|
115
62
|
const toks = [];
|
|
116
63
|
let cur = "";
|
|
@@ -152,7 +99,6 @@ function tokenizeShell(cmd) {
|
|
|
152
99
|
i++;
|
|
153
100
|
continue;
|
|
154
101
|
}
|
|
155
|
-
// 多字符操作符先行:>>、<<、&&、||、2>、1>> 等。
|
|
156
102
|
const three = cmd.slice(i, i + 3);
|
|
157
103
|
const two = cmd.slice(i, i + 2);
|
|
158
104
|
if (/^\d>>/.test(three) || three === "<<<") {
|
|
@@ -180,12 +126,9 @@ function tokenizeShell(cmd) {
|
|
|
180
126
|
return toks;
|
|
181
127
|
}
|
|
182
128
|
const SEGMENT_SEPS = new Set([";", "&&", "||", "|", "&", "(", ")"]);
|
|
183
|
-
/** 命令段首可跳过的包装词(之后仍是命令位置)。 */
|
|
184
129
|
const WRAPPER_WORDS = new Set(["sudo", "env", "command", "time", "nohup", "doas"]);
|
|
185
130
|
const MULTI_TARGET_WRITES = new Set(["rm", "rmdir", "mkdir", "touch"]);
|
|
186
|
-
/** 只算目标端(最后一个非 flag 参数)的命令。 */
|
|
187
131
|
const DEST_ONLY_WRITES = new Set(["cp", "mv"]);
|
|
188
|
-
/** 重定向目标黑名单:不是文件。 */
|
|
189
132
|
function isNonFileTarget(t) {
|
|
190
133
|
if (t === "/dev/null" || t.toLowerCase() === "nul")
|
|
191
134
|
return true;
|
|
@@ -195,13 +138,11 @@ function isNonFileTarget(t) {
|
|
|
195
138
|
return true;
|
|
196
139
|
return false;
|
|
197
140
|
}
|
|
198
|
-
/** bash 命令 → 高置信度写入路径(去重前,调用方计数)。 */
|
|
199
141
|
export function bashWriteTargets(command) {
|
|
200
142
|
if (typeof command !== "string" || !command.trim())
|
|
201
143
|
return [];
|
|
202
144
|
const toks = tokenizeShell(command);
|
|
203
145
|
const out = [];
|
|
204
|
-
// 命令段内状态:cmd = 当前命令词(null = 还在找命令词),args = 该段非 flag 参数。
|
|
205
146
|
let cmd = null;
|
|
206
147
|
let pendingMulti = [];
|
|
207
148
|
let pendingDest = null;
|
|
@@ -226,8 +167,6 @@ export function bashWriteTargets(command) {
|
|
|
226
167
|
afterDoubleDash = false;
|
|
227
168
|
continue;
|
|
228
169
|
}
|
|
229
|
-
// 重定向:`[fd]>[>] 目标`;heredoc 一律跳过。分隔符不能当目标吃掉
|
|
230
|
-
// (`echo a > ; rm x` 里 `;` 必须保留,否则后半段命令会错位)。
|
|
231
170
|
if (/^(\d*)(>>?)$/.test(t) || t === "<<" || t === "<<<" || /^(\d*)<<<?$/.test(t)) {
|
|
232
171
|
const next = toks[i + 1];
|
|
233
172
|
if (typeof next !== "undefined" && !SEGMENT_SEPS.has(next)) {
|
|
@@ -245,25 +184,24 @@ export function bashWriteTargets(command) {
|
|
|
245
184
|
if (WRAPPER_WORDS.has(t))
|
|
246
185
|
continue;
|
|
247
186
|
if (t.includes("=") && !t.startsWith("-"))
|
|
248
|
-
continue;
|
|
187
|
+
continue;
|
|
249
188
|
cmd = t;
|
|
250
189
|
if (cmd === "xargs")
|
|
251
|
-
cmd = "\0xargs-opaque";
|
|
190
|
+
cmd = "\0xargs-opaque";
|
|
252
191
|
continue;
|
|
253
192
|
}
|
|
254
193
|
if (cmd === "\0xargs-opaque")
|
|
255
194
|
continue;
|
|
256
195
|
if (!afterDoubleDash && t.startsWith("-") && t.length > 1)
|
|
257
|
-
continue;
|
|
196
|
+
continue;
|
|
258
197
|
if (MULTI_TARGET_WRITES.has(cmd))
|
|
259
198
|
pendingMulti.push(t);
|
|
260
199
|
else if (DEST_ONLY_WRITES.has(cmd))
|
|
261
|
-
pendingDest = t;
|
|
200
|
+
pendingDest = t;
|
|
262
201
|
}
|
|
263
202
|
flush();
|
|
264
203
|
return out.filter((p) => p !== "" && !isNonFileTarget(p));
|
|
265
204
|
}
|
|
266
|
-
/** 转录消息 → 触碰文件集(按次数降序,次数相同按最后时间降序)。 */
|
|
267
205
|
export function extractTouches(messages, opts) {
|
|
268
206
|
if (!Array.isArray(messages) || messages.length === 0)
|
|
269
207
|
return [];
|
|
@@ -291,7 +229,6 @@ export function extractTouches(messages, opts) {
|
|
|
291
229
|
for (const call of toolCallsOf(m)) {
|
|
292
230
|
const name = call.name;
|
|
293
231
|
if (name === "patch") {
|
|
294
|
-
// patch 的目标路径在补丁文本里(无 args.path),按段头/MV 提取
|
|
295
232
|
const args = call.args;
|
|
296
233
|
if (args && typeof args.patch === "string") {
|
|
297
234
|
for (const p of patchWriteTargets(args.patch))
|
|
@@ -313,7 +250,6 @@ export function extractTouches(messages, opts) {
|
|
|
313
250
|
}
|
|
314
251
|
}
|
|
315
252
|
}
|
|
316
|
-
// `!` 命令 / bashExecution 转录消息:命令在顶层 command 字段。
|
|
317
253
|
if (m.role === "bashExecution" && typeof m.command === "string") {
|
|
318
254
|
for (const p of bashWriteTargets(m.command))
|
|
319
255
|
bump(p, ts);
|
|
@@ -323,9 +259,6 @@ export function extractTouches(messages, opts) {
|
|
|
323
259
|
.map(([path, e]) => ({ path, count: e.count, lastTs: e.lastTs }))
|
|
324
260
|
.sort((a, b) => b.count - a.count || b.lastTs - a.lastTs);
|
|
325
261
|
}
|
|
326
|
-
/** 两个触碰集求并(sidecar 合并用):sidecar 是历史快照、live 是当前全量,
|
|
327
|
-
* 两者消息集重叠,所以 count 取大不相加 —— 相加会把同一批触碰算两遍。
|
|
328
|
-
* 压缩后次数只能保证是下界(presence 与 lastTs 精确,交集计算不受影响)。 */
|
|
329
262
|
export function unionTouchLists(a, b) {
|
|
330
263
|
const acc = new Map();
|
|
331
264
|
for (const f of [...(Array.isArray(a) ? a : []), ...(Array.isArray(b) ? b : [])]) {
|
|
@@ -348,22 +281,18 @@ export function unionTouchLists(a, b) {
|
|
|
348
281
|
.map(([path, e]) => ({ path, count: e.count, lastTs: e.lastTs }))
|
|
349
282
|
.sort((x, y) => y.count - x.count || y.lastTs - x.lastTs);
|
|
350
283
|
}
|
|
351
|
-
/** 两个触碰集的交集:取 a 中同时出现在 b 里的条目(计数/时间沿用 a 的)。 */
|
|
352
284
|
export function intersectTouches(a, b) {
|
|
353
285
|
if (!Array.isArray(a) || !Array.isArray(b) || a.length === 0 || b.length === 0)
|
|
354
286
|
return [];
|
|
355
287
|
const inB = new Set(b.map((f) => f.path));
|
|
356
288
|
return a.filter((f) => inB.has(f.path));
|
|
357
289
|
}
|
|
358
|
-
/** 单条触碰格式化(供提醒用):条目超长时优先保路径完整 —— 路径永不截断
|
|
359
|
-
* (半截路径不可用,还可能误导 AI 去碰错文件),只丢 `×N` 后缀。 */
|
|
360
290
|
export function formatTouchEntry(f, perItemCap = 60) {
|
|
361
291
|
const full = f.count > 1 ? `${f.path} ×${f.count}` : f.path;
|
|
362
292
|
if (full.length <= perItemCap)
|
|
363
293
|
return full;
|
|
364
294
|
return f.path;
|
|
365
295
|
}
|
|
366
|
-
/** 触碰集紧凑格式化:前 N 条完整路径 + `… (+K)` 计数(静默丢弃是大忌)。 */
|
|
367
296
|
export function formatTouchesCompact(files, opts) {
|
|
368
297
|
if (!Array.isArray(files) || files.length === 0)
|
|
369
298
|
return "";
|