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
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { promises as fsPromises } from "node:fs";
|
|
2
|
+
import { setImmediate } from "node:timers/promises";
|
|
3
|
+
import { NATIVE_CLI_ENTRY, parseNativeCliMetadata } from "./native-cli.js";
|
|
4
|
+
const CHUNK_BYTES = 64 * 1024;
|
|
5
|
+
const FAST_PATH_MIN_BYTES = 512;
|
|
6
|
+
const HEAD_SIG_BYTES = 128;
|
|
7
|
+
const TAIL_SIG_BYTES = 64;
|
|
8
|
+
const STRIP_DATA_MIN_CHARS = 64 * 1024;
|
|
9
|
+
const DATA_VALUE_RE = /"data"\s*:\s*"(?:[^"\\]|\\.)*"/g;
|
|
10
|
+
const COLON = 0x3a;
|
|
11
|
+
const TIMESTAMP_KEY = Buffer.from('"timestamp"');
|
|
12
|
+
const SESSION_INFO_KEY = Buffer.from('"session_info"');
|
|
13
|
+
const NATIVE_CLI_KEY = Buffer.from(NATIVE_CLI_ENTRY);
|
|
14
|
+
const MESSAGE_TYPE_RE = /"type"\s*:\s*"message"/;
|
|
15
|
+
function isWs(b) {
|
|
16
|
+
return b === 0x20 || b === 0x09 || b === 0x0d || b === 0x0a;
|
|
17
|
+
}
|
|
18
|
+
function firstNumericTimestamp(line) {
|
|
19
|
+
let from = 0;
|
|
20
|
+
for (;;) {
|
|
21
|
+
const k = line.indexOf(TIMESTAMP_KEY, from);
|
|
22
|
+
if (k < 0)
|
|
23
|
+
return null;
|
|
24
|
+
let i = k + TIMESTAMP_KEY.length;
|
|
25
|
+
while (i < line.length && isWs(line[i]))
|
|
26
|
+
i++;
|
|
27
|
+
if (line[i] === COLON) {
|
|
28
|
+
i++;
|
|
29
|
+
while (i < line.length && isWs(line[i]))
|
|
30
|
+
i++;
|
|
31
|
+
let j = i;
|
|
32
|
+
while (j < line.length && j - i < 16 && line[j] >= 0x30 && line[j] <= 0x39)
|
|
33
|
+
j++;
|
|
34
|
+
if (j - i >= 10)
|
|
35
|
+
return Number(line.toString("latin1", i, j));
|
|
36
|
+
}
|
|
37
|
+
from = k + 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function messageText(msg) {
|
|
41
|
+
if (typeof msg.content === "string")
|
|
42
|
+
return msg.content;
|
|
43
|
+
let text = "";
|
|
44
|
+
if (Array.isArray(msg.content)) {
|
|
45
|
+
for (const part of msg.content) {
|
|
46
|
+
if (part && typeof part.text === "string")
|
|
47
|
+
text += (text ? " " : "") + part.text;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return text;
|
|
51
|
+
}
|
|
52
|
+
function isBlank(line) {
|
|
53
|
+
for (let i = 0; i < line.length; i++)
|
|
54
|
+
if (!isWs(line[i]))
|
|
55
|
+
return false;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
function applyLine(line, st) {
|
|
59
|
+
if (line.length === 0 || isBlank(line))
|
|
60
|
+
return;
|
|
61
|
+
if (st.id &&
|
|
62
|
+
st.firstMessage &&
|
|
63
|
+
line.length > FAST_PATH_MIN_BYTES &&
|
|
64
|
+
line.indexOf(SESSION_INFO_KEY) < 0 &&
|
|
65
|
+
line.indexOf(NATIVE_CLI_KEY) < 0) {
|
|
66
|
+
const head = line.toString("utf8", 0, 140);
|
|
67
|
+
if (MESSAGE_TYPE_RE.test(head)) {
|
|
68
|
+
st.messageCount++;
|
|
69
|
+
const ts = firstNumericTimestamp(line);
|
|
70
|
+
if (ts !== null && ts > st.lastActivityTime)
|
|
71
|
+
st.lastActivityTime = ts;
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
let text = line.toString("utf8");
|
|
76
|
+
if (text.length > STRIP_DATA_MIN_CHARS)
|
|
77
|
+
text = text.replace(DATA_VALUE_RE, '"data":""');
|
|
78
|
+
let rec;
|
|
79
|
+
try {
|
|
80
|
+
rec = JSON.parse(text);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!rec || typeof rec !== "object")
|
|
86
|
+
return;
|
|
87
|
+
if (rec.type === "session") {
|
|
88
|
+
st.id = typeof rec.id === "string" ? rec.id : "";
|
|
89
|
+
st.cwd = typeof rec.cwd === "string" ? rec.cwd : "";
|
|
90
|
+
if (typeof rec.timestamp === "string")
|
|
91
|
+
st.headerTime = new Date(rec.timestamp).getTime();
|
|
92
|
+
if (typeof rec.parentSession === "string")
|
|
93
|
+
st.parentSessionPath = rec.parentSession;
|
|
94
|
+
}
|
|
95
|
+
else if (rec.type === "session_info") {
|
|
96
|
+
if (typeof rec.name === "string" && rec.name.trim())
|
|
97
|
+
st.name = rec.name.trim();
|
|
98
|
+
}
|
|
99
|
+
else if (rec.type === "custom" && rec.customType === NATIVE_CLI_ENTRY) {
|
|
100
|
+
try {
|
|
101
|
+
st.nativeCli = parseNativeCliMetadata(rec.data);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
delete st.nativeCli;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (rec.type === "message") {
|
|
108
|
+
st.messageCount++;
|
|
109
|
+
const msg = rec.message;
|
|
110
|
+
if (msg && typeof msg === "object") {
|
|
111
|
+
if (typeof msg.timestamp === "number")
|
|
112
|
+
st.lastActivityTime = Math.max(st.lastActivityTime, msg.timestamp);
|
|
113
|
+
if (!st.firstMessage && msg.role === "user") {
|
|
114
|
+
const t = messageText(msg);
|
|
115
|
+
if (t)
|
|
116
|
+
st.firstMessage = t;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function emptyFields() {
|
|
122
|
+
return { id: "", cwd: "", headerTime: 0, firstMessage: "", messageCount: 0, lastActivityTime: 0 };
|
|
123
|
+
}
|
|
124
|
+
async function readSig(fh, position, length) {
|
|
125
|
+
if (length <= 0 || position < 0)
|
|
126
|
+
return "";
|
|
127
|
+
const buf = Buffer.allocUnsafe(length);
|
|
128
|
+
const { bytesRead } = await fh.read(buf, 0, length, position);
|
|
129
|
+
return buf.toString("base64", 0, bytesRead);
|
|
130
|
+
}
|
|
131
|
+
function toInfo(filePath, fileMtime, f) {
|
|
132
|
+
if (!f.id)
|
|
133
|
+
return null;
|
|
134
|
+
const modified = f.lastActivityTime > 0 ? f.lastActivityTime : f.headerTime > 0 ? f.headerTime : fileMtime;
|
|
135
|
+
return {
|
|
136
|
+
path: filePath,
|
|
137
|
+
id: f.id,
|
|
138
|
+
cwd: f.cwd,
|
|
139
|
+
name: f.name,
|
|
140
|
+
...(f.nativeCli ? { nativeCli: f.nativeCli } : {}),
|
|
141
|
+
parentSessionPath: f.parentSessionPath,
|
|
142
|
+
created: new Date(f.headerTime || fileMtime),
|
|
143
|
+
modified: new Date(modified),
|
|
144
|
+
messageCount: f.messageCount,
|
|
145
|
+
firstMessage: f.firstMessage || (f.nativeCli ? "" : "(no messages)"),
|
|
146
|
+
allMessagesText: "",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export async function scanSessionListInfo(filePath, fileMtime, prev) {
|
|
150
|
+
let fh;
|
|
151
|
+
try {
|
|
152
|
+
fh = await fsPromises.open(filePath, "r");
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const size = (await fh.stat()).size;
|
|
159
|
+
const headSig = await readSig(fh, 0, Math.min(HEAD_SIG_BYTES, size));
|
|
160
|
+
let start = 0;
|
|
161
|
+
let fields = emptyFields();
|
|
162
|
+
if (prev && prev.offset > 0 && prev.offset <= size && prev.headSig === headSig) {
|
|
163
|
+
const tailLen = Math.min(TAIL_SIG_BYTES, prev.offset);
|
|
164
|
+
const tailSig = await readSig(fh, prev.offset - tailLen, tailLen);
|
|
165
|
+
if (tailSig === prev.tailSig) {
|
|
166
|
+
start = prev.offset;
|
|
167
|
+
const { offset: _o, headSig: _h, tailSig: _t, ...rest } = prev;
|
|
168
|
+
fields = { ...rest };
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
let pos = start;
|
|
172
|
+
let committed = start;
|
|
173
|
+
let pending = [];
|
|
174
|
+
for (;;) {
|
|
175
|
+
const buf = Buffer.allocUnsafe(CHUNK_BYTES);
|
|
176
|
+
const { bytesRead } = await fh.read(buf, 0, CHUNK_BYTES, pos);
|
|
177
|
+
if (bytesRead === 0)
|
|
178
|
+
break;
|
|
179
|
+
const view = buf.subarray(0, bytesRead);
|
|
180
|
+
let s = 0;
|
|
181
|
+
let nl;
|
|
182
|
+
while ((nl = view.indexOf(0x0a, s)) !== -1) {
|
|
183
|
+
const piece = view.subarray(s, nl);
|
|
184
|
+
const line = pending.length > 0 ? Buffer.concat([...pending, piece]) : piece;
|
|
185
|
+
pending = [];
|
|
186
|
+
applyLine(line, fields);
|
|
187
|
+
committed = pos + nl + 1;
|
|
188
|
+
s = nl + 1;
|
|
189
|
+
}
|
|
190
|
+
if (s < bytesRead)
|
|
191
|
+
pending.push(view.subarray(s));
|
|
192
|
+
pos += bytesRead;
|
|
193
|
+
await setImmediate();
|
|
194
|
+
}
|
|
195
|
+
const tailLen = Math.min(TAIL_SIG_BYTES, committed);
|
|
196
|
+
const state = {
|
|
197
|
+
...fields,
|
|
198
|
+
offset: committed,
|
|
199
|
+
headSig,
|
|
200
|
+
tailSig: await readSig(fh, committed - tailLen, tailLen),
|
|
201
|
+
};
|
|
202
|
+
let resultFields = fields;
|
|
203
|
+
if (pending.length > 0) {
|
|
204
|
+
resultFields = { ...fields };
|
|
205
|
+
applyLine(Buffer.concat(pending), resultFields);
|
|
206
|
+
}
|
|
207
|
+
return { info: toInfo(filePath, fileMtime, resultFields), state, resumedFrom: start };
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
await fh.close().catch(() => { });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { promises as fsPromises } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { setImmediate } from "node:timers/promises";
|
|
4
|
+
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
const SLICE_MS = 8;
|
|
6
|
+
export async function parseJsonlSliced(raw, sliceMs = SLICE_MS) {
|
|
7
|
+
const entries = [];
|
|
8
|
+
let start = 0;
|
|
9
|
+
let sliceStart = performance.now();
|
|
10
|
+
const take = (line) => {
|
|
11
|
+
if (!line.trim())
|
|
12
|
+
return;
|
|
13
|
+
try {
|
|
14
|
+
const v = JSON.parse(line);
|
|
15
|
+
if (v)
|
|
16
|
+
entries.push(v);
|
|
17
|
+
}
|
|
18
|
+
catch { }
|
|
19
|
+
};
|
|
20
|
+
for (;;) {
|
|
21
|
+
const nl = raw.indexOf("\n", start);
|
|
22
|
+
if (nl === -1)
|
|
23
|
+
break;
|
|
24
|
+
take(raw.slice(start, nl));
|
|
25
|
+
start = nl + 1;
|
|
26
|
+
if (performance.now() - sliceStart >= sliceMs) {
|
|
27
|
+
await setImmediate();
|
|
28
|
+
sliceStart = performance.now();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const tail = raw.slice(start);
|
|
32
|
+
take(tail);
|
|
33
|
+
return { entries, tail };
|
|
34
|
+
}
|
|
35
|
+
export async function openSessionManagerAsync(path) {
|
|
36
|
+
const resolvedPath = resolve(path);
|
|
37
|
+
if (process.env.PI_WEB_ASYNC_SESSION_OPEN === "0")
|
|
38
|
+
return SessionManager.open(resolvedPath);
|
|
39
|
+
let raw;
|
|
40
|
+
try {
|
|
41
|
+
raw = await fsPromises.readFile(resolvedPath, "utf8");
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return SessionManager.open(resolvedPath);
|
|
45
|
+
}
|
|
46
|
+
const { entries, tail } = await parseJsonlSliced(raw);
|
|
47
|
+
const header = entries[0];
|
|
48
|
+
if (!header || header.type !== "session" || typeof header.id !== "string") {
|
|
49
|
+
return SessionManager.open(resolvedPath);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
if (tail)
|
|
53
|
+
await fsPromises.appendFile(resolvedPath, "\n");
|
|
54
|
+
const cwd = typeof header.cwd === "string" ? header.cwd : process.cwd();
|
|
55
|
+
const Ctor = SessionManager;
|
|
56
|
+
const manager = new Ctor(cwd, dirname(resolvedPath), resolvedPath, true, undefined, entries);
|
|
57
|
+
const file = manager.getSessionFile();
|
|
58
|
+
const ok = typeof file === "string" &&
|
|
59
|
+
resolve(file) === resolvedPath &&
|
|
60
|
+
manager.getSessionId() === header.id &&
|
|
61
|
+
manager.getEntries().length === entries.length - 1;
|
|
62
|
+
if (!ok)
|
|
63
|
+
return SessionManager.open(resolvedPath);
|
|
64
|
+
return manager;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return SessionManager.open(resolvedPath);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* session-parser — 会话转录快速轻量解析器与磁盘项目发现。
|
|
3
|
-
*
|
|
4
|
-
* 负责:
|
|
5
|
-
* - parseSessionInfoFast: 快速解析单个会话文件头部和消息,提取元信息,按需截断收集全文
|
|
6
|
-
* - discoverRecentProjectsFromDisk: 遍历会话根目录,按最近修改时间轻量发现使用过的项目路径
|
|
7
|
-
*
|
|
8
|
-
* 从 agent-service.ts 抽出为独立模块。
|
|
9
|
-
*/
|
|
10
1
|
import { existsSync } from "node:fs";
|
|
11
2
|
import { sessionLines } from "./session-scan.js";
|
|
3
|
+
import { scanSessionListInfo } from "./session-list-scan.js";
|
|
12
4
|
import * as fsPromises from "node:fs/promises";
|
|
13
5
|
import { basename, join, resolve } from "node:path";
|
|
14
6
|
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
15
7
|
import { normalizePathKey } from "./client-state.js";
|
|
16
8
|
import { MAX_SEARCH_TEXT_CHARS, readCwdFromSessionHeader, piSessionsRoot } from "./session-search.js";
|
|
17
|
-
/**
|
|
18
|
-
* 快速轻量地从 SDK 会话目录中发现项目路径(仅读取会话文件的第一行头部获取 cwd,
|
|
19
|
-
* 绝不使用 SessionManager.listAll 遍历解析全部会话文本,避免大历史时阻塞数秒到数十秒)。
|
|
20
|
-
*/
|
|
21
9
|
export async function discoverRecentProjectsFromDisk(sessionRoots, limit = 30) {
|
|
22
10
|
const projects = new Map();
|
|
23
11
|
for (const root of sessionRoots) {
|
|
24
12
|
if (projects.size >= limit)
|
|
25
13
|
break;
|
|
26
14
|
try {
|
|
27
|
-
// 异步探测(issue #441):会话根可能在已断连的网络盘上,同步 existsSync 会冻结事件循环。
|
|
28
15
|
try {
|
|
29
16
|
await fsPromises.access(root);
|
|
30
17
|
}
|
|
@@ -32,7 +19,6 @@ export async function discoverRecentProjectsFromDisk(sessionRoots, limit = 30) {
|
|
|
32
19
|
continue;
|
|
33
20
|
}
|
|
34
21
|
const entries = await fsPromises.readdir(root, { withFileTypes: true });
|
|
35
|
-
// 1. 扁平布局(PI_CODING_AGENT_SESSION_DIR):根目录下直接是 .jsonl
|
|
36
22
|
const flatFiles = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl"));
|
|
37
23
|
if (flatFiles.length > 0) {
|
|
38
24
|
const fileStats = await Promise.all(flatFiles.map(async (f) => {
|
|
@@ -54,7 +40,6 @@ export async function discoverRecentProjectsFromDisk(sessionRoots, limit = 30) {
|
|
|
54
40
|
const key = normalizePathKey(cwd);
|
|
55
41
|
if (!projects.has(key)) {
|
|
56
42
|
try {
|
|
57
|
-
// 异步探测(issue #441):cwd 可能在已断连的网络盘上。
|
|
58
43
|
await fsPromises.access(cwd);
|
|
59
44
|
projects.set(key, { path: cwd, lastUsed: s.mtime });
|
|
60
45
|
}
|
|
@@ -63,7 +48,6 @@ export async function discoverRecentProjectsFromDisk(sessionRoots, limit = 30) {
|
|
|
63
48
|
}
|
|
64
49
|
}
|
|
65
50
|
}
|
|
66
|
-
// 2. 默认子目录布局(<agentDir>/sessions/--<cwd>--/):每 cwd 一个子目录
|
|
67
51
|
const subdirs = entries.filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => join(root, e.name));
|
|
68
52
|
if (subdirs.length > 0 && projects.size < limit) {
|
|
69
53
|
const CHUNK = 64;
|
|
@@ -129,7 +113,6 @@ export async function discoverRecentProjectsFromDisk(sessionRoots, limit = 30) {
|
|
|
129
113
|
const key = normalizePathKey(r.path);
|
|
130
114
|
if (!projects.has(key)) {
|
|
131
115
|
try {
|
|
132
|
-
// 异步探测(issue #441):cwd 可能在已断连的网络盘上。
|
|
133
116
|
await fsPromises.access(r.path);
|
|
134
117
|
projects.set(key, r);
|
|
135
118
|
}
|
|
@@ -139,22 +122,13 @@ export async function discoverRecentProjectsFromDisk(sessionRoots, limit = 30) {
|
|
|
139
122
|
}
|
|
140
123
|
}
|
|
141
124
|
}
|
|
142
|
-
catch {
|
|
143
|
-
/* best effort */
|
|
144
|
-
}
|
|
125
|
+
catch { }
|
|
145
126
|
}
|
|
146
127
|
return [...projects.values()].sort((a, b) => b.lastUsed - a.lastUsed);
|
|
147
128
|
}
|
|
148
|
-
/**
|
|
149
|
-
* 快速解析单个会话文件(提取 id/cwd/name/parentSessionPath/firstMessage/messageCount/modified,
|
|
150
|
-
* 以及可选的转录全文 allMessagesText)。仅用于会话列表发现与搜索,避免调用 SDK 重型的全量树解析。
|
|
151
|
-
*
|
|
152
|
-
* withAllMessagesText=false(默认,列表路径)时不收集转录全文,allMessagesText 返回空串 ——
|
|
153
|
-
* 全文单条可达 MB 级,绝不随列表进任何缓存(issue #440);true 仅兼容旧调用,返回
|
|
154
|
-
* MAX_SEARCH_TEXT_CHARS 内的文本预览。全文搜索请使用 scanSessionForSearch,避免截断漏查。
|
|
155
|
-
* 逐行异步读取,内存仅保留当前 JSONL 记录及列表字段。
|
|
156
|
-
*/
|
|
157
129
|
export async function parseSessionInfoFast(filePath, fileMtime, withAllMessagesText = false) {
|
|
130
|
+
if (!withAllMessagesText)
|
|
131
|
+
return (await scanSessionListInfo(filePath, fileMtime))?.info ?? null;
|
|
158
132
|
try {
|
|
159
133
|
let id = "";
|
|
160
134
|
let cwd = "";
|
|
@@ -169,8 +143,6 @@ export async function parseSessionInfoFast(filePath, fileMtime, withAllMessagesT
|
|
|
169
143
|
for await (const line of sessionLines(filePath)) {
|
|
170
144
|
if (!line.trim())
|
|
171
145
|
continue;
|
|
172
|
-
// 列表路径(withAllMessagesText=false)已拿到 id 与首条消息后,跳过对大块长行
|
|
173
|
-
// (如数百 KB 的 toolResult/assistant 消息)的全量 JSON.parse:仅轻量计数并提取时间戳
|
|
174
146
|
if (!withAllMessagesText && id && firstMessage && line.length > 512 && !line.includes('"session_info"')) {
|
|
175
147
|
const head = line.slice(0, 140);
|
|
176
148
|
if (/"type"\s*:\s*"message"/.test(head)) {
|
|
@@ -264,13 +236,6 @@ export async function parseSessionInfoFast(filePath, fileMtime, withAllMessagesT
|
|
|
264
236
|
return null;
|
|
265
237
|
}
|
|
266
238
|
}
|
|
267
|
-
/**
|
|
268
|
-
* 历史会话列表的 fork 父会话过滤:
|
|
269
|
-
* - `showForkedParents === true` 时保留全部会话(父会话与子会话同时显示);
|
|
270
|
-
* - `showForkedParents === false`(默认)时隐藏「已被后续分支派生、且该分支链上存在叶子会话」的父会话,
|
|
271
|
-
* 仅保留每条 fork 链最新的链尾叶子会话;
|
|
272
|
-
* - 若某条链因异常形成纯环(无叶子)或自环,环上节点保留而不整条隐藏。
|
|
273
|
-
*/
|
|
274
239
|
export function filterForkedParentSessions(infos, showForkedParents = false) {
|
|
275
240
|
if (showForkedParents || infos.length <= 1)
|
|
276
241
|
return infos;
|
|
@@ -295,7 +260,6 @@ export function filterForkedParentSessions(infos, showForkedParents = false) {
|
|
|
295
260
|
}
|
|
296
261
|
if (childrenOf.size === 0)
|
|
297
262
|
return infos;
|
|
298
|
-
// 从去重后的边构建反向关系;重复 path 可能让同一节点有多个父节点。
|
|
299
263
|
const parentsOf = new Map();
|
|
300
264
|
for (const [parentKey, children] of childrenOf) {
|
|
301
265
|
for (const childKey of children) {
|
|
@@ -316,7 +280,6 @@ export function filterForkedParentSessions(infos, showForkedParents = false) {
|
|
|
316
280
|
queue.push(key);
|
|
317
281
|
}
|
|
318
282
|
}
|
|
319
|
-
// 每个节点最多入队一次,每条反向边最多访问一次,避免长链反复全图扫描。
|
|
320
283
|
for (let head = 0; head < queue.length; head++) {
|
|
321
284
|
for (const parentKey of parentsOf.get(queue[head]) ?? []) {
|
|
322
285
|
if (canReachLeaf.has(parentKey))
|
|
@@ -334,18 +297,6 @@ export function filterForkedParentSessions(infos, showForkedParents = false) {
|
|
|
334
297
|
});
|
|
335
298
|
return kept.length > 0 ? kept : infos;
|
|
336
299
|
}
|
|
337
|
-
/**
|
|
338
|
-
* 极速定位指定目录下最近修改的单个有效会话文件路径(用于 attach/恢复 判定,毫秒级返回)。
|
|
339
|
-
*
|
|
340
|
-
* 绝不使用 SessionManager.list 递归全量加载解析全部历史消息(大历史会有数百个文件、
|
|
341
|
-
* 几百兆 JSON 反序列化耗时数十秒,严重饿死 Node 事件循环)。
|
|
342
|
-
*
|
|
343
|
-
* 逻辑:
|
|
344
|
-
* 1. 扫描目录下的 .jsonl 文件;
|
|
345
|
-
* 2. 按 mtime 降序排序;
|
|
346
|
-
* 3. 逐个轻量探测(仅读首行 cwd,使用 readCwdFromSessionHeader);
|
|
347
|
-
* 4. 找到首个匹配 targetCwd(若指定)的有效会话文件后立即返回;若未指定 targetCwd 则直接返回最新文件的路径。
|
|
348
|
-
*/
|
|
349
300
|
export async function findMostRecentSessionFileFast(sessionDir, targetCwd) {
|
|
350
301
|
try {
|
|
351
302
|
let targetDir = sessionDir;
|
|
@@ -366,7 +317,6 @@ export async function findMostRecentSessionFileFast(sessionDir, targetCwd) {
|
|
|
366
317
|
}
|
|
367
318
|
}
|
|
368
319
|
else {
|
|
369
|
-
// 如果 targetDir 下没有 .jsonl 文件,可能是工作区根目录(sessionBaseDir),尝试解析物理存储目录
|
|
370
320
|
try {
|
|
371
321
|
const projectDir = SessionManager.create(targetDir).getSessionDir();
|
|
372
322
|
if (existsSync(projectDir)) {
|
|
@@ -1,77 +1,114 @@
|
|
|
1
|
-
/** Shared streaming transcript reader. Memory scales with textual JSONL records,
|
|
2
|
-
* not the file or embedded binary `data` strings. */
|
|
3
1
|
import { createReadStream } from "node:fs";
|
|
4
2
|
import { setImmediate } from "node:timers/promises";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const STRING_SPECIAL = /["\\\n]/g;
|
|
4
|
+
const NON_WS_OR_NL = /[^\s]|\n/g;
|
|
5
|
+
function tokenIsData(token) {
|
|
6
|
+
if (token === "data")
|
|
7
|
+
return true;
|
|
8
|
+
if (token.length < 4 || !token.includes("\\"))
|
|
9
|
+
return false;
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse('"' + token + '"') === "data";
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class BinaryStringFilter {
|
|
9
18
|
inString = false;
|
|
10
19
|
escaped = false;
|
|
11
20
|
token = "";
|
|
12
21
|
dataKey = false;
|
|
13
22
|
awaitingValue = false;
|
|
14
23
|
discard = false;
|
|
24
|
+
addToken(seg) {
|
|
25
|
+
if (this.token.length < 16)
|
|
26
|
+
this.token += seg.slice(0, 16 - this.token.length);
|
|
27
|
+
}
|
|
15
28
|
push(chunk) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.escaped = false;
|
|
21
|
-
this.discard = false;
|
|
22
|
-
}
|
|
29
|
+
const out = [];
|
|
30
|
+
const n = chunk.length;
|
|
31
|
+
let i = 0;
|
|
32
|
+
while (i < n) {
|
|
23
33
|
if (this.inString) {
|
|
24
|
-
if (!this.discard)
|
|
25
|
-
output.push(char);
|
|
26
34
|
if (this.escaped) {
|
|
35
|
+
const ch = chunk[i];
|
|
36
|
+
if (ch === "\n") {
|
|
37
|
+
this.inString = false;
|
|
38
|
+
this.escaped = false;
|
|
39
|
+
this.discard = false;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (!this.discard)
|
|
43
|
+
out.push(ch);
|
|
27
44
|
this.escaped = false;
|
|
28
|
-
|
|
29
|
-
|
|
45
|
+
this.addToken(ch);
|
|
46
|
+
i++;
|
|
47
|
+
continue;
|
|
30
48
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
STRING_SPECIAL.lastIndex = i;
|
|
50
|
+
const m = STRING_SPECIAL.exec(chunk);
|
|
51
|
+
const j = m ? m.index : n;
|
|
52
|
+
if (j > i) {
|
|
53
|
+
const seg = chunk.slice(i, j);
|
|
54
|
+
if (!this.discard)
|
|
55
|
+
out.push(seg);
|
|
56
|
+
this.addToken(seg);
|
|
35
57
|
}
|
|
36
|
-
|
|
58
|
+
if (!m)
|
|
59
|
+
break;
|
|
60
|
+
const ch = chunk[j];
|
|
61
|
+
if (ch === "\n") {
|
|
37
62
|
this.inString = false;
|
|
38
|
-
|
|
39
|
-
output.push(char);
|
|
40
|
-
try {
|
|
41
|
-
this.dataKey = JSON.parse('"' + this.token + '"') === "data";
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
this.dataKey = false;
|
|
45
|
-
}
|
|
63
|
+
this.escaped = false;
|
|
46
64
|
this.discard = false;
|
|
65
|
+
i = j;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (ch === "\\") {
|
|
69
|
+
if (!this.discard)
|
|
70
|
+
out.push(ch);
|
|
71
|
+
this.escaped = true;
|
|
72
|
+
this.addToken(ch);
|
|
73
|
+
i = j + 1;
|
|
74
|
+
continue;
|
|
47
75
|
}
|
|
48
|
-
|
|
49
|
-
|
|
76
|
+
out.push('"');
|
|
77
|
+
this.inString = false;
|
|
78
|
+
this.dataKey = tokenIsData(this.token);
|
|
79
|
+
this.discard = false;
|
|
80
|
+
i = j + 1;
|
|
50
81
|
continue;
|
|
51
82
|
}
|
|
52
|
-
|
|
53
|
-
|
|
83
|
+
NON_WS_OR_NL.lastIndex = i;
|
|
84
|
+
const m = NON_WS_OR_NL.exec(chunk);
|
|
85
|
+
const j = m ? m.index : n;
|
|
86
|
+
if (j > i)
|
|
87
|
+
out.push(chunk.slice(i, j));
|
|
88
|
+
if (!m)
|
|
89
|
+
break;
|
|
90
|
+
const ch = chunk[j];
|
|
91
|
+
out.push(ch);
|
|
92
|
+
if (ch === "\n") {
|
|
93
|
+
this.dataKey = false;
|
|
94
|
+
this.awaitingValue = false;
|
|
95
|
+
}
|
|
96
|
+
else if (ch === '"') {
|
|
54
97
|
this.inString = true;
|
|
55
98
|
this.token = "";
|
|
56
99
|
this.discard = this.awaitingValue;
|
|
57
100
|
this.awaitingValue = false;
|
|
58
101
|
this.dataKey = false;
|
|
59
102
|
}
|
|
60
|
-
else
|
|
61
|
-
this.awaitingValue =
|
|
103
|
+
else {
|
|
104
|
+
this.awaitingValue = ch === ":" && this.dataKey;
|
|
62
105
|
this.dataKey = false;
|
|
63
106
|
}
|
|
64
|
-
|
|
65
|
-
if (char === "\n") {
|
|
66
|
-
this.dataKey = false;
|
|
67
|
-
this.awaitingValue = false;
|
|
68
|
-
}
|
|
107
|
+
i = j + 1;
|
|
69
108
|
}
|
|
70
|
-
return
|
|
109
|
+
return out.join("");
|
|
71
110
|
}
|
|
72
111
|
}
|
|
73
|
-
/** Early return and errors close the file. Non-binary text records are not capped:
|
|
74
|
-
* an exceptionally large single text message still requires one record in memory. */
|
|
75
112
|
export async function* sessionLines(filePath, signal) {
|
|
76
113
|
signal?.throwIfAborted();
|
|
77
114
|
const input = createReadStream(filePath, { encoding: "utf8", highWaterMark: 64 * 1024, signal });
|
|
@@ -109,7 +146,6 @@ export async function* sessionLines(filePath, signal) {
|
|
|
109
146
|
input.destroy();
|
|
110
147
|
}
|
|
111
148
|
}
|
|
112
|
-
/** Bounded worker pool; results retain input order. No implicit list/result limit. */
|
|
113
149
|
export async function mapSessionsConcurrent(items, visit, concurrency = 4, signal) {
|
|
114
150
|
signal?.throwIfAborted();
|
|
115
151
|
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 32) {
|