@rcoding-lab/gateway 0.0.0-stage → 1.5.52
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/LICENSE +661 -0
- package/README.md +126 -2
- package/dist/agent-content-page.js +21 -0
- package/dist/agent-content-persistence.js +177 -0
- package/dist/agent-content-store.js +526 -0
- package/dist/agent-content-value.js +224 -0
- package/dist/agent-runtime-event.js +121 -0
- package/dist/agent-runtime-sanitize.js +110 -0
- package/dist/agent-timeline-migration-worker.js +137 -0
- package/dist/agent-timeline-migration.js +57 -0
- package/dist/agent-timeline-page-storage.js +83 -0
- package/dist/agent-timeline-projector.js +268 -0
- package/dist/agent-timeline-segment-format.js +238 -0
- package/dist/agent-timeline-segment-storage.js +242 -0
- package/dist/agent-timeline-session-service.js +96 -0
- package/dist/agent-timeline-store.js +777 -0
- package/dist/agent-timeline-stream.js +108 -0
- package/dist/antigravity-account-route.js +158 -0
- package/dist/antigravity-account-service.js +467 -0
- package/dist/antigravity-acp-elicitation.js +286 -0
- package/dist/antigravity-acp-output.js +199 -0
- package/dist/antigravity-acp-process.js +134 -0
- package/dist/antigravity-acp-progress.js +89 -0
- package/dist/antigravity-acp-tool.js +127 -0
- package/dist/antigravity-content-archive.js +75 -0
- package/dist/antigravity-runtime-client.js +1244 -0
- package/dist/antigravity-runtime-installer.js +307 -0
- package/dist/antigravity-session-lifecycle.js +395 -0
- package/dist/app-usage-registry.js +104 -0
- package/dist/app-usage-summary.js +224 -0
- package/dist/approval-dedupe.js +88 -0
- package/dist/approval-store.js +159 -0
- package/dist/approval.js +19 -0
- package/dist/assistant-api-client.js +116 -0
- package/dist/assistant-api-errors.js +22 -0
- package/dist/assistant-api-harness.js +234 -0
- package/dist/assistant-api-response.js +103 -0
- package/dist/assistant-api-session-service.js +192 -0
- package/dist/assistant-api-tools.js +136 -0
- package/dist/assistant-search-evidence.js +89 -0
- package/dist/assistant-search-policy.js +30 -0
- package/dist/assistant-session-policy.js +150 -0
- package/dist/assistant-session-runtime.js +90 -0
- package/dist/atomic-json-file.js +19 -0
- package/dist/attachment-upload.js +108 -0
- package/dist/attachment.js +319 -0
- package/dist/auth.js +44 -0
- package/dist/board-device.js +130 -0
- package/dist/board-preferences.js +77 -0
- package/dist/captcha.js +100 -0
- package/dist/channel-plugin-installer.js +271 -0
- package/dist/channel-plugin-ipc.js +299 -0
- package/dist/channel-plugin-manager.js +297 -0
- package/dist/channel-plugin-manifest.js +85 -0
- package/dist/channel-plugin-protocol.js +16 -0
- package/dist/channel-plugin-route.js +203 -0
- package/dist/channel-plugin-state.js +51 -0
- package/dist/channel-plugin-worker.js +277 -0
- package/dist/claude-background-activity.js +100 -0
- package/dist/claude-code-config-service.js +178 -0
- package/dist/claude-code-config.js +168 -0
- package/dist/claude-code-extension-catalog.js +212 -0
- package/dist/claude-code-file-diff.js +131 -0
- package/dist/claude-code-runtime-client.js +1480 -0
- package/dist/claude-code-session-projection.js +163 -0
- package/dist/claude-code-settings-overlay.js +32 -0
- package/dist/claude-code-system-prompt.js +146 -0
- package/dist/claude-code-unified-config.js +98 -0
- package/dist/claude-context-usage.js +129 -0
- package/dist/claude-input-requests.js +82 -0
- package/dist/claude-permission-requests.js +54 -0
- package/dist/claude-runtime-installer.js +270 -0
- package/dist/claude-sdk-timeline-adapter.js +1167 -0
- package/dist/claude-sdk-tool-detail.js +382 -0
- package/dist/claude-session-import.js +369 -0
- package/dist/claude-subagent-stop.js +53 -0
- package/dist/claude-subagent-task-events.js +132 -0
- package/dist/claude-task-detail-router.js +406 -0
- package/dist/claude-task-detail-value.js +42 -0
- package/dist/claude-task-text-timeline.js +61 -0
- package/dist/claude-tool-dot-filter.js +241 -0
- package/dist/cli.js +825 -0
- package/dist/client-base-url.js +31 -0
- package/dist/coalesced-json-writer.js +107 -0
- package/dist/codex-account-service.js +155 -0
- package/dist/codex-app-server-client.js +914 -0
- package/dist/codex-command.js +160 -0
- package/dist/codex-extension-route.js +60 -0
- package/dist/codex-extension-service.js +534 -0
- package/dist/codex-import-sync-cursor.js +60 -0
- package/dist/codex-mcp-oauth-config.js +22 -0
- package/dist/codex-mcp-oauth-migration.js +20 -0
- package/dist/codex-memory-read-route.js +20 -0
- package/dist/codex-memory-service.js +126 -0
- package/dist/codex-model-catalog.js +136 -0
- package/dist/codex-model-metadata-profile.js +53 -0
- package/dist/codex-official-account-route.js +113 -0
- package/dist/codex-provider-archive-transfer.js +83 -0
- package/dist/codex-provider-bound-client.js +20 -0
- package/dist/codex-provider-config-service.js +518 -0
- package/dist/codex-provider-config.js +424 -0
- package/dist/codex-provider-import.js +125 -0
- package/dist/codex-provider-runtime-client.js +531 -0
- package/dist/codex-provider-runtime-config.js +156 -0
- package/dist/codex-provider-services.js +40 -0
- package/dist/codex-runtime-capabilities.js +90 -0
- package/dist/codex-runtime-installer.js +266 -0
- package/dist/codex-runtime-route.js +88 -0
- package/dist/codex-session-import.js +1369 -0
- package/dist/codex-session-manager.js +6800 -0
- package/dist/codex-session-reconciliation.js +209 -0
- package/dist/codex-turn-lifecycle.js +43 -0
- package/dist/config.js +296 -0
- package/dist/console-activity-feed.js +297 -0
- package/dist/console-asset-encoding.js +88 -0
- package/dist/console-assets/OpenClaw-background-LICENSE.txt +23 -0
- package/dist/console-assets/OpenClaw-background-LICENSE.txt.br +0 -0
- package/dist/console-assets/OpenClaw-background-LICENSE.txt.gz +0 -0
- package/dist/console-assets/app-icon-dark.png +0 -0
- package/dist/console-assets/app-icon.png +0 -0
- package/dist/console-assets/claw-dark.webp +0 -0
- package/dist/console-assets/claw-light.webp +0 -0
- package/dist/console-assets/console-admin-fields.css +117 -0
- package/dist/console-assets/console-admin-fields.css.br +0 -0
- package/dist/console-assets/console-admin-fields.css.gz +0 -0
- package/dist/console-assets/console-admin-pages.css +318 -0
- package/dist/console-assets/console-admin-pages.css.br +0 -0
- package/dist/console-assets/console-admin-pages.css.gz +0 -0
- package/dist/console-assets/console-agent-content-view.js +299 -0
- package/dist/console-assets/console-agent-content-view.js.br +0 -0
- package/dist/console-assets/console-agent-content-view.js.gz +0 -0
- package/dist/console-assets/console-agent-content.js +308 -0
- package/dist/console-assets/console-agent-content.js.br +0 -0
- package/dist/console-assets/console-agent-content.js.gz +0 -0
- package/dist/console-assets/console-agent-icons.js +24 -0
- package/dist/console-assets/console-agent-relationships.css +121 -0
- package/dist/console-assets/console-agent-relationships.css.br +0 -0
- package/dist/console-assets/console-agent-relationships.css.gz +0 -0
- package/dist/console-assets/console-agent-relationships.js +286 -0
- package/dist/console-assets/console-agent-relationships.js.br +0 -0
- package/dist/console-assets/console-agent-relationships.js.gz +0 -0
- package/dist/console-assets/console-agent-timeline-state.js +284 -0
- package/dist/console-assets/console-agent-timeline-state.js.br +0 -0
- package/dist/console-assets/console-agent-timeline-state.js.gz +0 -0
- package/dist/console-assets/console-agent-timeline.js +153 -0
- package/dist/console-assets/console-agent-timeline.js.br +0 -0
- package/dist/console-assets/console-agent-timeline.js.gz +0 -0
- package/dist/console-assets/console-agent-tool-detail.js +166 -0
- package/dist/console-assets/console-agent-tool-detail.js.br +0 -0
- package/dist/console-assets/console-agent-tool-detail.js.gz +0 -0
- package/dist/console-assets/console-antigravity-account.js +248 -0
- package/dist/console-assets/console-antigravity-account.js.br +0 -0
- package/dist/console-assets/console-antigravity-account.js.gz +0 -0
- package/dist/console-assets/console-antigravity-events.js +60 -0
- package/dist/console-assets/console-antigravity-events.js.br +0 -0
- package/dist/console-assets/console-antigravity-events.js.gz +0 -0
- package/dist/console-assets/console-api-provider.js +1163 -0
- package/dist/console-assets/console-api-provider.js.br +0 -0
- package/dist/console-assets/console-api-provider.js.gz +0 -0
- package/dist/console-assets/console-api.js +136 -0
- package/dist/console-assets/console-api.js.br +0 -0
- package/dist/console-assets/console-api.js.gz +0 -0
- package/dist/console-assets/console-base-path.js +27 -0
- package/dist/console-assets/console-claude-tool-detail.js +44 -0
- package/dist/console-assets/console-claude-tool-detail.js.br +0 -0
- package/dist/console-assets/console-claude-tool-detail.js.gz +0 -0
- package/dist/console-assets/console-claw-conversation.css +203 -0
- package/dist/console-assets/console-claw-conversation.css.br +0 -0
- package/dist/console-assets/console-claw-conversation.css.gz +0 -0
- package/dist/console-assets/console-claw.css +438 -0
- package/dist/console-assets/console-claw.css.br +0 -0
- package/dist/console-assets/console-claw.css.gz +0 -0
- package/dist/console-assets/console-code-language.js +88 -0
- package/dist/console-assets/console-code-language.js.br +0 -0
- package/dist/console-assets/console-code-language.js.gz +0 -0
- package/dist/console-assets/console-code-reader.js +18 -0
- package/dist/console-assets/console-codex-import.js +80 -0
- package/dist/console-assets/console-codex-import.js.br +0 -0
- package/dist/console-assets/console-codex-import.js.gz +0 -0
- package/dist/console-assets/console-codex-runtime.js +144 -0
- package/dist/console-assets/console-codex-runtime.js.br +0 -0
- package/dist/console-assets/console-codex-runtime.js.gz +0 -0
- package/dist/console-assets/console-confirm-dialog.js +141 -0
- package/dist/console-assets/console-confirm-dialog.js.br +0 -0
- package/dist/console-assets/console-confirm-dialog.js.gz +0 -0
- package/dist/console-assets/console-connection-page.js +227 -0
- package/dist/console-assets/console-connection-page.js.br +0 -0
- package/dist/console-assets/console-connection-page.js.gz +0 -0
- package/dist/console-assets/console-connection-qr.js +52 -0
- package/dist/console-assets/console-connection-qr.js.br +0 -0
- package/dist/console-assets/console-connection-qr.js.gz +0 -0
- package/dist/console-assets/console-content-hierarchy.css +120 -0
- package/dist/console-assets/console-content-hierarchy.css.br +0 -0
- package/dist/console-assets/console-content-hierarchy.css.gz +0 -0
- package/dist/console-assets/console-content-presentation.js +20 -0
- package/dist/console-assets/console-context-compaction.js +41 -0
- package/dist/console-assets/console-context-compaction.js.br +0 -0
- package/dist/console-assets/console-context-compaction.js.gz +0 -0
- package/dist/console-assets/console-dashboard-overview.js +302 -0
- package/dist/console-assets/console-dashboard-overview.js.br +0 -0
- package/dist/console-assets/console-dashboard-overview.js.gz +0 -0
- package/dist/console-assets/console-density.css +225 -0
- package/dist/console-assets/console-density.css.br +0 -0
- package/dist/console-assets/console-density.css.gz +0 -0
- package/dist/console-assets/console-design-system.css +1039 -0
- package/dist/console-assets/console-design-system.css.br +0 -0
- package/dist/console-assets/console-design-system.css.gz +0 -0
- package/dist/console-assets/console-diff-parser.js +119 -0
- package/dist/console-assets/console-diff-parser.js.br +0 -0
- package/dist/console-assets/console-diff-parser.js.gz +0 -0
- package/dist/console-assets/console-e2ee.js +874 -0
- package/dist/console-assets/console-e2ee.js.br +0 -0
- package/dist/console-assets/console-e2ee.js.gz +0 -0
- package/dist/console-assets/console-extension-center.js +208 -0
- package/dist/console-assets/console-extension-center.js.br +0 -0
- package/dist/console-assets/console-extension-center.js.gz +0 -0
- package/dist/console-assets/console-extension-source-switcher.js +67 -0
- package/dist/console-assets/console-extension-source-switcher.js.br +0 -0
- package/dist/console-assets/console-extension-source-switcher.js.gz +0 -0
- package/dist/console-assets/console-extension-toolbar.css +118 -0
- package/dist/console-assets/console-extension-toolbar.css.br +0 -0
- package/dist/console-assets/console-extension-toolbar.css.gz +0 -0
- package/dist/console-assets/console-extension-visual.js +77 -0
- package/dist/console-assets/console-extension-visual.js.br +0 -0
- package/dist/console-assets/console-extension-visual.js.gz +0 -0
- package/dist/console-assets/console-extensions.js +1400 -0
- package/dist/console-assets/console-extensions.js.br +0 -0
- package/dist/console-assets/console-extensions.js.gz +0 -0
- package/dist/console-assets/console-feature-loader.js +59 -0
- package/dist/console-assets/console-feature-loader.js.br +0 -0
- package/dist/console-assets/console-feature-loader.js.gz +0 -0
- package/dist/console-assets/console-feishu-channel.js +483 -0
- package/dist/console-assets/console-feishu-channel.js.br +0 -0
- package/dist/console-assets/console-feishu-channel.js.gz +0 -0
- package/dist/console-assets/console-file-change-summary.js +87 -0
- package/dist/console-assets/console-file-change-summary.js.br +0 -0
- package/dist/console-assets/console-file-change-summary.js.gz +0 -0
- package/dist/console-assets/console-file-download.js +108 -0
- package/dist/console-assets/console-file-download.js.br +0 -0
- package/dist/console-assets/console-file-download.js.gz +0 -0
- package/dist/console-assets/console-file-drawer.css +118 -0
- package/dist/console-assets/console-file-drawer.css.br +0 -0
- package/dist/console-assets/console-file-drawer.css.gz +0 -0
- package/dist/console-assets/console-file-drawer.js +52 -0
- package/dist/console-assets/console-file-drawer.js.br +0 -0
- package/dist/console-assets/console-file-drawer.js.gz +0 -0
- package/dist/console-assets/console-file-link.js +40 -0
- package/dist/console-assets/console-file-link.js.br +0 -0
- package/dist/console-assets/console-file-link.js.gz +0 -0
- package/dist/console-assets/console-file-pane.js +794 -0
- package/dist/console-assets/console-file-pane.js.br +0 -0
- package/dist/console-assets/console-file-pane.js.gz +0 -0
- package/dist/console-assets/console-file-tree.js +81 -0
- package/dist/console-assets/console-file-tree.js.br +0 -0
- package/dist/console-assets/console-file-tree.js.gz +0 -0
- package/dist/console-assets/console-gateway-update.js +93 -0
- package/dist/console-assets/console-gateway-update.js.br +0 -0
- package/dist/console-assets/console-gateway-update.js.gz +0 -0
- package/dist/console-assets/console-health.js +218 -0
- package/dist/console-assets/console-health.js.br +0 -0
- package/dist/console-assets/console-health.js.gz +0 -0
- package/dist/console-assets/console-i18n-app-messages.js +388 -0
- package/dist/console-assets/console-i18n-app-messages.js.br +0 -0
- package/dist/console-assets/console-i18n-app-messages.js.gz +0 -0
- package/dist/console-assets/console-i18n-hierarchy-messages.js +94 -0
- package/dist/console-assets/console-i18n-hierarchy-messages.js.br +0 -0
- package/dist/console-assets/console-i18n-hierarchy-messages.js.gz +0 -0
- package/dist/console-assets/console-i18n-pi-messages.js +56 -0
- package/dist/console-assets/console-i18n-pi-messages.js.br +0 -0
- package/dist/console-assets/console-i18n-pi-messages.js.gz +0 -0
- package/dist/console-assets/console-i18n.js +2143 -0
- package/dist/console-assets/console-i18n.js.br +0 -0
- package/dist/console-assets/console-i18n.js.gz +0 -0
- package/dist/console-assets/console-ilink-binding.js +88 -0
- package/dist/console-assets/console-ilink-binding.js.br +0 -0
- package/dist/console-assets/console-ilink-binding.js.gz +0 -0
- package/dist/console-assets/console-image-feedback-model.js +89 -0
- package/dist/console-assets/console-image-feedback-model.js.br +0 -0
- package/dist/console-assets/console-image-feedback-model.js.gz +0 -0
- package/dist/console-assets/console-image-feedback.css +43 -0
- package/dist/console-assets/console-image-feedback.css.br +0 -0
- package/dist/console-assets/console-image-feedback.css.gz +0 -0
- package/dist/console-assets/console-image-feedback.js +268 -0
- package/dist/console-assets/console-image-feedback.js.br +0 -0
- package/dist/console-assets/console-image-feedback.js.gz +0 -0
- package/dist/console-assets/console-image-preview-zoom.js +73 -0
- package/dist/console-assets/console-image-preview-zoom.js.br +0 -0
- package/dist/console-assets/console-image-preview-zoom.js.gz +0 -0
- package/dist/console-assets/console-image-preview.js +232 -0
- package/dist/console-assets/console-image-preview.js.br +0 -0
- package/dist/console-assets/console-image-preview.js.gz +0 -0
- package/dist/console-assets/console-import-catalog-worker.js +61 -0
- package/dist/console-assets/console-import-catalog-worker.js.br +0 -0
- package/dist/console-assets/console-import-catalog-worker.js.gz +0 -0
- package/dist/console-assets/console-import-panel.js +517 -0
- package/dist/console-assets/console-import-panel.js.br +0 -0
- package/dist/console-assets/console-import-panel.js.gz +0 -0
- package/dist/console-assets/console-inline-visualization.js +57 -0
- package/dist/console-assets/console-inline-visualization.js.br +0 -0
- package/dist/console-assets/console-inline-visualization.js.gz +0 -0
- package/dist/console-assets/console-input-request.js +302 -0
- package/dist/console-assets/console-input-request.js.br +0 -0
- package/dist/console-assets/console-input-request.js.gz +0 -0
- package/dist/console-assets/console-live-sync.js +96 -0
- package/dist/console-assets/console-live-sync.js.br +0 -0
- package/dist/console-assets/console-live-sync.js.gz +0 -0
- package/dist/console-assets/console-loading.css +50 -0
- package/dist/console-assets/console-loading.css.br +0 -0
- package/dist/console-assets/console-loading.css.gz +0 -0
- package/dist/console-assets/console-loading.js +118 -0
- package/dist/console-assets/console-loading.js.br +0 -0
- package/dist/console-assets/console-loading.js.gz +0 -0
- package/dist/console-assets/console-markdown-image.js +74 -0
- package/dist/console-assets/console-markdown-image.js.br +0 -0
- package/dist/console-assets/console-markdown-image.js.gz +0 -0
- package/dist/console-assets/console-markdown-link.js +91 -0
- package/dist/console-assets/console-markdown-link.js.br +0 -0
- package/dist/console-assets/console-markdown-link.js.gz +0 -0
- package/dist/console-assets/console-markdown-list.js +68 -0
- package/dist/console-assets/console-markdown-list.js.br +0 -0
- package/dist/console-assets/console-markdown-list.js.gz +0 -0
- package/dist/console-assets/console-markdown-url.js +105 -0
- package/dist/console-assets/console-markdown-url.js.br +0 -0
- package/dist/console-assets/console-markdown-url.js.gz +0 -0
- package/dist/console-assets/console-markdown.js +509 -0
- package/dist/console-assets/console-markdown.js.br +0 -0
- package/dist/console-assets/console-markdown.js.gz +0 -0
- package/dist/console-assets/console-memory-galaxy.js +461 -0
- package/dist/console-assets/console-memory-galaxy.js.br +0 -0
- package/dist/console-assets/console-memory-galaxy.js.gz +0 -0
- package/dist/console-assets/console-memory.css +364 -0
- package/dist/console-assets/console-memory.css.br +0 -0
- package/dist/console-assets/console-memory.css.gz +0 -0
- package/dist/console-assets/console-memory.js +567 -0
- package/dist/console-assets/console-memory.js.br +0 -0
- package/dist/console-assets/console-memory.js.gz +0 -0
- package/dist/console-assets/console-model-capabilities-import.js +550 -0
- package/dist/console-assets/console-model-capabilities-import.js.br +0 -0
- package/dist/console-assets/console-model-capabilities-import.js.gz +0 -0
- package/dist/console-assets/console-model-picker.css +621 -0
- package/dist/console-assets/console-model-picker.css.br +0 -0
- package/dist/console-assets/console-model-picker.css.gz +0 -0
- package/dist/console-assets/console-model-picker.js +816 -0
- package/dist/console-assets/console-model-picker.js.br +0 -0
- package/dist/console-assets/console-model-picker.js.gz +0 -0
- package/dist/console-assets/console-model-reasoning-data.js +178 -0
- package/dist/console-assets/console-model-reasoning-data.js.br +0 -0
- package/dist/console-assets/console-model-reasoning-data.js.gz +0 -0
- package/dist/console-assets/console-model-reasoning.css +690 -0
- package/dist/console-assets/console-model-reasoning.css.br +0 -0
- package/dist/console-assets/console-model-reasoning.css.gz +0 -0
- package/dist/console-assets/console-model-reasoning.js +592 -0
- package/dist/console-assets/console-model-reasoning.js.br +0 -0
- package/dist/console-assets/console-model-reasoning.js.gz +0 -0
- package/dist/console-assets/console-notice.js +66 -0
- package/dist/console-assets/console-notice.js.br +0 -0
- package/dist/console-assets/console-notice.js.gz +0 -0
- package/dist/console-assets/console-notification-channels.css +471 -0
- package/dist/console-assets/console-notification-channels.css.br +0 -0
- package/dist/console-assets/console-notification-channels.css.gz +0 -0
- package/dist/console-assets/console-notification-channels.js +403 -0
- package/dist/console-assets/console-notification-channels.js.br +0 -0
- package/dist/console-assets/console-notification-channels.js.gz +0 -0
- package/dist/console-assets/console-official-codex-account.js +92 -0
- package/dist/console-assets/console-official-codex-account.js.br +0 -0
- package/dist/console-assets/console-official-codex-account.js.gz +0 -0
- package/dist/console-assets/console-overlay.js +202 -0
- package/dist/console-assets/console-overlay.js.br +0 -0
- package/dist/console-assets/console-overlay.js.gz +0 -0
- package/dist/console-assets/console-pi-events.js +56 -0
- package/dist/console-assets/console-pi-events.js.br +0 -0
- package/dist/console-assets/console-pi-events.js.gz +0 -0
- package/dist/console-assets/console-pi-model-catalog.js +86 -0
- package/dist/console-assets/console-pi-model-catalog.js.br +0 -0
- package/dist/console-assets/console-pi-model-catalog.js.gz +0 -0
- package/dist/console-assets/console-pi-model-editor.js +143 -0
- package/dist/console-assets/console-pi-model-editor.js.br +0 -0
- package/dist/console-assets/console-pi-model-editor.js.gz +0 -0
- package/dist/console-assets/console-pi-provider-fields.js +87 -0
- package/dist/console-assets/console-pi-provider-fields.js.br +0 -0
- package/dist/console-assets/console-pi-provider-fields.js.gz +0 -0
- package/dist/console-assets/console-preview-icons.svg +38 -0
- package/dist/console-assets/console-preview-icons.svg.br +0 -0
- package/dist/console-assets/console-preview-icons.svg.gz +0 -0
- package/dist/console-assets/console-provider-add-dialog.js +154 -0
- package/dist/console-assets/console-provider-add-dialog.js.br +0 -0
- package/dist/console-assets/console-provider-add-dialog.js.gz +0 -0
- package/dist/console-assets/console-provider-capabilities.js +295 -0
- package/dist/console-assets/console-provider-capabilities.js.br +0 -0
- package/dist/console-assets/console-provider-capabilities.js.gz +0 -0
- package/dist/console-assets/console-provider-config-tabs.js +78 -0
- package/dist/console-assets/console-provider-config-tabs.js.br +0 -0
- package/dist/console-assets/console-provider-config-tabs.js.gz +0 -0
- package/dist/console-assets/console-provider-edit-dialog.css +155 -0
- package/dist/console-assets/console-provider-edit-dialog.css.br +0 -0
- package/dist/console-assets/console-provider-edit-dialog.css.gz +0 -0
- package/dist/console-assets/console-provider-icon.js +217 -0
- package/dist/console-assets/console-provider-icon.js.br +0 -0
- package/dist/console-assets/console-provider-icon.js.gz +0 -0
- package/dist/console-assets/console-provider-model-default.js +56 -0
- package/dist/console-assets/console-provider-model-default.js.br +0 -0
- package/dist/console-assets/console-provider-model-default.js.gz +0 -0
- package/dist/console-assets/console-provider-model-editor.css +38 -0
- package/dist/console-assets/console-provider-model-editor.css.br +0 -0
- package/dist/console-assets/console-provider-model-editor.css.gz +0 -0
- package/dist/console-assets/console-provider-model-editor.js +284 -0
- package/dist/console-assets/console-provider-model-editor.js.br +0 -0
- package/dist/console-assets/console-provider-model-editor.js.gz +0 -0
- package/dist/console-assets/console-provider-overview.js +60 -0
- package/dist/console-assets/console-provider-overview.js.br +0 -0
- package/dist/console-assets/console-provider-overview.js.gz +0 -0
- package/dist/console-assets/console-provider-usage-panel.js +225 -0
- package/dist/console-assets/console-provider-usage-panel.js.br +0 -0
- package/dist/console-assets/console-provider-usage-panel.js.gz +0 -0
- package/dist/console-assets/console-provider-usage.js +246 -0
- package/dist/console-assets/console-provider-usage.js.br +0 -0
- package/dist/console-assets/console-provider-usage.js.gz +0 -0
- package/dist/console-assets/console-quick-prompts.js +178 -0
- package/dist/console-assets/console-quick-prompts.js.br +0 -0
- package/dist/console-assets/console-quick-prompts.js.gz +0 -0
- package/dist/console-assets/console-reconnect.js +76 -0
- package/dist/console-assets/console-reconnect.js.br +0 -0
- package/dist/console-assets/console-reconnect.js.gz +0 -0
- package/dist/console-assets/console-relay-access.js +212 -0
- package/dist/console-assets/console-relay-access.js.br +0 -0
- package/dist/console-assets/console-relay-access.js.gz +0 -0
- package/dist/console-assets/console-render-shell.js +63 -0
- package/dist/console-assets/console-render-shell.js.br +0 -0
- package/dist/console-assets/console-render-shell.js.gz +0 -0
- package/dist/console-assets/console-reply-color-names.js +151 -0
- package/dist/console-assets/console-reply-color-names.js.br +0 -0
- package/dist/console-assets/console-reply-color-names.js.gz +0 -0
- package/dist/console-assets/console-reply-markdown.js +123 -0
- package/dist/console-assets/console-reply-markdown.js.br +0 -0
- package/dist/console-assets/console-reply-markdown.js.gz +0 -0
- package/dist/console-assets/console-reply-preview-shell.js +63 -0
- package/dist/console-assets/console-reply-preview-shell.js.br +0 -0
- package/dist/console-assets/console-reply-preview-shell.js.gz +0 -0
- package/dist/console-assets/console-reply-preview.js +70 -0
- package/dist/console-assets/console-reply-preview.js.br +0 -0
- package/dist/console-assets/console-reply-preview.js.gz +0 -0
- package/dist/console-assets/console-reply-style.js +73 -0
- package/dist/console-assets/console-reply-style.js.br +0 -0
- package/dist/console-assets/console-reply-style.js.gz +0 -0
- package/dist/console-assets/console-schedule-drafts.js +410 -0
- package/dist/console-assets/console-schedule-drafts.js.br +0 -0
- package/dist/console-assets/console-schedule-drafts.js.gz +0 -0
- package/dist/console-assets/console-schedule-run-details.css +46 -0
- package/dist/console-assets/console-schedule-run-details.css.br +0 -0
- package/dist/console-assets/console-schedule-run-details.css.gz +0 -0
- package/dist/console-assets/console-schedule-run-details.js +221 -0
- package/dist/console-assets/console-schedule-run-details.js.br +0 -0
- package/dist/console-assets/console-schedule-run-details.js.gz +0 -0
- package/dist/console-assets/console-schedule-run-results.js +137 -0
- package/dist/console-assets/console-schedule-run-results.js.br +0 -0
- package/dist/console-assets/console-schedule-run-results.js.gz +0 -0
- package/dist/console-assets/console-schedule-runtime.js +163 -0
- package/dist/console-assets/console-schedule-runtime.js.br +0 -0
- package/dist/console-assets/console-schedule-runtime.js.gz +0 -0
- package/dist/console-assets/console-schedules.css +614 -0
- package/dist/console-assets/console-schedules.css.br +0 -0
- package/dist/console-assets/console-schedules.css.gz +0 -0
- package/dist/console-assets/console-schedules.js +900 -0
- package/dist/console-assets/console-schedules.js.br +0 -0
- package/dist/console-assets/console-schedules.js.gz +0 -0
- package/dist/console-assets/console-scrollbars.js +38 -0
- package/dist/console-assets/console-scrollbars.js.br +0 -0
- package/dist/console-assets/console-scrollbars.js.gz +0 -0
- package/dist/console-assets/console-select.js +506 -0
- package/dist/console-assets/console-select.js.br +0 -0
- package/dist/console-assets/console-select.js.gz +0 -0
- package/dist/console-assets/console-session-agent-preset.js +209 -0
- package/dist/console-assets/console-session-agent-preset.js.br +0 -0
- package/dist/console-assets/console-session-agent-preset.js.gz +0 -0
- package/dist/console-assets/console-session-branch-view.js +125 -0
- package/dist/console-assets/console-session-branch-view.js.br +0 -0
- package/dist/console-assets/console-session-branch-view.js.gz +0 -0
- package/dist/console-assets/console-session-branch.css +74 -0
- package/dist/console-assets/console-session-branch.css.br +0 -0
- package/dist/console-assets/console-session-branch.css.gz +0 -0
- package/dist/console-assets/console-session-branch.js +263 -0
- package/dist/console-assets/console-session-branch.js.br +0 -0
- package/dist/console-assets/console-session-branch.js.gz +0 -0
- package/dist/console-assets/console-session-changes.js +310 -0
- package/dist/console-assets/console-session-changes.js.br +0 -0
- package/dist/console-assets/console-session-changes.js.gz +0 -0
- package/dist/console-assets/console-session-cockpit.css +37 -0
- package/dist/console-assets/console-session-cockpit.css.br +0 -0
- package/dist/console-assets/console-session-cockpit.css.gz +0 -0
- package/dist/console-assets/console-session-cockpit.js +106 -0
- package/dist/console-assets/console-session-cockpit.js.br +0 -0
- package/dist/console-assets/console-session-cockpit.js.gz +0 -0
- package/dist/console-assets/console-session-composer.js +42 -0
- package/dist/console-assets/console-session-composer.js.br +0 -0
- package/dist/console-assets/console-session-composer.js.gz +0 -0
- package/dist/console-assets/console-session-create-controls.js +133 -0
- package/dist/console-assets/console-session-create-controls.js.br +0 -0
- package/dist/console-assets/console-session-create-controls.js.gz +0 -0
- package/dist/console-assets/console-session-create-default.js +26 -0
- package/dist/console-assets/console-session-create-default.js.br +0 -0
- package/dist/console-assets/console-session-create-default.js.gz +0 -0
- package/dist/console-assets/console-session-create-draft.css +374 -0
- package/dist/console-assets/console-session-create-draft.css.br +0 -0
- package/dist/console-assets/console-session-create-draft.css.gz +0 -0
- package/dist/console-assets/console-session-create-draft.js +82 -0
- package/dist/console-assets/console-session-create-draft.js.br +0 -0
- package/dist/console-assets/console-session-create-draft.js.gz +0 -0
- package/dist/console-assets/console-session-create-reasoning.js +187 -0
- package/dist/console-assets/console-session-create-reasoning.js.br +0 -0
- package/dist/console-assets/console-session-create-reasoning.js.gz +0 -0
- package/dist/console-assets/console-session-diff.css +572 -0
- package/dist/console-assets/console-session-diff.css.br +0 -0
- package/dist/console-assets/console-session-diff.css.gz +0 -0
- package/dist/console-assets/console-session-diff.js +342 -0
- package/dist/console-assets/console-session-diff.js.br +0 -0
- package/dist/console-assets/console-session-diff.js.gz +0 -0
- package/dist/console-assets/console-session-event-i18n.js +187 -0
- package/dist/console-assets/console-session-event-i18n.js.br +0 -0
- package/dist/console-assets/console-session-event-i18n.js.gz +0 -0
- package/dist/console-assets/console-session-event-tone.js +60 -0
- package/dist/console-assets/console-session-event-tone.js.br +0 -0
- package/dist/console-assets/console-session-event-tone.js.gz +0 -0
- package/dist/console-assets/console-session-generated-images.js +367 -0
- package/dist/console-assets/console-session-generated-images.js.br +0 -0
- package/dist/console-assets/console-session-generated-images.js.gz +0 -0
- package/dist/console-assets/console-session-handoff-picker.js +58 -0
- package/dist/console-assets/console-session-handoff-picker.js.br +0 -0
- package/dist/console-assets/console-session-handoff-picker.js.gz +0 -0
- package/dist/console-assets/console-session-history.js +188 -0
- package/dist/console-assets/console-session-history.js.br +0 -0
- package/dist/console-assets/console-session-history.js.gz +0 -0
- package/dist/console-assets/console-session-image-rail.js +241 -0
- package/dist/console-assets/console-session-image-rail.js.br +0 -0
- package/dist/console-assets/console-session-image-rail.js.gz +0 -0
- package/dist/console-assets/console-session-input.js +111 -0
- package/dist/console-assets/console-session-input.js.br +0 -0
- package/dist/console-assets/console-session-input.js.gz +0 -0
- package/dist/console-assets/console-session-interactions.css +216 -0
- package/dist/console-assets/console-session-interactions.css.br +0 -0
- package/dist/console-assets/console-session-interactions.css.gz +0 -0
- package/dist/console-assets/console-session-list-data.js +39 -0
- package/dist/console-assets/console-session-list-data.js.br +0 -0
- package/dist/console-assets/console-session-list-data.js.gz +0 -0
- package/dist/console-assets/console-session-list-loader.js +40 -0
- package/dist/console-assets/console-session-list-loader.js.br +0 -0
- package/dist/console-assets/console-session-list-loader.js.gz +0 -0
- package/dist/console-assets/console-session-list-menu.js +73 -0
- package/dist/console-assets/console-session-list-menu.js.br +0 -0
- package/dist/console-assets/console-session-list-menu.js.gz +0 -0
- package/dist/console-assets/console-session-message-context.js +193 -0
- package/dist/console-assets/console-session-message-context.js.br +0 -0
- package/dist/console-assets/console-session-message-context.js.gz +0 -0
- package/dist/console-assets/console-session-message-position.js +223 -0
- package/dist/console-assets/console-session-message-position.js.br +0 -0
- package/dist/console-assets/console-session-message-position.js.gz +0 -0
- package/dist/console-assets/console-session-message-search.js +44 -0
- package/dist/console-assets/console-session-message-search.js.br +0 -0
- package/dist/console-assets/console-session-message-search.js.gz +0 -0
- package/dist/console-assets/console-session-optimistic-input.js +148 -0
- package/dist/console-assets/console-session-optimistic-input.js.br +0 -0
- package/dist/console-assets/console-session-optimistic-input.js.gz +0 -0
- package/dist/console-assets/console-session-pagination.js +323 -0
- package/dist/console-assets/console-session-pagination.js.br +0 -0
- package/dist/console-assets/console-session-pagination.js.gz +0 -0
- package/dist/console-assets/console-session-permission.js +282 -0
- package/dist/console-assets/console-session-permission.js.br +0 -0
- package/dist/console-assets/console-session-permission.js.gz +0 -0
- package/dist/console-assets/console-session-primary-collapse.js +135 -0
- package/dist/console-assets/console-session-primary-collapse.js.br +0 -0
- package/dist/console-assets/console-session-primary-collapse.js.gz +0 -0
- package/dist/console-assets/console-session-provider.js +72 -0
- package/dist/console-assets/console-session-provider.js.br +0 -0
- package/dist/console-assets/console-session-provider.js.gz +0 -0
- package/dist/console-assets/console-session-runtime-config.js +1052 -0
- package/dist/console-assets/console-session-runtime-config.js.br +0 -0
- package/dist/console-assets/console-session-runtime-config.js.gz +0 -0
- package/dist/console-assets/console-session-scroll-anchor.js +81 -0
- package/dist/console-assets/console-session-scroll-anchor.js.br +0 -0
- package/dist/console-assets/console-session-scroll-anchor.js.gz +0 -0
- package/dist/console-assets/console-session-stage-clock.js +78 -0
- package/dist/console-assets/console-session-stage-clock.js.br +0 -0
- package/dist/console-assets/console-session-stage-clock.js.gz +0 -0
- package/dist/console-assets/console-session-stages.js +392 -0
- package/dist/console-assets/console-session-stages.js.br +0 -0
- package/dist/console-assets/console-session-stages.js.gz +0 -0
- package/dist/console-assets/console-session-state-reconcile.js +85 -0
- package/dist/console-assets/console-session-state-reconcile.js.br +0 -0
- package/dist/console-assets/console-session-state-reconcile.js.gz +0 -0
- package/dist/console-assets/console-session-status.js +108 -0
- package/dist/console-assets/console-session-status.js.br +0 -0
- package/dist/console-assets/console-session-status.js.gz +0 -0
- package/dist/console-assets/console-session-subagent-detail.js +97 -0
- package/dist/console-assets/console-session-subagent-detail.js.br +0 -0
- package/dist/console-assets/console-session-subagent-detail.js.gz +0 -0
- package/dist/console-assets/console-session-tab-strip.js +97 -0
- package/dist/console-assets/console-session-tab-strip.js.br +0 -0
- package/dist/console-assets/console-session-tab-strip.js.gz +0 -0
- package/dist/console-assets/console-session-tabs.js +272 -0
- package/dist/console-assets/console-session-tabs.js.br +0 -0
- package/dist/console-assets/console-session-tabs.js.gz +0 -0
- package/dist/console-assets/console-session-terminal-reconcile.js +17 -0
- package/dist/console-assets/console-session-tool-dock.css +47 -0
- package/dist/console-assets/console-session-tool-dock.css.br +0 -0
- package/dist/console-assets/console-session-tool-dock.css.gz +0 -0
- package/dist/console-assets/console-session-tools.css +60 -0
- package/dist/console-assets/console-session-tools.css.br +0 -0
- package/dist/console-assets/console-session-tools.css.gz +0 -0
- package/dist/console-assets/console-session-turn-files.js +178 -0
- package/dist/console-assets/console-session-turn-files.js.br +0 -0
- package/dist/console-assets/console-session-turn-files.js.gz +0 -0
- package/dist/console-assets/console-session-type.js +136 -0
- package/dist/console-assets/console-session-type.js.br +0 -0
- package/dist/console-assets/console-session-type.js.gz +0 -0
- package/dist/console-assets/console-session-workspace-picker.js +356 -0
- package/dist/console-assets/console-session-workspace-picker.js.br +0 -0
- package/dist/console-assets/console-session-workspace-picker.js.gz +0 -0
- package/dist/console-assets/console-session-workspace-suggestions.js +242 -0
- package/dist/console-assets/console-session-workspace-suggestions.js.br +0 -0
- package/dist/console-assets/console-session-workspace-suggestions.js.gz +0 -0
- package/dist/console-assets/console-sound.js +172 -0
- package/dist/console-assets/console-sound.js.br +0 -0
- package/dist/console-assets/console-sound.js.gz +0 -0
- package/dist/console-assets/console-state.js +331 -0
- package/dist/console-assets/console-state.js.br +0 -0
- package/dist/console-assets/console-state.js.gz +0 -0
- package/dist/console-assets/console-subagent-stop.js +94 -0
- package/dist/console-assets/console-subagent-stop.js.br +0 -0
- package/dist/console-assets/console-subagent-stop.js.gz +0 -0
- package/dist/console-assets/console-system-layout.css +188 -0
- package/dist/console-assets/console-system-layout.css.br +0 -0
- package/dist/console-assets/console-system-layout.css.gz +0 -0
- package/dist/console-assets/console-tool-diff.js +24 -0
- package/dist/console-assets/console-tool-diff.js.br +0 -0
- package/dist/console-assets/console-tool-diff.js.gz +0 -0
- package/dist/console-assets/console-tool-page-tabs.js +56 -0
- package/dist/console-assets/console-tool-page-tabs.js.br +0 -0
- package/dist/console-assets/console-tool-page-tabs.js.gz +0 -0
- package/dist/console-assets/console-tool-permissions.js +32 -0
- package/dist/console-assets/console-tool-permissions.js.br +0 -0
- package/dist/console-assets/console-tool-permissions.js.gz +0 -0
- package/dist/console-assets/console-topbar-quota.js +242 -0
- package/dist/console-assets/console-topbar-quota.js.br +0 -0
- package/dist/console-assets/console-topbar-quota.js.gz +0 -0
- package/dist/console-assets/console-topbar-status.js +74 -0
- package/dist/console-assets/console-topbar-status.js.br +0 -0
- package/dist/console-assets/console-topbar-status.js.gz +0 -0
- package/dist/console-assets/console-typography.css +70 -0
- package/dist/console-assets/console-typography.css.br +0 -0
- package/dist/console-assets/console-typography.css.gz +0 -0
- package/dist/console-assets/console-usage-calendar.js +313 -0
- package/dist/console-assets/console-usage-calendar.js.br +0 -0
- package/dist/console-assets/console-usage-calendar.js.gz +0 -0
- package/dist/console-assets/console-usage-report.js +48 -0
- package/dist/console-assets/console-usage-report.js.br +0 -0
- package/dist/console-assets/console-usage-report.js.gz +0 -0
- package/dist/console-assets/console-usage-trend.js +163 -0
- package/dist/console-assets/console-usage-trend.js.br +0 -0
- package/dist/console-assets/console-usage-trend.js.gz +0 -0
- package/dist/console-assets/console-utils.js +2659 -0
- package/dist/console-assets/console-utils.js.br +0 -0
- package/dist/console-assets/console-utils.js.gz +0 -0
- package/dist/console-assets/console-visual-consistency.css +412 -0
- package/dist/console-assets/console-visual-consistency.css.br +0 -0
- package/dist/console-assets/console-visual-consistency.css.gz +0 -0
- package/dist/console-assets/console-workbench-unified.css +1949 -0
- package/dist/console-assets/console-workbench-unified.css.br +0 -0
- package/dist/console-assets/console-workbench-unified.css.gz +0 -0
- package/dist/console-assets/console-workspace-git-data.js +39 -0
- package/dist/console-assets/console-workspace-git-data.js.br +0 -0
- package/dist/console-assets/console-workspace-git-data.js.gz +0 -0
- package/dist/console-assets/console-workspace-git-diff-view.js +103 -0
- package/dist/console-assets/console-workspace-git-diff-view.js.br +0 -0
- package/dist/console-assets/console-workspace-git-diff-view.js.gz +0 -0
- package/dist/console-assets/console-workspace-git-explorer.js +147 -0
- package/dist/console-assets/console-workspace-git-explorer.js.br +0 -0
- package/dist/console-assets/console-workspace-git-explorer.js.gz +0 -0
- package/dist/console-assets/console-workspace-git-view.js +236 -0
- package/dist/console-assets/console-workspace-git-view.js.br +0 -0
- package/dist/console-assets/console-workspace-git-view.js.gz +0 -0
- package/dist/console-assets/console-workspace-git.css +147 -0
- package/dist/console-assets/console-workspace-git.css.br +0 -0
- package/dist/console-assets/console-workspace-git.css.gz +0 -0
- package/dist/console-assets/console-workspace-git.js +172 -0
- package/dist/console-assets/console-workspace-git.js.br +0 -0
- package/dist/console-assets/console-workspace-git.js.gz +0 -0
- package/dist/console-assets/console.css +11598 -0
- package/dist/console-assets/console.css.br +0 -0
- package/dist/console-assets/console.css.gz +0 -0
- package/dist/console-assets/console.js +9537 -0
- package/dist/console-assets/console.js.br +0 -0
- package/dist/console-assets/console.js.gz +0 -0
- package/dist/console-assets/favicon-dark.ico +0 -0
- package/dist/console-assets/favicon.ico +0 -0
- package/dist/console-assets/fonts/instrument-sans-OFL.txt +93 -0
- package/dist/console-assets/fonts/instrument-sans-OFL.txt.br +0 -0
- package/dist/console-assets/fonts/instrument-sans-OFL.txt.gz +0 -0
- package/dist/console-assets/fonts/instrument-sans-italic-latin.woff2 +0 -0
- package/dist/console-assets/fonts/instrument-sans-latin.woff2 +0 -0
- package/dist/console-assets/fonts/jetbrains-mono-OFL.txt +93 -0
- package/dist/console-assets/fonts/jetbrains-mono-OFL.txt.br +0 -0
- package/dist/console-assets/fonts/jetbrains-mono-OFL.txt.gz +0 -0
- package/dist/console-assets/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/dist/console-assets/index.html +2272 -0
- package/dist/console-assets/index.html.br +0 -0
- package/dist/console-assets/index.html.gz +0 -0
- package/dist/console-assets/vendor/THIRD_PARTY_LICENSES.txt +74 -0
- package/dist/console-assets/vendor/THIRD_PARTY_LICENSES.txt.br +0 -0
- package/dist/console-assets/vendor/THIRD_PARTY_LICENSES.txt.gz +0 -0
- package/dist/console-assets/vendor/code-reader-6.0.0.mjs +41 -0
- package/dist/console-assets/vendor/code-reader-6.0.0.mjs.br +0 -0
- package/dist/console-assets/vendor/code-reader-6.0.0.mjs.gz +0 -0
- package/dist/console-assets/vendor/inter-5.2.8/LICENSE +93 -0
- package/dist/console-assets/vendor/inter-5.2.8/files/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/console-assets/vendor/inter-5.2.8/files/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/console-assets/vendor/inter-5.2.8/files/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/console-assets/vendor/inter-5.2.8/files/inter-greek-wght-normal.woff2 +0 -0
- package/dist/console-assets/vendor/inter-5.2.8/files/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/console-assets/vendor/inter-5.2.8/files/inter-latin-wght-normal.woff2 +0 -0
- package/dist/console-assets/vendor/inter-5.2.8/files/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/console-assets/vendor/inter-5.2.8/wght.css +69 -0
- package/dist/console-assets/vendor/inter-5.2.8/wght.css.br +0 -0
- package/dist/console-assets/vendor/inter-5.2.8/wght.css.gz +0 -0
- package/dist/console-assets/vendor/marked-18.0.11-LICENSE.txt +44 -0
- package/dist/console-assets/vendor/marked-18.0.11-LICENSE.txt.br +0 -0
- package/dist/console-assets/vendor/marked-18.0.11-LICENSE.txt.gz +0 -0
- package/dist/console-assets/vendor/marked-18.0.11.mjs +78 -0
- package/dist/console-assets/vendor/marked-18.0.11.mjs.br +0 -0
- package/dist/console-assets/vendor/marked-18.0.11.mjs.gz +0 -0
- package/dist/console-cache.js +49 -0
- package/dist/console-connection.js +219 -0
- package/dist/console-gateway-update-route.js +45 -0
- package/dist/console-overview.js +147 -0
- package/dist/console-quality-analytics.js +247 -0
- package/dist/console-session-aggregation.js +54 -0
- package/dist/console-static.js +132 -0
- package/dist/console-summary.js +582 -0
- package/dist/console-usage-analytics.js +486 -0
- package/dist/console-websocket-server.js +235 -0
- package/dist/console-workbench.js +11 -0
- package/dist/deepseek-harness-agent-preset.js +64 -0
- package/dist/deepseek-harness-auth.js +113 -0
- package/dist/deepseek-harness-extension-catalog.js +252 -0
- package/dist/deepseek-harness-prompt.js +88 -0
- package/dist/deepseek-harness-remote-runtime-client.js +1334 -0
- package/dist/deepseek-harness-runtime-client.js +421 -0
- package/dist/deepseek-harness-token-usage.js +82 -0
- package/dist/deepseek-harness-v2-protocol.js +18 -0
- package/dist/deepseek-harness-v2-stream.js +210 -0
- package/dist/deveco-code-acp-output.js +114 -0
- package/dist/deveco-code-acp-process.js +136 -0
- package/dist/deveco-code-acp-progress.js +89 -0
- package/dist/deveco-code-acp-tool.js +125 -0
- package/dist/deveco-code-content-archive.js +75 -0
- package/dist/deveco-code-runtime-client.js +1040 -0
- package/dist/deveco-code-runtime-installer.js +194 -0
- package/dist/deveco-code-session-lifecycle.js +362 -0
- package/dist/diagnostics-insights.js +24 -0
- package/dist/directory-entry.js +1 -0
- package/dist/directory-listing.js +59 -0
- package/dist/document-content.js +149 -0
- package/dist/event-history-retention.js +140 -0
- package/dist/event-payload-filter.js +689 -0
- package/dist/extension-center-route.js +94 -0
- package/dist/extension-center-service.js +482 -0
- package/dist/extension-center-types.js +15 -0
- package/dist/feishu-approval-service.js +135 -0
- package/dist/feishu-approval-token.js +185 -0
- package/dist/feishu-binding-store.js +67 -0
- package/dist/feishu-channel-config.js +152 -0
- package/dist/feishu-conversation-service.js +290 -0
- package/dist/feishu-conversation-store.js +123 -0
- package/dist/feishu-inbox.js +194 -0
- package/dist/feishu-notification-channel.js +43 -0
- package/dist/filesystem-roots-route.js +37 -0
- package/dist/filesystem-roots-store.js +142 -0
- package/dist/gateway-device-info.js +91 -0
- package/dist/gateway-env.js +41 -0
- package/dist/gateway-health.js +9 -0
- package/dist/gateway-memory-capture-policy.js +26 -0
- package/dist/gateway-memory-curator.js +180 -0
- package/dist/gateway-memory-distiller.js +153 -0
- package/dist/gateway-memory-extraction.js +159 -0
- package/dist/gateway-memory-reference.js +38 -0
- package/dist/gateway-memory-repository-accounting.js +63 -0
- package/dist/gateway-memory-repository-jobs.js +278 -0
- package/dist/gateway-memory-repository-schema.js +87 -0
- package/dist/gateway-memory-repository.js +311 -0
- package/dist/gateway-memory-route.js +141 -0
- package/dist/gateway-memory-runtime.js +53 -0
- package/dist/gateway-memory-service.js +395 -0
- package/dist/gateway-memory-store.js +118 -0
- package/dist/gateway-memory-types.js +5 -0
- package/dist/gateway-memory-validation.js +110 -0
- package/dist/gateway-memory-worker.js +23 -0
- package/dist/gateway-self-update.js +122 -0
- package/dist/gateway-shutdown.js +35 -0
- package/dist/gateway-startup-context.js +11 -0
- package/dist/gateway-update-coordinator.js +86 -0
- package/dist/gateway-update-handoff.js +167 -0
- package/dist/generated-image-collector.js +108 -0
- package/dist/generated-image-result.js +84 -0
- package/dist/history-json-response.js +51 -0
- package/dist/http-file-stream.js +24 -0
- package/dist/http-json-body.js +54 -0
- package/dist/http-read-budget.js +23 -0
- package/dist/http-request-isolation.js +22 -0
- package/dist/ilink-binding-service.js +91 -0
- package/dist/ilink-channel-state.js +26 -0
- package/dist/ilink-client.js +264 -0
- package/dist/ilink-managed-worker.js +103 -0
- package/dist/ilink-notification-channel.js +185 -0
- package/dist/ilink-text-chunks.js +33 -0
- package/dist/importable-thread-groups.js +142 -0
- package/dist/index.js +4809 -0
- package/dist/inline-visualization-file.js +95 -0
- package/dist/inline-visualization.js +65 -0
- package/dist/input-request-store.js +80 -0
- package/dist/input-request.js +1 -0
- package/dist/mcp-oauth-callback-proxy.js +229 -0
- package/dist/mcp-oauth-policy.js +3 -0
- package/dist/model-capabilities-models-dev-route.js +116 -0
- package/dist/model-reasoning-capabilities.js +65 -0
- package/dist/model-reasoning-policy-route.js +39 -0
- package/dist/model-reasoning-policy-schema.js +181 -0
- package/dist/model-reasoning-policy-store.js +124 -0
- package/dist/model-reasoning-policy-upgrade.js +89 -0
- package/dist/model-reasoning-policy.js +46 -0
- package/dist/model-reasoning-policy.json +34 -0
- package/dist/newapi-provider-usage.js +324 -0
- package/dist/notification-channel-public.js +27 -0
- package/dist/notification-channel.js +48 -0
- package/dist/notification-outbox.js +230 -0
- package/dist/notification.js +5 -0
- package/dist/persistence.js +826 -0
- package/dist/pi-agent-approval-policy.js +65 -0
- package/dist/pi-agent-config-test.js +80 -0
- package/dist/pi-agent-content-archive.js +54 -0
- package/dist/pi-agent-diff-archive.js +49 -0
- package/dist/pi-agent-diff-preview.js +40 -0
- package/dist/pi-agent-event-adapter.js +165 -0
- package/dist/pi-agent-extension-catalog.js +289 -0
- package/dist/pi-agent-extension-support.js +307 -0
- package/dist/pi-agent-history-validation.js +60 -0
- package/dist/pi-agent-image-header.js +45 -0
- package/dist/pi-agent-input-context.js +171 -0
- package/dist/pi-agent-input-queue.js +82 -0
- package/dist/pi-agent-model-catalog-match.js +152 -0
- package/dist/pi-agent-model-catalog-route.js +49 -0
- package/dist/pi-agent-model-catalog.js +170 -0
- package/dist/pi-agent-model-config.js +135 -0
- package/dist/pi-agent-model-runtime.js +141 -0
- package/dist/pi-agent-permissions.js +40 -0
- package/dist/pi-agent-runtime-client.js +433 -0
- package/dist/pi-agent-sdk-installer.js +296 -0
- package/dist/pi-agent-session-branch.js +128 -0
- package/dist/pi-agent-session-projection.js +25 -0
- package/dist/pi-agent-session-recovery.js +61 -0
- package/dist/pi-agent-session-storage.js +89 -0
- package/dist/pi-agent-text-content.js +29 -0
- package/dist/pi-agent-tool-events.js +71 -0
- package/dist/pi-agent-write-diff.js +119 -0
- package/dist/platform-command.js +9 -0
- package/dist/project-memory-choice.js +83 -0
- package/dist/project-memory-command.js +17 -0
- package/dist/project-memory-curation.js +47 -0
- package/dist/project-memory-files.js +117 -0
- package/dist/project-memory-git.js +58 -0
- package/dist/project-memory-offer.js +35 -0
- package/dist/project-memory-repository.js +57 -0
- package/dist/project-memory-runtime.js +156 -0
- package/dist/project-memory-service.js +44 -0
- package/dist/protocol-runtime.js +77 -0
- package/dist/protocol.js +28 -0
- package/dist/provider-capabilities.js +195 -0
- package/dist/provider-config-migration.js +148 -0
- package/dist/provider-config.js +299 -0
- package/dist/provider-default-model.js +27 -0
- package/dist/provider-model-discovery-adapters.js +127 -0
- package/dist/provider-model-discovery-service.js +208 -0
- package/dist/provider-model-options.js +98 -0
- package/dist/provider-model-resolution.js +49 -0
- package/dist/provider-protocol.js +21 -0
- package/dist/provider-quota-summary-route.js +77 -0
- package/dist/provider-runtime-apply.js +35 -0
- package/dist/provider-runtime-diagnostics.js +77 -0
- package/dist/provider-usage-route.js +45 -0
- package/dist/provider-usage.js +180 -0
- package/dist/published-app-file.js +28 -0
- package/dist/qr-login-ticket.js +67 -0
- package/dist/relay-client.js +1196 -0
- package/dist/relay-console-route.js +46 -0
- package/dist/relay-controller.js +266 -0
- package/dist/relay-e2ee.js +540 -0
- package/dist/relay-enrollment-client.js +162 -0
- package/dist/relay-identity-store.js +191 -0
- package/dist/relay-observability.js +36 -0
- package/dist/relay-preference-store.js +49 -0
- package/dist/relay-protocol.js +47 -0
- package/dist/retired-codex-skills.js +30 -0
- package/dist/runtime-manager-route.js +212 -0
- package/dist/runtime-models.js +485 -0
- package/dist/runtime-skills/rcoding-schedule/SKILL.md +33 -0
- package/dist/schedule-configuration-route.js +38 -0
- package/dist/schedule-configuration.js +70 -0
- package/dist/schedule-draft-service.js +327 -0
- package/dist/schedule-engine.js +304 -0
- package/dist/schedule-executor.js +547 -0
- package/dist/schedule-mcp-server.js +372 -0
- package/dist/schedule-recovery.js +18 -0
- package/dist/schedule-route.js +576 -0
- package/dist/schedule-run-details.js +108 -0
- package/dist/schedule-run-diagnostics.js +25 -0
- package/dist/schedule-run-output-store.js +97 -0
- package/dist/schedule-run-output.js +37 -0
- package/dist/schedule-session-retention.js +108 -0
- package/dist/schedule-skill-policy.js +36 -0
- package/dist/schedule-store.js +417 -0
- package/dist/schedule-tool-policy.js +139 -0
- package/dist/schedule.js +329 -0
- package/dist/segmented-event-history.js +577 -0
- package/dist/server-health.js +545 -0
- package/dist/session-action-list.js +22 -0
- package/dist/session-branch-files.js +52 -0
- package/dist/session-branch-history.js +98 -0
- package/dist/session-branch-recovery.js +88 -0
- package/dist/session-branch-route.js +53 -0
- package/dist/session-branch.js +57 -0
- package/dist/session-busy-response.js +9 -0
- package/dist/session-change-index.js +423 -0
- package/dist/session-changes.js +357 -0
- package/dist/session-child-route.js +14 -0
- package/dist/session-cockpit.js +384 -0
- package/dist/session-create-request.js +104 -0
- package/dist/session-event-page.js +153 -0
- package/dist/session-event-turn-file-metadata.js +56 -0
- package/dist/session-file-access.js +310 -0
- package/dist/session-file-download.js +89 -0
- package/dist/session-file-worktree.js +76 -0
- package/dist/session-final-answer.js +29 -0
- package/dist/session-handoff-history.js +115 -0
- package/dist/session-handoff-model.js +100 -0
- package/dist/session-handoff.js +115 -0
- package/dist/session-history-backward-reader.js +107 -0
- package/dist/session-history-migrator.js +193 -0
- package/dist/session-history-stream.js +45 -0
- package/dist/session-history.js +323 -0
- package/dist/session-image.js +64 -0
- package/dist/session-import-job.js +189 -0
- package/dist/session-input-service.js +245 -0
- package/dist/session-insight-persistence.js +176 -0
- package/dist/session-insight-service.js +267 -0
- package/dist/session-list-query.js +273 -0
- package/dist/session-list-route.js +26 -0
- package/dist/session-memory-citation.js +74 -0
- package/dist/session-provider-resolver.js +87 -0
- package/dist/session-reconciliation-service.js +218 -0
- package/dist/session-startup-operation.js +49 -0
- package/dist/session-steer-observer.js +44 -0
- package/dist/session-store.js +60 -0
- package/dist/session-subagent-history.js +67 -0
- package/dist/session-subagent-state.js +66 -0
- package/dist/session-subagent-stop-route.js +49 -0
- package/dist/session-summary.js +178 -0
- package/dist/session-timeline-page.js +97 -0
- package/dist/session-token-usage-recovery.js +59 -0
- package/dist/session-token-usage.js +291 -0
- package/dist/session-turn-lock.js +33 -0
- package/dist/session.js +82 -0
- package/dist/structured-input.js +103 -0
- package/dist/third-party-notices/OpenMausBot/LICENSE +202 -0
- package/dist/third-party-notices/OpenMausBot/NOTICE +24 -0
- package/dist/throttled-snapshot-writer.js +58 -0
- package/dist/turn-file-undo-capture.js +53 -0
- package/dist/turn-file-undo-files.js +192 -0
- package/dist/turn-file-undo-gate.js +15 -0
- package/dist/turn-file-undo-patch.js +258 -0
- package/dist/turn-file-undo-route.js +41 -0
- package/dist/turn-file-undo-service.js +377 -0
- package/dist/turn-file-undo-store.js +229 -0
- package/dist/turn-file-undo-types.js +32 -0
- package/dist/turn-speed-tracker.js +326 -0
- package/dist/unified-provider-config-service.js +798 -0
- package/dist/update-manifest.js +211 -0
- package/dist/usage-history-supplement.js +79 -0
- package/dist/usage-ledger.js +370 -0
- package/dist/usage-report-client.js +37 -0
- package/dist/usage-report-route.js +41 -0
- package/dist/usage-report-scheduler.js +140 -0
- package/dist/user-paths.js +125 -0
- package/dist/weather-service.js +193 -0
- package/dist/websocket-client-registry.js +101 -0
- package/dist/websocket-close.js +86 -0
- package/dist/websocket-server.js +195 -0
- package/dist/widget-summary.js +399 -0
- package/dist/windows-launcher/windows-arm64/rcoding-windows-launcher.exe +0 -0
- package/dist/windows-launcher/windows-x64/rcoding-windows-launcher.exe +0 -0
- package/dist/windows-service.js +473 -0
- package/dist/workspace-directory.js +63 -0
- package/dist/workspace-file.js +276 -0
- package/dist/workspace-git-branches.js +46 -0
- package/dist/workspace-git-browser-context.js +41 -0
- package/dist/workspace-git-browser-route.js +60 -0
- package/dist/workspace-git-browser.js +71 -0
- package/dist/workspace-git-command.js +63 -0
- package/dist/workspace-git-diff.js +105 -0
- package/dist/workspace-git-history.js +169 -0
- package/dist/workspace-git-route.js +69 -0
- package/dist/workspace-git-security.js +234 -0
- package/dist/workspace-git-status.js +182 -0
- package/dist/workspace-path.js +32 -0
- package/package.json +93 -4
|
@@ -0,0 +1,2659 @@
|
|
|
1
|
+
import { questionIndex, inputQuestionView } from "./console-input-request.js?v=structured-questions-20261016-schedule-recovery-20261020";
|
|
2
|
+
import {
|
|
3
|
+
messageContextSignature,
|
|
4
|
+
normalizeMessageAttachments,
|
|
5
|
+
normalizeMessageWorkspaceFileRefs,
|
|
6
|
+
} from "./console-session-message-context.js?v=console-information-architecture-20260921-default-model-20261007-console-workspace-git-20261008-console-file-download-20261008-console-runtime-config-20261009-extension-source-i18n-20261010-mcp-oauth-20261014-structured-questions-20261016-claude-user-extensions-20261016-dsh-token-20261016-gateway-space-update-20261019-schedule-provider-20261020-ilink-provider-20261020-schedule-recovery-20261020-ilink-onboarding-20261020-console-hierarchy-20261020-console-interactions-20261020-console-image-feedback-20261020-assistant-search-20261021-pi-direct-steer-20261028-pi-levels-20261028-create-draft-20261029-context-create-20261029-file-drawer-20261029-agent-metrics-20261102-antigravity-20261121";
|
|
7
|
+
import { normalizeAssistantContentBlocks } from "./console-inline-visualization.js";
|
|
8
|
+
import { antigravityEventView } from "./console-antigravity-events.js?v=process-plan-20261127-deveco-code-20261127";
|
|
9
|
+
|
|
10
|
+
import { contextCompactionView, compactionAdvisoryView, isCompactionAdvisory } from "./console-context-compaction.js";
|
|
11
|
+
import {
|
|
12
|
+
isAssistantSession,
|
|
13
|
+
sessionGroupKey,
|
|
14
|
+
sessionGroupTitle,
|
|
15
|
+
} from "./console-session-type.js?v=console-information-architecture-20260921-default-model-20261007-console-workspace-git-20261008-console-file-download-20261008-console-runtime-config-20261009-extension-source-i18n-20261010-mcp-oauth-20261014-structured-questions-20261016-claude-user-extensions-20261016-dsh-token-20261016-console-whitespace-20261019-gateway-space-update-20261019-schedule-provider-20261020-ilink-provider-20261020-schedule-recovery-20261020-ilink-onboarding-20261020-console-hierarchy-20261020-console-interactions-20261020-console-image-feedback-20261020-assistant-search-20261021-pi-direct-steer-20261028-pi-levels-20261028-create-draft-20261029-context-create-20261029-file-drawer-20261029-agent-metrics-20261102-antigravity-20261121";
|
|
16
|
+
import {
|
|
17
|
+
applyScheduleDraftUpdate,
|
|
18
|
+
scheduleDraftSearchTerms,
|
|
19
|
+
scheduleDraftViewFromEvent,
|
|
20
|
+
} from "./console-schedule-drafts.js?v=console-information-architecture-20260921-default-model-20261007-console-workspace-git-20261008-console-file-download-20261008-console-runtime-config-20261009-extension-source-i18n-20261010-mcp-oauth-20261014-structured-questions-20261016-claude-user-extensions-20261016-dsh-token-20261016-gateway-space-update-20261019-schedule-provider-20261020-ilink-provider-20261020-provider-dialog-system-channels-20261020-schedule-recovery-20261020-ilink-onboarding-20261020-console-hierarchy-20261020-console-interactions-20261020-console-image-feedback-20261020-assistant-search-20261021-pi-direct-steer-20261028-pi-levels-20261028-create-draft-20261029-context-create-20261029-file-drawer-20261029-agent-metrics-20261102-provider-select-20261105-antigravity-20261121";
|
|
21
|
+
import {
|
|
22
|
+
scheduleRunResultSearchTerms,
|
|
23
|
+
scheduleRunResultViewFromEvent,
|
|
24
|
+
} from "./console-schedule-run-results.js?v=console-information-architecture-20260921-default-model-20261007-console-workspace-git-20261008-console-file-download-20261008-console-runtime-config-20261009-extension-source-i18n-20261010-mcp-oauth-20261014-structured-questions-20261016-claude-user-extensions-20261016-dsh-token-20261016-gateway-space-update-20261019-schedule-provider-20261020-ilink-provider-20261020-schedule-recovery-20261020-ilink-onboarding-20261020-console-hierarchy-20261020-console-interactions-20261020-console-image-feedback-20261020-assistant-search-20261021-pi-direct-steer-20261028-pi-levels-20261028-create-draft-20261029-context-create-20261029-file-drawer-20261029-agent-metrics-20261102-antigravity-20261121";
|
|
25
|
+
import { getConsoleLocale, tf } from "./console-i18n.js?v=console-model-capabilities-20261006-provider-insights-20261007-default-model-20261007-console-workspace-git-20261008-console-file-download-20261008-console-runtime-config-20261009-extension-source-i18n-20261010-mcp-oauth-20261014-structured-questions-20261016-claude-user-extensions-20261016-dsh-token-20261016-gateway-space-update-20261019-schedule-provider-20261020-ilink-provider-20261020-schedule-recovery-20261020-ilink-onboarding-20261020-console-hierarchy-20261020-console-interactions-20261020-console-image-feedback-20261020-assistant-search-20261021-pi-direct-steer-20261028-pi-levels-20261028-create-draft-20261029-context-create-20261029-file-drawer-20261029-agent-metrics-20261102-antigravity-20261121";
|
|
26
|
+
import {
|
|
27
|
+
agentTimelineCoveredTurnIds,
|
|
28
|
+
agentTimelineViews,
|
|
29
|
+
hasAgentTimelineEntries,
|
|
30
|
+
} from "./console-agent-timeline.js?v=console-agent-timeline-20260907-schedule-recovery-20261020-app-event-policy-20261021-process-tones-20261030-agent-launch-20261102";
|
|
31
|
+
|
|
32
|
+
import { structuredEventFields } from "./console-agent-tool-detail.js?v=app-event-policy-20261021-process-tones-20261030";
|
|
33
|
+
import { claudeToolView } from "./console-claude-tool-detail.js?v=claude-details-20261028-process-tones-20261030-agent-launch-20261102";
|
|
34
|
+
|
|
35
|
+
export const UI_TIME_ZONE = "Asia/Shanghai";
|
|
36
|
+
|
|
37
|
+
export function isSessionLocalFileHref(hrefValue, workspacePathValue) {
|
|
38
|
+
let href = String(hrefValue || "").trim();
|
|
39
|
+
const workspacePath = String(workspacePathValue || "").trim();
|
|
40
|
+
if (!href || !workspacePath || href.startsWith("#") || href.startsWith("?")) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
href = decodeURIComponent(href);
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (/^file:\/\//i.test(href)) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const windowsHref = /^[A-Za-z]:[\\/]/.test(href);
|
|
53
|
+
const relativeLocationHref = /^[^/\\]+\.[A-Za-z\d][A-Za-z\d._-]*:\d+(?::\d+)?$/i.test(href);
|
|
54
|
+
const scheme = href.match(/^([A-Za-z][A-Za-z\d+.-]*):/);
|
|
55
|
+
if (scheme && !windowsHref && !relativeLocationHref) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const windowsWorkspace = /^[A-Za-z]:[\\/]/.test(workspacePath);
|
|
60
|
+
if (windowsHref || windowsWorkspace) {
|
|
61
|
+
if (!windowsHref || !windowsWorkspace) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const normalizedHref = href.replaceAll("/", "\\").toLowerCase();
|
|
65
|
+
const normalizedWorkspace = workspacePath.replaceAll("/", "\\").replace(/\\+$/, "").toLowerCase();
|
|
66
|
+
return normalizedHref === normalizedWorkspace
|
|
67
|
+
|| normalizedHref.startsWith(`${normalizedWorkspace}\\`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (href.startsWith("/")) {
|
|
71
|
+
const normalizedWorkspace = workspacePath.replace(/\/+$/, "");
|
|
72
|
+
return href === normalizedWorkspace || href.startsWith(`${normalizedWorkspace}/`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return href.startsWith("./")
|
|
76
|
+
|| href.includes("/")
|
|
77
|
+
|| href.includes("\\")
|
|
78
|
+
|| /(^|\/)[^/]+\.[A-Za-z\d][A-Za-z\d._-]*(?::\d+(?::\d+)?)?(?:#L\d+(?:C\d+)?)?$/i.test(href);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function storageValue(storage, key, fallback = "") {
|
|
82
|
+
try {
|
|
83
|
+
return storage?.getItem?.(key) || fallback;
|
|
84
|
+
} catch {
|
|
85
|
+
return fallback;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function setStorageValue(storage, key, value) {
|
|
90
|
+
try {
|
|
91
|
+
storage?.setItem?.(key, value);
|
|
92
|
+
} catch {
|
|
93
|
+
// 测试 VM 或隐私模式可能没有可用 storage,主题和视图状态允许降级为内存态。
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function removeStorageValue(storage, key) {
|
|
98
|
+
try {
|
|
99
|
+
storage?.removeItem?.(key);
|
|
100
|
+
} catch {
|
|
101
|
+
// 同上,清理失败不影响当前页面状态。
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function formatNumber(value) {
|
|
106
|
+
const number = Number(value || 0);
|
|
107
|
+
if (!Number.isFinite(number)) {
|
|
108
|
+
return "0";
|
|
109
|
+
}
|
|
110
|
+
if (number >= 100000000) {
|
|
111
|
+
return `${Math.round(number / 1000000)}M`;
|
|
112
|
+
}
|
|
113
|
+
if (number >= 1000000) {
|
|
114
|
+
return `${(number / 1000000).toFixed(1).replace(".0", "")}M`;
|
|
115
|
+
}
|
|
116
|
+
if (number >= 1000) {
|
|
117
|
+
return `${Math.round(number / 1000)}K`;
|
|
118
|
+
}
|
|
119
|
+
return String(Math.round(number));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function formatTokenCount(value) {
|
|
123
|
+
const number = Math.max(0, Number(value || 0));
|
|
124
|
+
if (!Number.isFinite(number)) {
|
|
125
|
+
return "0";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const units = [
|
|
129
|
+
[1, ""],
|
|
130
|
+
[1_000, "K"],
|
|
131
|
+
[1_000_000, "M"],
|
|
132
|
+
[1_000_000_000, "B"],
|
|
133
|
+
];
|
|
134
|
+
let unitIndex = number >= 1_000_000_000
|
|
135
|
+
? 3
|
|
136
|
+
: number >= 1_000_000
|
|
137
|
+
? 2
|
|
138
|
+
: number >= 1_000
|
|
139
|
+
? 1
|
|
140
|
+
: 0;
|
|
141
|
+
while (unitIndex < units.length) {
|
|
142
|
+
const [divisor, suffix] = units[unitIndex];
|
|
143
|
+
const scaledNumber = Number((number / divisor).toFixed(2));
|
|
144
|
+
// 四舍五入越过 1000 时主动升级单位,避免出现 1000K、1000M。
|
|
145
|
+
if (scaledNumber < 1_000 || unitIndex === units.length - 1) {
|
|
146
|
+
const scaled = scaledNumber
|
|
147
|
+
.toFixed(2)
|
|
148
|
+
.replace(/\.0+$/, "")
|
|
149
|
+
.replace(/(\.\d*[1-9])0+$/, "$1");
|
|
150
|
+
return `${scaled}${suffix}`;
|
|
151
|
+
}
|
|
152
|
+
unitIndex += 1;
|
|
153
|
+
}
|
|
154
|
+
return "0";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function formatFullNumber(value) {
|
|
158
|
+
const number = Number(value || 0);
|
|
159
|
+
if (!Number.isFinite(number)) {
|
|
160
|
+
return "0";
|
|
161
|
+
}
|
|
162
|
+
return new Intl.NumberFormat("en-US", {
|
|
163
|
+
maximumFractionDigits: 0,
|
|
164
|
+
}).format(Math.round(number));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function readInt(value) {
|
|
168
|
+
const number = Number(value || 0);
|
|
169
|
+
return Number.isFinite(number) ? Math.max(0, Math.trunc(number)) : 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function contextWindowUsagePercent(usedTokens, modelContextWindow) {
|
|
173
|
+
const used = readInt(usedTokens);
|
|
174
|
+
const windowSize = readInt(modelContextWindow);
|
|
175
|
+
if (used <= 0 || windowSize <= 0) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return Math.min(100, Math.round((used * 100) / windowSize));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function sessionTokenTotalsById({
|
|
182
|
+
sessions = [],
|
|
183
|
+
summarySessions = [],
|
|
184
|
+
rankedSessions = [],
|
|
185
|
+
sessionTabs = new Map(),
|
|
186
|
+
} = {}) {
|
|
187
|
+
const totals = new Map();
|
|
188
|
+
const applyRows = (rows) => {
|
|
189
|
+
for (const row of rows) {
|
|
190
|
+
const id = typeof row?.id === "string" ? row.id : typeof row?.key === "string" ? row.key : "";
|
|
191
|
+
if (!id) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const total = row.tokenTotal ?? row.totalTokens;
|
|
195
|
+
if (total === undefined || total === null) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
totals.set(id, readInt(total));
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
applyRows(rankedSessions);
|
|
203
|
+
applyRows(sessions);
|
|
204
|
+
applyRows(summarySessions);
|
|
205
|
+
// 已加载 Tab 的快照最新,但它必须按会话 ID 覆盖,不能依赖当前选中态。
|
|
206
|
+
for (const [sessionId, tab] of sessionTabs) {
|
|
207
|
+
if (typeof sessionId === "string" && tab?.tokenUsage) {
|
|
208
|
+
totals.set(sessionId, readInt(tab.tokenUsage.totalTokens));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return totals;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function emptyTokenUsage(updatedAt = "") {
|
|
215
|
+
return {
|
|
216
|
+
totalTokens: 0,
|
|
217
|
+
totalInputTokens: 0,
|
|
218
|
+
totalCachedInputTokens: 0,
|
|
219
|
+
totalOutputTokens: 0,
|
|
220
|
+
totalReasoningOutputTokens: 0,
|
|
221
|
+
lastTokens: 0,
|
|
222
|
+
lastInputTokens: 0,
|
|
223
|
+
lastCachedInputTokens: 0,
|
|
224
|
+
lastOutputTokens: 0,
|
|
225
|
+
lastReasoningOutputTokens: 0,
|
|
226
|
+
lastEventTokens: 0,
|
|
227
|
+
modelContextWindow: 0,
|
|
228
|
+
updatedAt,
|
|
229
|
+
turnId: "",
|
|
230
|
+
isDeltaMode: false,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function normalizeTokenUsage(value) {
|
|
235
|
+
if (!value || typeof value !== "object") {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
...emptyTokenUsage(String(value.updatedAt || "")),
|
|
240
|
+
totalTokens: readInt(value.totalTokens),
|
|
241
|
+
totalInputTokens: readInt(value.totalInputTokens),
|
|
242
|
+
totalCachedInputTokens: readInt(value.totalCachedInputTokens),
|
|
243
|
+
totalOutputTokens: readInt(value.totalOutputTokens),
|
|
244
|
+
totalReasoningOutputTokens: readInt(value.totalReasoningOutputTokens),
|
|
245
|
+
lastTokens: readInt(value.lastTokens),
|
|
246
|
+
lastInputTokens: readInt(value.lastInputTokens),
|
|
247
|
+
lastCachedInputTokens: readInt(value.lastCachedInputTokens),
|
|
248
|
+
lastOutputTokens: readInt(value.lastOutputTokens),
|
|
249
|
+
lastReasoningOutputTokens: readInt(value.lastReasoningOutputTokens),
|
|
250
|
+
lastEventTokens: readInt(value.lastEventTokens),
|
|
251
|
+
modelContextWindow: readInt(value.modelContextWindow),
|
|
252
|
+
turnId: value.turnId ? String(value.turnId) : "",
|
|
253
|
+
isDeltaMode: value.isDeltaMode === true,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export function tokenBlockFromEvent(value) {
|
|
258
|
+
return {
|
|
259
|
+
totalTokens: readInt(value?.totalTokens),
|
|
260
|
+
inputTokens: readInt(value?.inputTokens),
|
|
261
|
+
cachedInputTokens: readInt(value?.cachedInputTokens),
|
|
262
|
+
outputTokens: readInt(value?.outputTokens),
|
|
263
|
+
reasoningOutputTokens: readInt(value?.reasoningOutputTokens),
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function sumTokenBlocks(blocks) {
|
|
268
|
+
return blocks.reduce((sum, block) => ({
|
|
269
|
+
totalTokens: sum.totalTokens + readInt(block.totalTokens),
|
|
270
|
+
inputTokens: sum.inputTokens + readInt(block.inputTokens),
|
|
271
|
+
cachedInputTokens: sum.cachedInputTokens + readInt(block.cachedInputTokens),
|
|
272
|
+
outputTokens: sum.outputTokens + readInt(block.outputTokens),
|
|
273
|
+
reasoningOutputTokens: sum.reasoningOutputTokens + readInt(block.reasoningOutputTokens),
|
|
274
|
+
}), tokenBlockFromEvent({}));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function subtractTokenBlocks(left, right) {
|
|
278
|
+
return {
|
|
279
|
+
totalTokens: Math.max(0, readInt(left.totalTokens) - readInt(right.totalTokens)),
|
|
280
|
+
inputTokens: Math.max(0, readInt(left.inputTokens) - readInt(right.inputTokens)),
|
|
281
|
+
cachedInputTokens: Math.max(0, readInt(left.cachedInputTokens) - readInt(right.cachedInputTokens)),
|
|
282
|
+
outputTokens: Math.max(0, readInt(left.outputTokens) - readInt(right.outputTokens)),
|
|
283
|
+
reasoningOutputTokens: Math.max(0, readInt(left.reasoningOutputTokens) - readInt(right.reasoningOutputTokens)),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export function snapshotTotalBlock(usage) {
|
|
288
|
+
return tokenBlockFromEvent({
|
|
289
|
+
totalTokens: usage?.totalTokens,
|
|
290
|
+
inputTokens: usage?.totalInputTokens,
|
|
291
|
+
cachedInputTokens: usage?.totalCachedInputTokens,
|
|
292
|
+
outputTokens: usage?.totalOutputTokens,
|
|
293
|
+
reasoningOutputTokens: usage?.totalReasoningOutputTokens,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function snapshotLastBlock(usage) {
|
|
298
|
+
return tokenBlockFromEvent({
|
|
299
|
+
totalTokens: usage?.lastTokens,
|
|
300
|
+
inputTokens: usage?.lastInputTokens,
|
|
301
|
+
cachedInputTokens: usage?.lastCachedInputTokens,
|
|
302
|
+
outputTokens: usage?.lastOutputTokens,
|
|
303
|
+
reasoningOutputTokens: usage?.lastReasoningOutputTokens,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export function usageFromBlocks(source, total, last) {
|
|
308
|
+
return {
|
|
309
|
+
...emptyTokenUsage(source.updatedAt),
|
|
310
|
+
totalTokens: total.totalTokens,
|
|
311
|
+
totalInputTokens: total.inputTokens,
|
|
312
|
+
totalCachedInputTokens: total.cachedInputTokens,
|
|
313
|
+
totalOutputTokens: total.outputTokens,
|
|
314
|
+
totalReasoningOutputTokens: total.reasoningOutputTokens,
|
|
315
|
+
lastTokens: last.totalTokens,
|
|
316
|
+
lastInputTokens: last.inputTokens,
|
|
317
|
+
lastCachedInputTokens: last.cachedInputTokens,
|
|
318
|
+
lastOutputTokens: last.outputTokens,
|
|
319
|
+
lastReasoningOutputTokens: last.reasoningOutputTokens,
|
|
320
|
+
lastEventTokens: source.contextUsedTokens ?? source.last.totalTokens,
|
|
321
|
+
modelContextWindow: source.modelContextWindow,
|
|
322
|
+
updatedAt: source.updatedAt,
|
|
323
|
+
turnId: source.turnId,
|
|
324
|
+
isDeltaMode: source.isDeltaMode,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export function tokenUsageFromMessage(message) {
|
|
329
|
+
const payload = message?.payload || {};
|
|
330
|
+
const contextOnly = payload.eventType === "thread/contextUsage/updated";
|
|
331
|
+
if (message?.type !== "session-output" || (!contextOnly && payload.eventType !== "thread/tokenUsage/updated")) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
const jsonPayload = payload.jsonPayload || {};
|
|
335
|
+
if (contextOnly) {
|
|
336
|
+
const context = jsonPayload.contextUsage;
|
|
337
|
+
if (!context || typeof context !== "object") return null;
|
|
338
|
+
return { contextOnly: true, contextUsedTokens: readInt(context.usedTokens),
|
|
339
|
+
modelContextWindow: readInt(context.modelContextWindow), updatedAt: message.timestamp || "" };
|
|
340
|
+
}
|
|
341
|
+
const tokenUsage = jsonPayload.tokenUsage || {};
|
|
342
|
+
if (!tokenUsage || typeof tokenUsage !== "object") {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
const sourceProvider = typeof jsonPayload.sourceProvider === "string" ? jsonPayload.sourceProvider : "";
|
|
346
|
+
const isAcpProvider = sourceProvider === "antigravity" || sourceProvider === "deveco-code";
|
|
347
|
+
const hasTurnUsage = Boolean(tokenUsage.turnUsage && typeof tokenUsage.turnUsage === "object");
|
|
348
|
+
const total = tokenBlockFromEvent(tokenUsage.total || {});
|
|
349
|
+
const eventLast = tokenBlockFromEvent(tokenUsage.last || {});
|
|
350
|
+
const last = tokenBlockFromEvent(tokenUsage.turnUsage || tokenUsage.last || {});
|
|
351
|
+
const modelContextWindow = readInt(tokenUsage.modelContextWindow);
|
|
352
|
+
// 旧版 ACP 事件把整轮累计直接复制到了 last,回放历史时不能覆盖先前的上下文占用。
|
|
353
|
+
const legacyAcpLast = isAcpProvider && hasTurnUsage
|
|
354
|
+
&& eventLast.totalTokens === last.totalTokens
|
|
355
|
+
&& eventLast.inputTokens === last.inputTokens
|
|
356
|
+
&& (eventLast.outputTokens > 0 || eventLast.cachedInputTokens > 0 || eventLast.reasoningOutputTokens > 0
|
|
357
|
+
|| (modelContextWindow > 0 && eventLast.totalTokens > modelContextWindow));
|
|
358
|
+
return {
|
|
359
|
+
total,
|
|
360
|
+
last,
|
|
361
|
+
contextUsedTokens: legacyAcpLast ? 0 : eventLast.totalTokens,
|
|
362
|
+
preserveLastEventTokens: legacyAcpLast,
|
|
363
|
+
modelContextWindow,
|
|
364
|
+
updatedAt: message.timestamp || new Date().toISOString(),
|
|
365
|
+
turnId: jsonPayload.turnId ? String(jsonPayload.turnId) : "",
|
|
366
|
+
isDeltaMode: tokenUsage.mode === "delta",
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export function mergeTokenUsage(previous, eventUsage) {
|
|
371
|
+
if (!eventUsage) {
|
|
372
|
+
return previous || null;
|
|
373
|
+
}
|
|
374
|
+
const existing = normalizeTokenUsage(previous);
|
|
375
|
+
if (eventUsage.contextOnly) {
|
|
376
|
+
// 压缩只改变当前占用,不进入账本,也不覆盖“本轮”统计。
|
|
377
|
+
return { ...(existing || emptyTokenUsage()), lastEventTokens: eventUsage.contextUsedTokens,
|
|
378
|
+
modelContextWindow: eventUsage.modelContextWindow, updatedAt: eventUsage.updatedAt };
|
|
379
|
+
}
|
|
380
|
+
if (eventUsage.isDeltaMode) {
|
|
381
|
+
const total = sumTokenBlocks([snapshotTotalBlock(existing), eventUsage.total]);
|
|
382
|
+
const sameTurn = existing?.isDeltaMode && existing.turnId && existing.turnId === eventUsage.turnId;
|
|
383
|
+
const last = sameTurn ? sumTokenBlocks([snapshotLastBlock(existing), eventUsage.last]) : eventUsage.last;
|
|
384
|
+
const next = usageFromBlocks(eventUsage, total, last);
|
|
385
|
+
if (eventUsage.preserveLastEventTokens) {
|
|
386
|
+
next.lastEventTokens = existing?.lastEventTokens ?? 0;
|
|
387
|
+
if (!next.modelContextWindow && existing?.modelContextWindow) {
|
|
388
|
+
next.modelContextWindow = existing.modelContextWindow;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return next;
|
|
392
|
+
}
|
|
393
|
+
if (!existing || !eventUsage.turnId) {
|
|
394
|
+
return usageFromBlocks(eventUsage, eventUsage.total, eventUsage.last);
|
|
395
|
+
}
|
|
396
|
+
if (existing.turnId === eventUsage.turnId) {
|
|
397
|
+
const baseline = subtractTokenBlocks(snapshotTotalBlock(existing), snapshotLastBlock(existing));
|
|
398
|
+
return usageFromBlocks(eventUsage, eventUsage.total, subtractTokenBlocks(eventUsage.total, baseline));
|
|
399
|
+
}
|
|
400
|
+
const last = subtractTokenBlocks(eventUsage.total, snapshotTotalBlock(existing));
|
|
401
|
+
const hasLast = Object.values(last).some((value) => value > 0);
|
|
402
|
+
return usageFromBlocks(eventUsage, eventUsage.total, hasLast ? last : eventUsage.last);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export function tokenUsageFromEvents(entries) {
|
|
406
|
+
return [...(entries || [])]
|
|
407
|
+
.map((entry) => entry?.message || entry)
|
|
408
|
+
.filter(Boolean)
|
|
409
|
+
.sort((left, right) => String(left.timestamp || "").localeCompare(String(right.timestamp || "")))
|
|
410
|
+
.reduce((usage, message) => mergeTokenUsage(usage, tokenUsageFromMessage(message)), null);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export function tokenUsageSummaryText(usage) {
|
|
414
|
+
const normalized = normalizeTokenUsage(usage);
|
|
415
|
+
if (!normalized) {
|
|
416
|
+
return tf("本轮 {last} · 总 {total}", { last: 0, total: 0 });
|
|
417
|
+
}
|
|
418
|
+
return tf("本轮 {last} · 总 {total}", {
|
|
419
|
+
last: formatTokenCount(normalized.lastTokens),
|
|
420
|
+
total: formatTokenCount(normalized.totalTokens),
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export function formatDateTime(value) {
|
|
425
|
+
if (!value) {
|
|
426
|
+
return "--";
|
|
427
|
+
}
|
|
428
|
+
const date = new Date(value);
|
|
429
|
+
if (Number.isNaN(date.getTime())) {
|
|
430
|
+
return "--";
|
|
431
|
+
}
|
|
432
|
+
return date.toLocaleString(getConsoleLocale() === "en" ? "en-US" : "zh-CN", {
|
|
433
|
+
timeZone: UI_TIME_ZONE,
|
|
434
|
+
month: "2-digit",
|
|
435
|
+
day: "2-digit",
|
|
436
|
+
hour: "2-digit",
|
|
437
|
+
minute: "2-digit",
|
|
438
|
+
hour12: false,
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export function formatHourLabel(value) {
|
|
443
|
+
if (!value) {
|
|
444
|
+
return "--";
|
|
445
|
+
}
|
|
446
|
+
const date = new Date(value);
|
|
447
|
+
if (Number.isNaN(date.getTime())) {
|
|
448
|
+
return "--";
|
|
449
|
+
}
|
|
450
|
+
return date.toLocaleString(getConsoleLocale() === "en" ? "en-US" : "zh-CN", {
|
|
451
|
+
timeZone: UI_TIME_ZONE,
|
|
452
|
+
hour: "2-digit",
|
|
453
|
+
minute: "2-digit",
|
|
454
|
+
hour12: false,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export function formatMoneyFromTokens(tokens) {
|
|
459
|
+
const value = (Number(tokens || 0) / 1000000) * 0.86;
|
|
460
|
+
return `$${value.toFixed(value >= 100 ? 0 : 2)}`;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export function text(value, fallback = "--") {
|
|
464
|
+
if (value === undefined || value === null || value === "") {
|
|
465
|
+
return fallback;
|
|
466
|
+
}
|
|
467
|
+
return String(value);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export function clearNode(node) {
|
|
471
|
+
node.replaceChildren();
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export function el(tag, className, content) {
|
|
475
|
+
const node = document.createElement(tag);
|
|
476
|
+
if (className) {
|
|
477
|
+
node.className = className;
|
|
478
|
+
}
|
|
479
|
+
if (content !== undefined) {
|
|
480
|
+
node.textContent = content;
|
|
481
|
+
}
|
|
482
|
+
return node;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export function tag(label, tone = "") {
|
|
486
|
+
return el("span", `tag${tone ? ` ${tone}` : ""}`, label);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export function emptyState(message) {
|
|
490
|
+
return el("div", "empty-state", message);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export function workspaceTail(path) {
|
|
494
|
+
if (!path) {
|
|
495
|
+
return "未记录工作区";
|
|
496
|
+
}
|
|
497
|
+
return String(path).split(/[\\/]/).filter(Boolean).at(-1) || path;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function normalizeImportableWorkspacePath(path) {
|
|
501
|
+
const normalized = String(path || "").trim();
|
|
502
|
+
if (normalized === "/" || /^[A-Za-z]:[\\/]$/.test(normalized)) {
|
|
503
|
+
return normalized;
|
|
504
|
+
}
|
|
505
|
+
return normalized.replace(/[\\/]+$/, "");
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
export function importableWorkspacePathDisplay(path) {
|
|
509
|
+
const normalized = normalizeImportableWorkspacePath(path);
|
|
510
|
+
if (!normalized) {
|
|
511
|
+
return "未指定目录";
|
|
512
|
+
}
|
|
513
|
+
return normalized;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export function importableThreadKey(thread) {
|
|
517
|
+
const provider = String(thread?.provider || "codex").trim() || "codex";
|
|
518
|
+
return `${provider}:${String(thread?.id || "").trim()}`;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export async function runWithConcurrency(items, limit, worker) {
|
|
522
|
+
const entries = Array.isArray(items) ? items : [];
|
|
523
|
+
if (entries.length === 0) {
|
|
524
|
+
return [];
|
|
525
|
+
}
|
|
526
|
+
const concurrency = Math.min(
|
|
527
|
+
entries.length,
|
|
528
|
+
Math.max(1, Math.floor(Number(limit) || 1)),
|
|
529
|
+
);
|
|
530
|
+
const results = new Array(entries.length);
|
|
531
|
+
let nextIndex = 0;
|
|
532
|
+
|
|
533
|
+
// JavaScript 同步分配下标,多个异步 worker 不会领取同一条任务。
|
|
534
|
+
await Promise.all(Array.from({ length: concurrency }, async () => {
|
|
535
|
+
while (nextIndex < entries.length) {
|
|
536
|
+
const index = nextIndex;
|
|
537
|
+
nextIndex += 1;
|
|
538
|
+
results[index] = await worker(entries[index], index);
|
|
539
|
+
}
|
|
540
|
+
}));
|
|
541
|
+
return results;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export function importableThreadGroups(payload, groupLimit = Infinity, perGroupLimit = Infinity) {
|
|
545
|
+
// 数据保持完整;展开面板按批次渲染,避免用数据截断控制 DOM 数量。
|
|
546
|
+
const safeGroupLimit = Math.max(1, Number(groupLimit) || Infinity);
|
|
547
|
+
const safePerGroupLimit = Math.max(1, Number(perGroupLimit) || Infinity);
|
|
548
|
+
if (Array.isArray(payload?.groups)) {
|
|
549
|
+
return payload.groups
|
|
550
|
+
.slice(0, safeGroupLimit)
|
|
551
|
+
.map((group) => {
|
|
552
|
+
const threads = Array.isArray(group?.threads)
|
|
553
|
+
? group.threads.slice(0, safePerGroupLimit)
|
|
554
|
+
: [];
|
|
555
|
+
return {
|
|
556
|
+
workspacePath: normalizeImportableWorkspacePath(group?.workspacePath),
|
|
557
|
+
updatedAt: String(group?.updatedAt || threads[0]?.updatedAt || ""),
|
|
558
|
+
totalCount: Math.max(threads.length, Number(group?.totalCount) || 0),
|
|
559
|
+
truncated: Boolean(group?.truncated) || Number(group?.totalCount) > threads.length,
|
|
560
|
+
threads,
|
|
561
|
+
};
|
|
562
|
+
})
|
|
563
|
+
.filter((group) => group.threads.length > 0);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
const grouped = new Map();
|
|
567
|
+
for (const thread of Array.isArray(payload?.threads) ? payload.threads : []) {
|
|
568
|
+
const workspacePath = normalizeImportableWorkspacePath(thread?.workspacePath);
|
|
569
|
+
const items = grouped.get(workspacePath) || [];
|
|
570
|
+
items.push(thread);
|
|
571
|
+
grouped.set(workspacePath, items);
|
|
572
|
+
}
|
|
573
|
+
return [...grouped.entries()]
|
|
574
|
+
.map(([workspacePath, items]) => {
|
|
575
|
+
const sorted = [...items].sort((left, right) =>
|
|
576
|
+
String(right?.updatedAt || right?.createdAt || "")
|
|
577
|
+
.localeCompare(String(left?.updatedAt || left?.createdAt || ""))
|
|
578
|
+
);
|
|
579
|
+
return {
|
|
580
|
+
workspacePath,
|
|
581
|
+
updatedAt: String(sorted[0]?.updatedAt || sorted[0]?.createdAt || ""),
|
|
582
|
+
totalCount: sorted.length,
|
|
583
|
+
truncated: sorted.length > safePerGroupLimit,
|
|
584
|
+
threads: sorted.slice(0, safePerGroupLimit),
|
|
585
|
+
};
|
|
586
|
+
})
|
|
587
|
+
.sort((left, right) => right.updatedAt.localeCompare(left.updatedAt))
|
|
588
|
+
.slice(0, safeGroupLimit);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
export function workspaceGroupPreferenceKey(workspacePath) {
|
|
592
|
+
const normalized = String(workspacePath || "").trim();
|
|
593
|
+
return normalized || "__unset_workspace__";
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
export function workspaceGroupTitle(workspacePath) {
|
|
597
|
+
const normalized = String(workspacePath || "").trim();
|
|
598
|
+
if (!normalized) {
|
|
599
|
+
return "未设置目录";
|
|
600
|
+
}
|
|
601
|
+
return workspaceTail(normalized);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export function sessionActivityTime(session) {
|
|
605
|
+
const time = new Date(session?.lastUpdatedAt || session?.updatedAt || session?.createdAt || 0).getTime();
|
|
606
|
+
return Number.isFinite(time) ? time : 0;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export function sessionGroupPriority(session) {
|
|
610
|
+
if (session?.status === "waiting-approval") {
|
|
611
|
+
return 3;
|
|
612
|
+
}
|
|
613
|
+
if (session?.status === "running" || session?.status === "starting") {
|
|
614
|
+
return 2;
|
|
615
|
+
}
|
|
616
|
+
if (session?.canResume === true) {
|
|
617
|
+
return 1;
|
|
618
|
+
}
|
|
619
|
+
return 0;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export function loadSessionGroupPreferenceSet(storage, key) {
|
|
623
|
+
const raw = storageValue(storage, key, "[]");
|
|
624
|
+
try {
|
|
625
|
+
const values = JSON.parse(raw);
|
|
626
|
+
if (!Array.isArray(values)) {
|
|
627
|
+
return new Set();
|
|
628
|
+
}
|
|
629
|
+
return new Set(values.map((value) => String(value || "").trim()).filter(Boolean));
|
|
630
|
+
} catch {
|
|
631
|
+
return new Set();
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
export function saveSessionGroupPreferenceSet(storage, key, values) {
|
|
636
|
+
setStorageValue(storage, key, JSON.stringify([...values].filter(Boolean)));
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export function sessionDisplayTitle(session) {
|
|
640
|
+
return String(
|
|
641
|
+
session?.displayName
|
|
642
|
+
|| session?.latestPrompt
|
|
643
|
+
|| session?.title
|
|
644
|
+
|| session?.prompt
|
|
645
|
+
|| session?.id
|
|
646
|
+
|| "未命名会话",
|
|
647
|
+
).trim();
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export function sessionDisplaySubtitle(session) {
|
|
651
|
+
const title = sessionDisplayTitle(session);
|
|
652
|
+
const candidates = [
|
|
653
|
+
session?.title,
|
|
654
|
+
session?.prompt,
|
|
655
|
+
session?.latestPrompt,
|
|
656
|
+
isAssistantSession(session) ? "" : session?.workspacePath,
|
|
657
|
+
];
|
|
658
|
+
const subtitle = candidates
|
|
659
|
+
.map((value) => String(value || "").trim())
|
|
660
|
+
.find((value) => value && value !== title);
|
|
661
|
+
return subtitle || (isAssistantSession(session) ? "" : session?.workspacePath) || "";
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function sessionPinnedTime(session) {
|
|
665
|
+
const value = new Date(session?.pinnedAt || 0).getTime();
|
|
666
|
+
return Number.isFinite(value) ? value : 0;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
export function compareConsoleSessions(left, right) {
|
|
670
|
+
const pinCompare = Number(Boolean(right?.pinnedAt)) - Number(Boolean(left?.pinnedAt));
|
|
671
|
+
if (pinCompare !== 0) {
|
|
672
|
+
return pinCompare;
|
|
673
|
+
}
|
|
674
|
+
if (left?.pinnedAt && right?.pinnedAt) {
|
|
675
|
+
const pinnedAtCompare = sessionPinnedTime(right) - sessionPinnedTime(left);
|
|
676
|
+
if (pinnedAtCompare !== 0) {
|
|
677
|
+
return pinnedAtCompare;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
const priorityCompare = sessionGroupPriority(right) - sessionGroupPriority(left);
|
|
681
|
+
if (priorityCompare !== 0) {
|
|
682
|
+
return priorityCompare;
|
|
683
|
+
}
|
|
684
|
+
return sessionActivityTime(right) - sessionActivityTime(left);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
export function workspaceSessionGroups(sessions, options = {}) {
|
|
688
|
+
const expandedSessionGroups = options.expandedSessionGroups || new Set();
|
|
689
|
+
const collapsedSessionGroups = options.collapsedSessionGroups || new Set();
|
|
690
|
+
const selectedSessionId = options.selectedSessionId || "";
|
|
691
|
+
const buckets = new Map();
|
|
692
|
+
for (const session of sessions || []) {
|
|
693
|
+
const assistant = isAssistantSession(session);
|
|
694
|
+
const workspacePath = assistant
|
|
695
|
+
? ""
|
|
696
|
+
: String(session?.workspacePath || "").trim();
|
|
697
|
+
const key = sessionGroupKey(session);
|
|
698
|
+
if (!buckets.has(key)) {
|
|
699
|
+
buckets.set(key, {
|
|
700
|
+
key,
|
|
701
|
+
workspacePath,
|
|
702
|
+
title: sessionGroupTitle({ key, workspacePath }),
|
|
703
|
+
sessionType: assistant ? "assistant" : "development",
|
|
704
|
+
sessions: [],
|
|
705
|
+
latestActivityAt: 0,
|
|
706
|
+
latestPinnedAt: 0,
|
|
707
|
+
priority: 0,
|
|
708
|
+
count: 0,
|
|
709
|
+
hasActiveSession: false,
|
|
710
|
+
hasRunningSession: false,
|
|
711
|
+
hasPinnedSession: false,
|
|
712
|
+
hasSelectedSession: false,
|
|
713
|
+
expandedPreference: expandedSessionGroups?.has(key) === true,
|
|
714
|
+
collapsedPreference: collapsedSessionGroups?.has(key) === true,
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
const group = buckets.get(key);
|
|
718
|
+
group.sessions.push(session);
|
|
719
|
+
group.latestActivityAt = Math.max(group.latestActivityAt, sessionActivityTime(session));
|
|
720
|
+
group.latestPinnedAt = Math.max(group.latestPinnedAt, sessionPinnedTime(session));
|
|
721
|
+
group.priority = Math.max(group.priority, sessionGroupPriority(session));
|
|
722
|
+
// 主题色只表示真正执行中,等待授权和可继续会话仍由各自状态标识。
|
|
723
|
+
group.hasRunningSession ||= session?.status === "running" || session?.status === "starting";
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
const groups = [...buckets.values()].map((group) => {
|
|
727
|
+
group.sessions.sort(compareConsoleSessions);
|
|
728
|
+
group.count = group.sessions.length;
|
|
729
|
+
group.hasActiveSession = group.priority > 0;
|
|
730
|
+
group.hasPinnedSession = group.latestPinnedAt > 0;
|
|
731
|
+
group.hasSelectedSession = group.sessions.some((session) => session?.id === selectedSessionId);
|
|
732
|
+
return group;
|
|
733
|
+
});
|
|
734
|
+
groups.sort((left, right) => {
|
|
735
|
+
const pinCompare = Number(right.hasPinnedSession) - Number(left.hasPinnedSession);
|
|
736
|
+
if (pinCompare !== 0) {
|
|
737
|
+
return pinCompare;
|
|
738
|
+
}
|
|
739
|
+
if (left.hasPinnedSession && right.hasPinnedSession) {
|
|
740
|
+
const pinnedAtCompare = right.latestPinnedAt - left.latestPinnedAt;
|
|
741
|
+
if (pinnedAtCompare !== 0) {
|
|
742
|
+
return pinnedAtCompare;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
const priorityCompare = right.priority - left.priority;
|
|
746
|
+
if (priorityCompare !== 0) {
|
|
747
|
+
return priorityCompare;
|
|
748
|
+
}
|
|
749
|
+
return right.latestActivityAt - left.latestActivityAt;
|
|
750
|
+
});
|
|
751
|
+
return groups;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
export function isWorkspaceGroupCollapsed(group) {
|
|
755
|
+
if (group?.collapsedPreference) {
|
|
756
|
+
return true;
|
|
757
|
+
}
|
|
758
|
+
if (group?.hasActiveSession || group?.hasSelectedSession || group?.expandedPreference) {
|
|
759
|
+
return false;
|
|
760
|
+
}
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
export function messageTimestamp(message) {
|
|
765
|
+
return formatDateTime(message?.timestamp);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
export function normalizeInlineText(value, maxLength = 56) {
|
|
769
|
+
const normalized = String(value || "").replace(/\s+/g, " ").trim();
|
|
770
|
+
if (normalized.length <= maxLength) {
|
|
771
|
+
return normalized;
|
|
772
|
+
}
|
|
773
|
+
return `${normalized.slice(0, maxLength - 3)}...`;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
export function normalizeCommandText(command) {
|
|
777
|
+
const trimmed = String(command || "").trim();
|
|
778
|
+
if (!trimmed.startsWith("/bin/bash -lc ")) {
|
|
779
|
+
return trimmed;
|
|
780
|
+
}
|
|
781
|
+
const body = trimmed.slice("/bin/bash -lc ".length).trim();
|
|
782
|
+
if ((body.startsWith("'") && body.endsWith("'")) || (body.startsWith("\"") && body.endsWith("\""))) {
|
|
783
|
+
return body.slice(1, -1);
|
|
784
|
+
}
|
|
785
|
+
return body;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
export function commandTag(command) {
|
|
789
|
+
const normalized = normalizeCommandText(command).toLowerCase();
|
|
790
|
+
if (normalized.startsWith("git ")) {
|
|
791
|
+
return "Git";
|
|
792
|
+
}
|
|
793
|
+
if (normalized.startsWith("curl ")) {
|
|
794
|
+
return "Curl";
|
|
795
|
+
}
|
|
796
|
+
return "命令";
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
const SESSION_EVENT_ICON_PATHS = Object.freeze({
|
|
800
|
+
git: ["M6 6h12M6 6v6m0 0h6m-6 0v6m6-6v6m0-6h6m0 0v6"],
|
|
801
|
+
shell: ["m8 9 3 3-3 3", "m13 15h3", "M5 5h14v14H5z"],
|
|
802
|
+
file: ["M6 3h8l4 4v14H6z", "M14 3v5h5"],
|
|
803
|
+
search: ["m11 5a6 6 0 1 0 0 12 6 6 0 0 0 0-12", "m16 16 4 4"],
|
|
804
|
+
reasoning: ["M9 18h6", "M10 21h4", "M8 14a6 6 0 1 1 8 0c-1 1-2 2-2 4h-4c0-2-1-3-2-4Z"],
|
|
805
|
+
subagent: ["M12 5v5", "M6 19v-3h12v3", "M4 19h4", "M16 19h4", "M9 5a3 3 0 1 0 6 0a3 3 0 0 0-6 0"],
|
|
806
|
+
approval: ["M12 3 20 6v5c0 5-3.5 8.5-8 10-4.5-1.5-8-5-8-10V6z", "m8 12 3 3 5-6"],
|
|
807
|
+
warning: ["m12 4 9 16H3z", "M12 9v5", "M12 17h.01"],
|
|
808
|
+
error: ["M12 4a8 8 0 1 0 0 16a8 8 0 0 0 0-16", "m9 9 6 6", "m15 9-6 6"],
|
|
809
|
+
command: ["M5 5h14v14H5z", "m8 9 3 3-3 3", "M13 15h3"],
|
|
810
|
+
event: ["M12 8v4", "M12 16h.01", "M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18"],
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
export function sessionEventIconPaths(tone, category) {
|
|
814
|
+
const key = SESSION_EVENT_ICON_PATHS[tone] ? tone : category;
|
|
815
|
+
return SESSION_EVENT_ICON_PATHS[key] || SESSION_EVENT_ICON_PATHS.event;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
const STARTED_TOOL_TYPE_LABELS = Object.freeze({
|
|
820
|
+
commandExecution: "命令执行",
|
|
821
|
+
fileChange: "文件变更",
|
|
822
|
+
mcpToolCall: "MCP 工具",
|
|
823
|
+
dynamicToolCall: "工具执行",
|
|
824
|
+
collabAgentToolCall: "子 Agent 调度",
|
|
825
|
+
imageGeneration: "图片生成",
|
|
826
|
+
webSearch: "联网搜索",
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
export function prettyJson(value) {
|
|
830
|
+
if (value === undefined) {
|
|
831
|
+
return "undefined";
|
|
832
|
+
}
|
|
833
|
+
try {
|
|
834
|
+
return JSON.stringify(value ?? null, null, 2);
|
|
835
|
+
} catch {
|
|
836
|
+
return String(value);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
export function readStructuredText(value) {
|
|
841
|
+
if (value === null || value === undefined) {
|
|
842
|
+
return "";
|
|
843
|
+
}
|
|
844
|
+
if (typeof value === "string") {
|
|
845
|
+
return value.trim();
|
|
846
|
+
}
|
|
847
|
+
if (Array.isArray(value)) {
|
|
848
|
+
for (const item of value) {
|
|
849
|
+
const text = readStructuredText(item);
|
|
850
|
+
if (text) {
|
|
851
|
+
return text;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return "";
|
|
855
|
+
}
|
|
856
|
+
if (typeof value === "object") {
|
|
857
|
+
for (const key of ["message", "error", "text", "detail", "details", "reason", "summary", "description", "status"]) {
|
|
858
|
+
const text = readStructuredText(value[key]);
|
|
859
|
+
if (text) {
|
|
860
|
+
return text;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return readStructuredText(value.item);
|
|
864
|
+
}
|
|
865
|
+
return "";
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
export function warningOrErrorText({ eventType, chunk, jsonPayload, payload }) {
|
|
869
|
+
const trimmedChunk = String(chunk || "").trim();
|
|
870
|
+
if (trimmedChunk) {
|
|
871
|
+
try {
|
|
872
|
+
const parsed = JSON.parse(trimmedChunk);
|
|
873
|
+
const parsedText = readStructuredText(parsed);
|
|
874
|
+
if (parsedText) {
|
|
875
|
+
return parsedText;
|
|
876
|
+
}
|
|
877
|
+
} catch {
|
|
878
|
+
return trimmedChunk;
|
|
879
|
+
}
|
|
880
|
+
return trimmedChunk;
|
|
881
|
+
}
|
|
882
|
+
return readStructuredText(jsonPayload) || readStructuredText(payload) || eventType || "系统异常事件";
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export function buildEventDetails(message, jsonPayload, leading = [], options = {}) {
|
|
886
|
+
const payload = message?.payload || {};
|
|
887
|
+
const eventType = payload.eventType || "";
|
|
888
|
+
const hideRawStructure = options.hideRawStructure || eventType === "item/agentMessage/delta" || eventType === "item/commandExecution/outputDelta";
|
|
889
|
+
return [
|
|
890
|
+
...leading,
|
|
891
|
+
{ title: "时间", body: message?.timestamp || "" },
|
|
892
|
+
...(message?.sessionId ? [{ title: "会话 ID", body: message.sessionId }] : []),
|
|
893
|
+
...(eventType && !hideRawStructure ? [{ title: "底层事件类型", body: eventType }] : []),
|
|
894
|
+
...(!hideRawStructure ? [{ title: "原始事件", body: prettyJson(jsonPayload || payload) }] : []),
|
|
895
|
+
];
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
export function trimToRecentRounds(views, maxRounds) {
|
|
899
|
+
if (maxRounds <= 0 || views.length === 0) {
|
|
900
|
+
return [];
|
|
901
|
+
}
|
|
902
|
+
const userViews = views.filter((view) => view.kind === "user");
|
|
903
|
+
if (userViews.length <= maxRounds) {
|
|
904
|
+
return views;
|
|
905
|
+
}
|
|
906
|
+
const firstKept = userViews[userViews.length - maxRounds];
|
|
907
|
+
const startIndex = views.indexOf(firstKept);
|
|
908
|
+
return startIndex >= 0 ? views.slice(startIndex) : views;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
export function assistantMessageKey(payload, jsonPayload, item) {
|
|
912
|
+
const turnId = jsonPayload?.turnId || payload?.turnId || "";
|
|
913
|
+
const itemId = jsonPayload?.itemId || item?.id || "";
|
|
914
|
+
if (itemId) {
|
|
915
|
+
return `${turnId || "turn"}:${itemId}`;
|
|
916
|
+
}
|
|
917
|
+
return turnId ? `turn:${turnId}` : "";
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
export function sessionEventMessageKey(entry) {
|
|
921
|
+
const message = entry?.message || entry;
|
|
922
|
+
if (!message) {
|
|
923
|
+
return "";
|
|
924
|
+
}
|
|
925
|
+
if (message.type === "session-timeline") {
|
|
926
|
+
return [
|
|
927
|
+
message.type,
|
|
928
|
+
message.sessionId || message.payload?.sessionId || "",
|
|
929
|
+
message.payload?.items?.[0]?.itemId || "",
|
|
930
|
+
].join("\u0000");
|
|
931
|
+
}
|
|
932
|
+
return [
|
|
933
|
+
message.type || "",
|
|
934
|
+
message.sessionId || "",
|
|
935
|
+
message.timestamp || "",
|
|
936
|
+
JSON.stringify(message.payload || {}),
|
|
937
|
+
].join("\u0000");
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
export function mergeSessionEventEntries(...entryGroups) {
|
|
941
|
+
const result = [];
|
|
942
|
+
const indexByKey = new Map();
|
|
943
|
+
for (const entries of entryGroups) {
|
|
944
|
+
// 每个输入组通常分别来自历史页、当前窗口或实时快照。只抵消“前一组已经
|
|
945
|
+
// 拥有的数量”,保留本组内部合法的同毫秒重复 delta,避免逐字符输出丢字。
|
|
946
|
+
const remainingMatches = new Map();
|
|
947
|
+
for (const [key, value] of indexByKey) {
|
|
948
|
+
if (value?.kind === "count") {
|
|
949
|
+
remainingMatches.set(key, value.count);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
for (const entry of entries || []) {
|
|
953
|
+
const key = sessionEventMessageKey(entry);
|
|
954
|
+
if (!key) {
|
|
955
|
+
result.push(entry);
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
const incomingMessage = entry?.message || entry;
|
|
959
|
+
if (incomingMessage?.type === "session-timeline") {
|
|
960
|
+
const timelineSlot = indexByKey.get(key);
|
|
961
|
+
if (!timelineSlot || timelineSlot.kind !== "timeline") {
|
|
962
|
+
indexByKey.set(key, { kind: "timeline", index: result.length });
|
|
963
|
+
result.push(entry);
|
|
964
|
+
continue;
|
|
965
|
+
}
|
|
966
|
+
// timeline 条目碰撞时保留 sequence 更高的版本(内容更新),位置不变。
|
|
967
|
+
const existingMessage = result[timelineSlot.index]?.message || result[timelineSlot.index];
|
|
968
|
+
if (
|
|
969
|
+
(Number(incomingMessage.payload?.sequence) || 0)
|
|
970
|
+
> (Number(existingMessage?.payload?.sequence) || 0)
|
|
971
|
+
) {
|
|
972
|
+
result[timelineSlot.index] = entry;
|
|
973
|
+
}
|
|
974
|
+
continue;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
const remaining = remainingMatches.get(key) || 0;
|
|
978
|
+
if (remaining > 0) {
|
|
979
|
+
remainingMatches.set(key, remaining - 1);
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
const countSlot = indexByKey.get(key);
|
|
983
|
+
indexByKey.set(key, {
|
|
984
|
+
kind: "count",
|
|
985
|
+
count: countSlot?.kind === "count" ? countSlot.count + 1 : 1,
|
|
986
|
+
});
|
|
987
|
+
result.push(entry);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
return result;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
export const SESSION_PLAN_STEP_LIMIT = 100;
|
|
994
|
+
export const SESSION_PLAN_STEP_TEXT_LIMIT = 500;
|
|
995
|
+
|
|
996
|
+
function normalizeSessionPlanText(value, maxLength) {
|
|
997
|
+
return String(value || "").trim().slice(0, maxLength);
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
function normalizeSessionPlanStatus(value) {
|
|
1001
|
+
const status = String(value || "").trim().toLowerCase();
|
|
1002
|
+
if (status === "completed" || status === "complete" || status === "done" || status === "skipped") {
|
|
1003
|
+
return "completed";
|
|
1004
|
+
}
|
|
1005
|
+
if (status === "inprogress" || status === "in_progress" || status === "in-progress" || status === "running") {
|
|
1006
|
+
return "inProgress";
|
|
1007
|
+
}
|
|
1008
|
+
return "pending";
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
function alignSessionPlanSteps(steps) {
|
|
1012
|
+
const activeIndex = steps.findIndex((step) => step.status === "inProgress");
|
|
1013
|
+
if (activeIndex <= 0) {
|
|
1014
|
+
return steps;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// 兼容旧快照中“后一步进行中、前一步仍 pending”的非单调状态。
|
|
1018
|
+
return steps.map((step, index) => (
|
|
1019
|
+
index < activeIndex && step.status === "pending"
|
|
1020
|
+
? { ...step, status: "completed" }
|
|
1021
|
+
: step
|
|
1022
|
+
));
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
function buildSessionPlanSnapshot({
|
|
1026
|
+
sessionId,
|
|
1027
|
+
threadId,
|
|
1028
|
+
turnId,
|
|
1029
|
+
explanation,
|
|
1030
|
+
updatedAt,
|
|
1031
|
+
sourceSteps,
|
|
1032
|
+
}) {
|
|
1033
|
+
const steps = alignSessionPlanSteps(
|
|
1034
|
+
sourceSteps
|
|
1035
|
+
.map((item) => ({
|
|
1036
|
+
step: normalizeSessionPlanText(
|
|
1037
|
+
item?.step ?? item?.title ?? item?.content ?? item?.text,
|
|
1038
|
+
SESSION_PLAN_STEP_TEXT_LIMIT,
|
|
1039
|
+
),
|
|
1040
|
+
status: normalizeSessionPlanStatus(item?.status),
|
|
1041
|
+
}))
|
|
1042
|
+
.filter((item) => item.step)
|
|
1043
|
+
.slice(0, SESSION_PLAN_STEP_LIMIT),
|
|
1044
|
+
);
|
|
1045
|
+
if (steps.length === 0) {
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
const activeStep = steps.find((step) => step.status === "inProgress")
|
|
1050
|
+
|| steps.find((step) => step.status === "pending")
|
|
1051
|
+
|| steps.at(-1)
|
|
1052
|
+
|| null;
|
|
1053
|
+
const completedCount = steps.filter((step) => step.status === "completed").length;
|
|
1054
|
+
return {
|
|
1055
|
+
sessionId: normalizeSessionPlanText(sessionId, 160),
|
|
1056
|
+
threadId: normalizeSessionPlanText(threadId, 160),
|
|
1057
|
+
turnId: normalizeSessionPlanText(turnId, 160),
|
|
1058
|
+
explanation: normalizeSessionPlanText(explanation, 1000),
|
|
1059
|
+
updatedAt: normalizeSessionPlanText(updatedAt, 80),
|
|
1060
|
+
steps,
|
|
1061
|
+
activeStep,
|
|
1062
|
+
completedCount,
|
|
1063
|
+
totalCount: steps.length,
|
|
1064
|
+
isCompleted: completedCount === steps.length,
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
export function sessionPlanSnapshotFromMessage(message) {
|
|
1069
|
+
if (message?.type === "session-plan-updated") {
|
|
1070
|
+
const payload = message.payload || {};
|
|
1071
|
+
const sourceSteps = Array.isArray(payload.steps)
|
|
1072
|
+
? payload.steps
|
|
1073
|
+
: Array.isArray(payload.plan)
|
|
1074
|
+
? payload.plan
|
|
1075
|
+
: [];
|
|
1076
|
+
return buildSessionPlanSnapshot({
|
|
1077
|
+
sessionId: payload.sessionId || message.sessionId,
|
|
1078
|
+
threadId: payload.threadId,
|
|
1079
|
+
turnId: payload.turnId,
|
|
1080
|
+
explanation: payload.explanation,
|
|
1081
|
+
updatedAt: message.timestamp,
|
|
1082
|
+
sourceSteps,
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
if (message?.type === "session-output" && message.payload?.eventType === "turn/plan/updated") {
|
|
1086
|
+
const payload = message.payload || {};
|
|
1087
|
+
const jsonPayload = payload.jsonPayload || {};
|
|
1088
|
+
const sourceSteps = Array.isArray(jsonPayload.plan)
|
|
1089
|
+
? jsonPayload.plan
|
|
1090
|
+
: Array.isArray(jsonPayload.steps)
|
|
1091
|
+
? jsonPayload.steps
|
|
1092
|
+
: [];
|
|
1093
|
+
return buildSessionPlanSnapshot({
|
|
1094
|
+
sessionId: payload.sessionId || message.sessionId,
|
|
1095
|
+
threadId: jsonPayload.threadId,
|
|
1096
|
+
turnId: jsonPayload.turnId,
|
|
1097
|
+
explanation: jsonPayload.explanation,
|
|
1098
|
+
updatedAt: message.timestamp,
|
|
1099
|
+
sourceSteps,
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
if (message?.type === "session-timeline") {
|
|
1103
|
+
const items = Array.isArray(message.payload?.items) ? message.payload.items : [];
|
|
1104
|
+
let latestTodo = null;
|
|
1105
|
+
for (const item of items) {
|
|
1106
|
+
if (item?.kind === "todo" && Array.isArray(item.entries) && item.entries.length > 0) {
|
|
1107
|
+
latestTodo = item;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
if (!latestTodo) return null;
|
|
1111
|
+
return buildSessionPlanSnapshot({
|
|
1112
|
+
sessionId: latestTodo.sessionId || message.sessionId,
|
|
1113
|
+
threadId: "",
|
|
1114
|
+
turnId: latestTodo.turnId,
|
|
1115
|
+
explanation: latestTodo.title && latestTodo.title !== "任务清单" ? latestTodo.title : "",
|
|
1116
|
+
updatedAt: latestTodo.updatedAt || latestTodo.createdAt || message.timestamp,
|
|
1117
|
+
sourceSteps: latestTodo.entries,
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
return null;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
function sessionPlanViewFromSnapshot(snapshot, message) {
|
|
1124
|
+
if (!snapshot || !Array.isArray(snapshot.steps) || snapshot.steps.length === 0) {
|
|
1125
|
+
return null;
|
|
1126
|
+
}
|
|
1127
|
+
const key = snapshot.turnId || snapshot.sessionId || "session";
|
|
1128
|
+
return {
|
|
1129
|
+
id: `plan-${key}`,
|
|
1130
|
+
kind: "plan",
|
|
1131
|
+
label: "执行计划",
|
|
1132
|
+
text: snapshot.activeStep?.step || `${snapshot.completedCount}/${snapshot.totalCount}`,
|
|
1133
|
+
timestamp: snapshot.updatedAt || message?.timestamp || "",
|
|
1134
|
+
sessionId: snapshot.sessionId || message?.sessionId || "",
|
|
1135
|
+
turnId: snapshot.turnId || "",
|
|
1136
|
+
explanation: snapshot.explanation || "",
|
|
1137
|
+
steps: snapshot.steps,
|
|
1138
|
+
activeStep: snapshot.activeStep,
|
|
1139
|
+
completedCount: snapshot.completedCount,
|
|
1140
|
+
totalCount: snapshot.totalCount,
|
|
1141
|
+
isCompleted: snapshot.isCompleted,
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
function extractReasoningItemText(item) {
|
|
1146
|
+
if (!item || typeof item !== "object") return "";
|
|
1147
|
+
const parts = [];
|
|
1148
|
+
const collect = (value) => {
|
|
1149
|
+
if (typeof value === "string") {
|
|
1150
|
+
const trimmed = value.trim();
|
|
1151
|
+
if (trimmed) parts.push(trimmed);
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
if (Array.isArray(value)) {
|
|
1155
|
+
for (const entry of value.slice(0, 32)) {
|
|
1156
|
+
if (typeof entry === "string") {
|
|
1157
|
+
const trimmed = entry.trim();
|
|
1158
|
+
if (trimmed) parts.push(trimmed);
|
|
1159
|
+
} else if (entry && typeof entry === "object" && typeof entry.text === "string") {
|
|
1160
|
+
const trimmed = entry.text.trim();
|
|
1161
|
+
if (trimmed) parts.push(trimmed);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
collect(item.text);
|
|
1167
|
+
if (parts.length === 0) collect(item.summary);
|
|
1168
|
+
if (parts.length === 0) collect(item.content);
|
|
1169
|
+
return parts.join("\n\n");
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
export function sessionPlanSnapshotFromEvents(entries) {
|
|
1173
|
+
let latest = null;
|
|
1174
|
+
for (const entry of entries || []) {
|
|
1175
|
+
latest = sessionPlanSnapshotFromMessage(entry?.message || entry) || latest;
|
|
1176
|
+
}
|
|
1177
|
+
return latest;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
export const SESSION_SUBAGENT_LIMIT = 20;
|
|
1181
|
+
|
|
1182
|
+
function normalizeSessionSubagentStatus(value) {
|
|
1183
|
+
const normalized = String(value?.status || value?.type || value || "")
|
|
1184
|
+
.trim()
|
|
1185
|
+
.toLowerCase();
|
|
1186
|
+
if (["running", "inprogress", "in_progress", "active", "started", "working"].includes(normalized)) {
|
|
1187
|
+
return "running";
|
|
1188
|
+
}
|
|
1189
|
+
if (["completed", "complete", "done", "succeeded", "success", "idle"].includes(normalized)) {
|
|
1190
|
+
return "completed";
|
|
1191
|
+
}
|
|
1192
|
+
if (["failed", "failure", "error", "cancelled", "canceled"].includes(normalized)) {
|
|
1193
|
+
return "failed";
|
|
1194
|
+
}
|
|
1195
|
+
if (["interrupted", "interrupt", "stopped", "aborted"].includes(normalized)) {
|
|
1196
|
+
return "interrupted";
|
|
1197
|
+
}
|
|
1198
|
+
if (["waitingapproval", "waiting_approval", "approval", "blocked"].includes(normalized)) {
|
|
1199
|
+
return "waitingApproval";
|
|
1200
|
+
}
|
|
1201
|
+
return "pending";
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
function isDoneSubagentStatus(status) {
|
|
1205
|
+
return status === "completed" || status === "failed";
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
function normalizedSubagentText(value, maxLength) {
|
|
1209
|
+
return String(value || "").trim().slice(0, maxLength);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
function normalizeSessionSubagentActivityType(value) {
|
|
1213
|
+
const normalized = normalizedSubagentText(value, 40);
|
|
1214
|
+
return [
|
|
1215
|
+
"starting",
|
|
1216
|
+
"message",
|
|
1217
|
+
"command",
|
|
1218
|
+
"fileChange",
|
|
1219
|
+
"tool",
|
|
1220
|
+
"waiting",
|
|
1221
|
+
"approval",
|
|
1222
|
+
"completed",
|
|
1223
|
+
"interrupted",
|
|
1224
|
+
"failed",
|
|
1225
|
+
].includes(normalized) ? normalized : "";
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
function mergeSessionSubagent(byId, record, timestamp, limit = SESSION_SUBAGENT_LIMIT) {
|
|
1229
|
+
const id = normalizedSubagentText(
|
|
1230
|
+
record?.id || record?.agentId || record?.subagentId || record?.threadId,
|
|
1231
|
+
160,
|
|
1232
|
+
);
|
|
1233
|
+
if (!id) {
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
const previous = byId.get(id);
|
|
1237
|
+
const nextStatus = normalizeSessionSubagentStatus(record?.status || record?.state || record?.phase);
|
|
1238
|
+
const revision = Number.isSafeInteger(record?.revision) && record.revision > 0 ? record.revision : 0;
|
|
1239
|
+
const updatedAt = normalizedSubagentText(record?.updatedAt || timestamp || previous?.updatedAt, 80);
|
|
1240
|
+
if (previous?.revision && revision <= previous.revision) return;
|
|
1241
|
+
if (previous && !revision) {
|
|
1242
|
+
const nextTime = Date.parse(updatedAt);
|
|
1243
|
+
const previousTime = Date.parse(previous.updatedAt);
|
|
1244
|
+
if (nextTime < previousTime) return;
|
|
1245
|
+
const newTurn = record?.turnId && record.turnId !== previous.turnId;
|
|
1246
|
+
// 旧 Gateway 无序号时只凭更新的明确启动/新轮次越过终态,避免迟到 active 回退。
|
|
1247
|
+
if (isDoneSubagentStatus(previous.status) && !isDoneSubagentStatus(nextStatus)
|
|
1248
|
+
&& !(nextTime > previousTime && (newTurn || record?.activityType === "starting"))) return;
|
|
1249
|
+
}
|
|
1250
|
+
const restarted = previous && (isDoneSubagentStatus(previous.status) || previous.status === "interrupted")
|
|
1251
|
+
&& ["running", "waitingApproval"].includes(nextStatus);
|
|
1252
|
+
// 统计按子运行隔离;同运行快照不相加,恢复到新线程时不能继承旧累计数。
|
|
1253
|
+
const newRun = restarted || previous && (
|
|
1254
|
+
record?.threadId && record.threadId !== previous.threadId
|
|
1255
|
+
|| record?.turnId && record.turnId !== previous.turnId
|
|
1256
|
+
);
|
|
1257
|
+
// 父发起锚不跟随子 turn 的指标清零;明确换线程或新父发起才放弃旧锚。
|
|
1258
|
+
const rebindOrigin = previous && (
|
|
1259
|
+
record?.threadId && record.threadId !== previous.threadId
|
|
1260
|
+
|| record?.parentTurnId && previous.parentTurnId && record.parentTurnId !== previous.parentTurnId
|
|
1261
|
+
|| record?.originToolCallId && previous.originToolCallId && record.originToolCallId !== previous.originToolCallId
|
|
1262
|
+
);
|
|
1263
|
+
const oldCount = newRun ? undefined : previous?.toolCallCount;
|
|
1264
|
+
const count = Number.isSafeInteger(record?.toolCallCount) && record.toolCallCount >= 0
|
|
1265
|
+
? record.toolCallCount : undefined;
|
|
1266
|
+
const oldToolTime = newRun ? undefined : previous?.lastToolActivityAt;
|
|
1267
|
+
const toolTime = typeof record?.lastToolActivityAt === "string" && Number.isFinite(Date.parse(record.lastToolActivityAt))
|
|
1268
|
+
? new Date(record.lastToolActivityAt).toISOString() : undefined;
|
|
1269
|
+
byId.set(id, {
|
|
1270
|
+
...previous,
|
|
1271
|
+
id,
|
|
1272
|
+
toolCallCount: count === undefined ? oldCount : Math.max(oldCount ?? 0, count),
|
|
1273
|
+
lastToolActivityAt: toolTime && (!oldToolTime || Date.parse(toolTime) > Date.parse(oldToolTime)) ? toolTime : oldToolTime,
|
|
1274
|
+
name: normalizedSubagentText(
|
|
1275
|
+
record?.name || record?.nickname || record?.displayName || record?.title || previous?.name || `Agent ${id.slice(0, 6)}`,
|
|
1276
|
+
80,
|
|
1277
|
+
),
|
|
1278
|
+
status: nextStatus,
|
|
1279
|
+
revision,
|
|
1280
|
+
role: normalizedSubagentText(record?.role || previous?.role, 80),
|
|
1281
|
+
task: normalizedSubagentText(
|
|
1282
|
+
record?.task || record?.taskName || record?.currentTask || previous?.task,
|
|
1283
|
+
80,
|
|
1284
|
+
),
|
|
1285
|
+
summary: normalizedSubagentText(record?.summary || record?.message || record?.prompt || previous?.summary, 400),
|
|
1286
|
+
result: normalizedSubagentText(record?.result || record?.conclusion || (!restarted && previous?.result), 400),
|
|
1287
|
+
error: normalizedSubagentText(record?.error || (!restarted && previous?.error), 400),
|
|
1288
|
+
threadId: normalizedSubagentText(record?.threadId || previous?.threadId, 160),
|
|
1289
|
+
turnId: normalizedSubagentText(record?.turnId || previous?.turnId, 160),
|
|
1290
|
+
parentTurnId: normalizedSubagentText(record?.parentTurnId || (!rebindOrigin && previous?.parentTurnId), 160),
|
|
1291
|
+
originToolCallId: normalizedSubagentText(record?.originToolCallId || (!rebindOrigin && previous?.originToolCallId), 200),
|
|
1292
|
+
activityType: normalizeSessionSubagentActivityType(record?.activityType || previous?.activityType),
|
|
1293
|
+
activitySummary: normalizedSubagentText(record?.activitySummary || previous?.activitySummary, 400),
|
|
1294
|
+
lastActivityAt: normalizedSubagentText(record?.lastActivityAt || previous?.lastActivityAt, 80),
|
|
1295
|
+
updatedAt,
|
|
1296
|
+
});
|
|
1297
|
+
while (byId.size > limit) {
|
|
1298
|
+
byId.delete(byId.keys().next().value);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
function applyRawCollabAgentEvent(byId, message, limit = SESSION_SUBAGENT_LIMIT) {
|
|
1303
|
+
if (message?.type !== "session-output") {
|
|
1304
|
+
return false;
|
|
1305
|
+
}
|
|
1306
|
+
const payload = message.payload || {};
|
|
1307
|
+
const item = payload.jsonPayload?.item;
|
|
1308
|
+
if (item?.type !== "collabAgentToolCall") {
|
|
1309
|
+
return false;
|
|
1310
|
+
}
|
|
1311
|
+
const tool = String(item.tool || "").toLowerCase();
|
|
1312
|
+
const ids = Array.isArray(item.receiverThreadIds)
|
|
1313
|
+
? item.receiverThreadIds.map((value) => normalizedSubagentText(value, 160)).filter(Boolean)
|
|
1314
|
+
: [];
|
|
1315
|
+
if (ids.length === 0 && item.agentsStates && typeof item.agentsStates === "object") {
|
|
1316
|
+
ids.push(...Object.keys(item.agentsStates).map((value) => normalizedSubagentText(value, 160)).filter(Boolean));
|
|
1317
|
+
}
|
|
1318
|
+
if (ids.length === 0 && item.agentId) {
|
|
1319
|
+
ids.push(normalizedSubagentText(item.agentId, 160));
|
|
1320
|
+
}
|
|
1321
|
+
if (tool === "spawnagent") {
|
|
1322
|
+
const prompt = normalizedSubagentText(item.prompt, 400);
|
|
1323
|
+
const name = normalizedSubagentText(
|
|
1324
|
+
prompt.split(/\r?\n/).find((line) => line.trim()) || "",
|
|
1325
|
+
80,
|
|
1326
|
+
);
|
|
1327
|
+
for (const id of ids) {
|
|
1328
|
+
mergeSessionSubagent(byId, {
|
|
1329
|
+
id,
|
|
1330
|
+
name: name || `Agent ${id.slice(0, 6)}`,
|
|
1331
|
+
status: item.agentsStates?.[id] || "running",
|
|
1332
|
+
task: name,
|
|
1333
|
+
summary: prompt,
|
|
1334
|
+
threadId: id,
|
|
1335
|
+
parentTurnId: payload.jsonPayload?.turnId || payload.jsonPayload?.turn?.id || payload.turnId,
|
|
1336
|
+
originToolCallId: item.id,
|
|
1337
|
+
activityType: "starting",
|
|
1338
|
+
activitySummary: "子 Agent 正在启动",
|
|
1339
|
+
lastActivityAt: message.timestamp,
|
|
1340
|
+
}, message.timestamp, limit);
|
|
1341
|
+
}
|
|
1342
|
+
return ids.length > 0;
|
|
1343
|
+
}
|
|
1344
|
+
if (tool !== "closeagent" && tool !== "wait") {
|
|
1345
|
+
return false;
|
|
1346
|
+
}
|
|
1347
|
+
let changed = false;
|
|
1348
|
+
for (const id of ids) {
|
|
1349
|
+
const previous = byId.get(id);
|
|
1350
|
+
if (!previous) {
|
|
1351
|
+
continue;
|
|
1352
|
+
}
|
|
1353
|
+
mergeSessionSubagent(byId, {
|
|
1354
|
+
...previous,
|
|
1355
|
+
updatedAt: message.timestamp,
|
|
1356
|
+
status: tool === "closeagent" ? "completed" : (item.agentsStates?.[id] || previous.status),
|
|
1357
|
+
...(tool === "closeagent" ? {
|
|
1358
|
+
activityType: "completed",
|
|
1359
|
+
activitySummary: "子 Agent 已完成",
|
|
1360
|
+
lastActivityAt: message.timestamp,
|
|
1361
|
+
} : {}),
|
|
1362
|
+
}, message.timestamp, limit);
|
|
1363
|
+
changed = true;
|
|
1364
|
+
}
|
|
1365
|
+
return changed;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
export function sessionSubagentSnapshotFromEvents(entries, options = {}) {
|
|
1369
|
+
// 历史展示仅扩大当前已加载窗口的聚合容量;默认缓存仍为 20,任何输入都不得突破 200。
|
|
1370
|
+
const limit = Number.isFinite(options?.limit)
|
|
1371
|
+
? Math.max(1, Math.min(200, Math.floor(options.limit)))
|
|
1372
|
+
: SESSION_SUBAGENT_LIMIT;
|
|
1373
|
+
const byId = new Map();
|
|
1374
|
+
let sessionId = "";
|
|
1375
|
+
let threadId = "";
|
|
1376
|
+
let turnId = "";
|
|
1377
|
+
let updatedAt = "";
|
|
1378
|
+
let parentWaiting = false;
|
|
1379
|
+
const starts = new Map();
|
|
1380
|
+
|
|
1381
|
+
for (const entry of entries || []) {
|
|
1382
|
+
const message = entry?.message || entry;
|
|
1383
|
+
if (!message) {
|
|
1384
|
+
continue;
|
|
1385
|
+
}
|
|
1386
|
+
if (options?.provider === "codex" && message.type === "session-output") {
|
|
1387
|
+
const data = message.payload?.jsonPayload;
|
|
1388
|
+
const item = data?.item;
|
|
1389
|
+
if (item?.type === "subAgentActivity" && item.kind === "started" && item.agentThreadId && data.turnId && item.id) {
|
|
1390
|
+
starts.set(item.agentThreadId, { parentTurnId: data.turnId, originToolCallId: item.id });
|
|
1391
|
+
if (starts.size > limit) starts.delete(starts.keys().next().value);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
if (message.type === "session-subagents-updated") {
|
|
1395
|
+
const payload = message.payload || {};
|
|
1396
|
+
for (const agent of payload.agents || payload.subagents || []) {
|
|
1397
|
+
mergeSessionSubagent(byId, agent, message.timestamp, limit);
|
|
1398
|
+
}
|
|
1399
|
+
sessionId = normalizedSubagentText(payload.sessionId || message.sessionId || sessionId, 160);
|
|
1400
|
+
threadId = normalizedSubagentText(payload.threadId || threadId, 160);
|
|
1401
|
+
turnId = normalizedSubagentText(payload.turnId || turnId, 160);
|
|
1402
|
+
parentWaiting = payload.parentWaiting === true;
|
|
1403
|
+
updatedAt = normalizedSubagentText(message.timestamp || updatedAt, 80);
|
|
1404
|
+
continue;
|
|
1405
|
+
}
|
|
1406
|
+
if (applyRawCollabAgentEvent(byId, message, limit)) {
|
|
1407
|
+
sessionId = normalizedSubagentText(message.sessionId || sessionId, 160);
|
|
1408
|
+
threadId = normalizedSubagentText(message.payload?.jsonPayload?.threadId || threadId, 160);
|
|
1409
|
+
turnId = normalizedSubagentText(message.payload?.jsonPayload?.turnId || turnId, 160);
|
|
1410
|
+
updatedAt = normalizedSubagentText(message.timestamp || updatedAt, 80);
|
|
1411
|
+
continue;
|
|
1412
|
+
}
|
|
1413
|
+
if (message.type === "session-finished" && byId.size > 0) {
|
|
1414
|
+
const terminalStatus = message.payload?.status === "failed" || message.payload?.status === "cancelled"
|
|
1415
|
+
? "failed"
|
|
1416
|
+
: "completed";
|
|
1417
|
+
for (const agent of [...byId.values()]) {
|
|
1418
|
+
if (!isDoneSubagentStatus(agent.status) && agent.status !== "interrupted"
|
|
1419
|
+
&& !(Date.parse(message.timestamp) < Date.parse(agent.updatedAt))) {
|
|
1420
|
+
// 旧历史可能只有父轮次终态;这是本地收尾,不制造服务端 revision。
|
|
1421
|
+
byId.set(agent.id, { ...agent, status: terminalStatus, updatedAt: message.timestamp });
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
updatedAt = normalizedSubagentText(message.timestamp || updatedAt, 80);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// 只在投影结果时恢复 Claude 旧任务自身的父轮次,避免兼容锚影响 revision/乱序合并。
|
|
1429
|
+
// snapshot 顶层 turn 可能属于后续主轮次,Codex 的任务 turn 则是子轮次,均不能借用。
|
|
1430
|
+
const agents = [...byId.values()].map((agent) => (
|
|
1431
|
+
options?.provider === "claude-code" && !agent.parentTurnId && agent.turnId
|
|
1432
|
+
? { ...agent, parentTurnId: agent.turnId }
|
|
1433
|
+
: !agent.parentTurnId && !agent.originToolCallId && starts.has(agent.threadId)
|
|
1434
|
+
? { ...agent, ...starts.get(agent.threadId) } : agent
|
|
1435
|
+
));
|
|
1436
|
+
if (agents.length === 0) {
|
|
1437
|
+
return null;
|
|
1438
|
+
}
|
|
1439
|
+
const interruptedAgents = agents.filter((agent) => agent.status === "interrupted");
|
|
1440
|
+
const activeAgents = agents.filter((agent) => (
|
|
1441
|
+
!isDoneSubagentStatus(agent.status) && agent.status !== "interrupted"
|
|
1442
|
+
));
|
|
1443
|
+
const doneAgents = agents.filter((agent) => isDoneSubagentStatus(agent.status));
|
|
1444
|
+
return {
|
|
1445
|
+
sessionId,
|
|
1446
|
+
threadId,
|
|
1447
|
+
turnId,
|
|
1448
|
+
updatedAt,
|
|
1449
|
+
parentWaiting,
|
|
1450
|
+
agents,
|
|
1451
|
+
activeAgents,
|
|
1452
|
+
interruptedAgents,
|
|
1453
|
+
doneAgents,
|
|
1454
|
+
totalCount: agents.length,
|
|
1455
|
+
activeCount: activeAgents.length,
|
|
1456
|
+
interruptedCount: interruptedAgents.length,
|
|
1457
|
+
completedCount: doneAgents.filter((agent) => agent.status === "completed").length,
|
|
1458
|
+
failedCount: doneAgents.filter((agent) => agent.status === "failed").length,
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
export function mergeSessionSubagentMessage(previous, message) {
|
|
1463
|
+
// 每次最多合并两份 20 项快照,实时更新无需重新扫描会话历史。
|
|
1464
|
+
return sessionSubagentSnapshotFromEvents([
|
|
1465
|
+
...(previous ? [{ type: "session-subagents-updated", timestamp: previous.updatedAt, payload: previous }] : []),
|
|
1466
|
+
message,
|
|
1467
|
+
]);
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
export function sessionSubagentDetailText(agent) {
|
|
1471
|
+
const activitySummary = normalizedSubagentText(agent?.activitySummary, 400);
|
|
1472
|
+
if (activitySummary) {
|
|
1473
|
+
return activitySummary;
|
|
1474
|
+
}
|
|
1475
|
+
const error = normalizedSubagentText(agent?.error, 400);
|
|
1476
|
+
if (error) {
|
|
1477
|
+
return error;
|
|
1478
|
+
}
|
|
1479
|
+
const result = normalizedSubagentText(agent?.result, 400);
|
|
1480
|
+
if (result) {
|
|
1481
|
+
return result;
|
|
1482
|
+
}
|
|
1483
|
+
const task = normalizedSubagentText(agent?.task, 80);
|
|
1484
|
+
const summary = normalizedSubagentText(agent?.summary, 400);
|
|
1485
|
+
if (task && summary && task !== summary) {
|
|
1486
|
+
return `${task} · ${summary}`;
|
|
1487
|
+
}
|
|
1488
|
+
return summary || task || "";
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
function sessionPixelAvatarHash(seed) {
|
|
1492
|
+
let hash = 0x811c9dc5;
|
|
1493
|
+
for (let index = 0; index < String(seed || "").length; index += 1) {
|
|
1494
|
+
hash ^= String(seed || "").charCodeAt(index);
|
|
1495
|
+
hash = Math.imul(hash, 0x01000193) & 0x7fffffff;
|
|
1496
|
+
}
|
|
1497
|
+
return hash;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
export function sessionPixelAvatarCells(seed) {
|
|
1501
|
+
const hash = sessionPixelAvatarHash(seed);
|
|
1502
|
+
const cells = Array.from({ length: 25 }, () => false);
|
|
1503
|
+
for (let y = 0; y < 5; y += 1) {
|
|
1504
|
+
for (let x = 0; x < 3; x += 1) {
|
|
1505
|
+
const bitIndex = y * 3 + x;
|
|
1506
|
+
const isFilled = ((hash >> bitIndex) & 1) === 1 || (x === 1 && y === 2);
|
|
1507
|
+
if (!isFilled) {
|
|
1508
|
+
continue;
|
|
1509
|
+
}
|
|
1510
|
+
cells[y * 5 + x] = true;
|
|
1511
|
+
cells[y * 5 + (4 - x)] = true;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
return cells;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
export function sessionPixelAvatarTone(seed) {
|
|
1518
|
+
return sessionPixelAvatarHash(seed) % 6;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
export function appendAssistantDelta(views, streamingByKey, fallbackRef, message, payload, jsonPayload) {
|
|
1522
|
+
const delta = payload.chunk || jsonPayload.delta || "";
|
|
1523
|
+
if (!delta) {
|
|
1524
|
+
return fallbackRef;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
const key = assistantMessageKey(payload, jsonPayload);
|
|
1528
|
+
const assistantPhase = String(jsonPayload.phase || "").trim();
|
|
1529
|
+
let view = key ? streamingByKey.get(key) : fallbackRef.current;
|
|
1530
|
+
if (!view) {
|
|
1531
|
+
view = {
|
|
1532
|
+
id: key || `assistant-${message.timestamp}`,
|
|
1533
|
+
kind: "assistant",
|
|
1534
|
+
label: "助手",
|
|
1535
|
+
text: "",
|
|
1536
|
+
sessionId: message.sessionId || payload.sessionId || "",
|
|
1537
|
+
timestamp: message.timestamp,
|
|
1538
|
+
markdown: true,
|
|
1539
|
+
streaming: true,
|
|
1540
|
+
assistantPhase,
|
|
1541
|
+
};
|
|
1542
|
+
views.push(view);
|
|
1543
|
+
if (key) {
|
|
1544
|
+
streamingByKey.set(key, view);
|
|
1545
|
+
} else {
|
|
1546
|
+
fallbackRef.current = view;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
view.text += delta;
|
|
1550
|
+
view.timestamp = message.timestamp;
|
|
1551
|
+
if (assistantPhase) {
|
|
1552
|
+
view.assistantPhase = assistantPhase;
|
|
1553
|
+
}
|
|
1554
|
+
view.turnId = String(jsonPayload.turnId || payload.turnId || view.turnId || "").trim();
|
|
1555
|
+
view.itemId = String(jsonPayload.itemId || view.itemId || "").trim();
|
|
1556
|
+
return view;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
const LEGACY_TRUNCATED_AGENT_MESSAGE_LENGTH = 4001;
|
|
1560
|
+
|
|
1561
|
+
function completedAssistantText(existingText, completedText, truncated = false) {
|
|
1562
|
+
if (truncated && existingText.length > completedText.length && existingText.startsWith(completedText)) return existingText;
|
|
1563
|
+
const legacyPrefix = completedText.endsWith("…")
|
|
1564
|
+
? completedText.slice(0, -1)
|
|
1565
|
+
: "";
|
|
1566
|
+
// 仅兼容旧 Gateway 固定的 4000 字符截断,正常终态仍应覆盖流式草稿。
|
|
1567
|
+
return existingText.length > completedText.length
|
|
1568
|
+
&& completedText.length === LEGACY_TRUNCATED_AGENT_MESSAGE_LENGTH
|
|
1569
|
+
&& legacyPrefix.length === LEGACY_TRUNCATED_AGENT_MESSAGE_LENGTH - 1
|
|
1570
|
+
&& existingText.startsWith(legacyPrefix)
|
|
1571
|
+
? existingText
|
|
1572
|
+
: completedText;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
export function completeAssistantMessage(views, streamingByKey, fallbackRef, message, payload, jsonPayload, item) {
|
|
1576
|
+
if (typeof item.text !== "string") {
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
const key = assistantMessageKey(payload, jsonPayload, item);
|
|
1581
|
+
const assistantPhase = String(item.phase || jsonPayload.phase || "").trim();
|
|
1582
|
+
const view = key ? streamingByKey.get(key) : fallbackRef.current;
|
|
1583
|
+
if (view) {
|
|
1584
|
+
view.text = completedAssistantText(view.text, item.text, item.textTruncated);
|
|
1585
|
+
view.agentContent = item.textContent;
|
|
1586
|
+
view.textTruncated = item.textTruncated === true;
|
|
1587
|
+
view.contentBlocks = normalizeAssistantContentBlocks(item.contentBlocks);
|
|
1588
|
+
view.sessionId = message.sessionId || payload.sessionId || view.sessionId || "";
|
|
1589
|
+
view.timestamp = message.timestamp;
|
|
1590
|
+
view.streaming = false;
|
|
1591
|
+
view.assistantPhase = assistantPhase;
|
|
1592
|
+
view.turnId = String(jsonPayload.turnId || payload.turnId || view.turnId || "").trim();
|
|
1593
|
+
view.itemId = String(item.id || jsonPayload.itemId || view.itemId || "").trim();
|
|
1594
|
+
if (key) {
|
|
1595
|
+
streamingByKey.delete(key);
|
|
1596
|
+
} else {
|
|
1597
|
+
fallbackRef.current = null;
|
|
1598
|
+
}
|
|
1599
|
+
return view;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
const completedView = {
|
|
1603
|
+
id: key || `assistant-${message.timestamp}`,
|
|
1604
|
+
kind: "assistant",
|
|
1605
|
+
label: "助手",
|
|
1606
|
+
text: item.text,
|
|
1607
|
+
agentContent: item.textContent,
|
|
1608
|
+
textTruncated: item.textTruncated === true,
|
|
1609
|
+
contentBlocks: normalizeAssistantContentBlocks(item.contentBlocks),
|
|
1610
|
+
sessionId: message.sessionId || payload.sessionId || "",
|
|
1611
|
+
timestamp: message.timestamp,
|
|
1612
|
+
markdown: true,
|
|
1613
|
+
assistantPhase,
|
|
1614
|
+
turnId: String(jsonPayload.turnId || payload.turnId || "").trim(),
|
|
1615
|
+
itemId: String(item.id || jsonPayload.itemId || "").trim(),
|
|
1616
|
+
};
|
|
1617
|
+
views.push(completedView);
|
|
1618
|
+
return completedView;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
const SESSION_MEMORY_CITATION_ENTRY_LIMIT = 8;
|
|
1622
|
+
const SESSION_MEMORY_CITATION_SCAN_LIMIT = 32;
|
|
1623
|
+
const SESSION_MEMORY_CITATION_SOURCE_LIMIT = 20;
|
|
1624
|
+
const SESSION_MEMORY_CITATION_NOTE_LIMIT = 240;
|
|
1625
|
+
|
|
1626
|
+
function normalizeSessionMemoryCitationView(message) {
|
|
1627
|
+
if (message?.type !== "session-memory-citation") {
|
|
1628
|
+
return null;
|
|
1629
|
+
}
|
|
1630
|
+
const payload = message.payload || {};
|
|
1631
|
+
const entries = [];
|
|
1632
|
+
const sourceEntries = Array.isArray(payload.entries) ? payload.entries : [];
|
|
1633
|
+
for (const entry of sourceEntries.slice(0, SESSION_MEMORY_CITATION_SCAN_LIMIT)) {
|
|
1634
|
+
if (entries.length >= SESSION_MEMORY_CITATION_ENTRY_LIMIT) {
|
|
1635
|
+
break;
|
|
1636
|
+
}
|
|
1637
|
+
const note = typeof entry?.note === "string"
|
|
1638
|
+
? Array.from(entry.note.trim()).slice(0, SESSION_MEMORY_CITATION_NOTE_LIMIT).join("")
|
|
1639
|
+
: "";
|
|
1640
|
+
if (!note) {
|
|
1641
|
+
continue;
|
|
1642
|
+
}
|
|
1643
|
+
const sourceLabel = typeof entry?.sourceLabel === "string"
|
|
1644
|
+
? entry.sourceLabel.trim().slice(0, 80)
|
|
1645
|
+
: "";
|
|
1646
|
+
entries.push({ note, sourceLabel: sourceLabel || "历史记忆" });
|
|
1647
|
+
}
|
|
1648
|
+
if (entries.length === 0) {
|
|
1649
|
+
return null;
|
|
1650
|
+
}
|
|
1651
|
+
const sourceThreadCount = Number(payload.sourceThreadCount);
|
|
1652
|
+
return {
|
|
1653
|
+
turnId: typeof payload.turnId === "string" ? payload.turnId.trim().slice(0, 160) : "",
|
|
1654
|
+
itemId: typeof payload.itemId === "string" ? payload.itemId.trim().slice(0, 160) : "",
|
|
1655
|
+
entries,
|
|
1656
|
+
sourceThreadCount: Number.isFinite(sourceThreadCount)
|
|
1657
|
+
? Math.min(SESSION_MEMORY_CITATION_SOURCE_LIMIT, Math.max(0, Math.floor(sourceThreadCount)))
|
|
1658
|
+
: 0,
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
function attachSessionMemoryCitation(view, citation) {
|
|
1663
|
+
if (!view || !citation) {
|
|
1664
|
+
return false;
|
|
1665
|
+
}
|
|
1666
|
+
view.memoryCitation = citation;
|
|
1667
|
+
return true;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
export function upsertSessionView(views, viewById, view) {
|
|
1671
|
+
if (!view?.id) {
|
|
1672
|
+
views.push(view);
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
const existingIndex = viewById.get(view.id);
|
|
1676
|
+
if (existingIndex === undefined) {
|
|
1677
|
+
viewById.set(view.id, views.length);
|
|
1678
|
+
views.push(view);
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
const current = views[existingIndex];
|
|
1682
|
+
if (current.antigravityTool && view.antigravityTool) {
|
|
1683
|
+
if (["completed", "failed", "cancelled"].includes(current.eventStatus)
|
|
1684
|
+
&& !["completed", "failed", "cancelled"].includes(view.eventStatus)) return;
|
|
1685
|
+
view = { ...view, timestamp: current.timestamp };
|
|
1686
|
+
}
|
|
1687
|
+
if (current.claudeToolStatus && view.claudeToolStatus) {
|
|
1688
|
+
// 历史分页与实时开始事件交错时保留已知终态。
|
|
1689
|
+
if (current.claudeToolStatus !== "running" && view.claudeToolStatus === "running") return;
|
|
1690
|
+
view = { ...view, timestamp: current.timestamp };
|
|
1691
|
+
}
|
|
1692
|
+
if (current.compactionStatus && view.compactionStatus) {
|
|
1693
|
+
if (current.compactionStatus !== "running" && view.compactionStatus === "running") return;
|
|
1694
|
+
view = { ...view, timestamp: current.timestamp };
|
|
1695
|
+
}
|
|
1696
|
+
// 局部快照替换正文时只继承缺失元数据,不把未知退出码转换为 0。
|
|
1697
|
+
view = { ...view };
|
|
1698
|
+
for (const field of ["toolType", "eventStatus", "exitCode", "eventLevel", "command", "eventType"]) {
|
|
1699
|
+
if (view[field] === undefined && current[field] !== undefined) view[field] = current[field];
|
|
1700
|
+
}
|
|
1701
|
+
views[existingIndex] = view;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
export function appendCommandOutputDelta(views, viewById, message, payload, jsonPayload) {
|
|
1705
|
+
const itemId = jsonPayload.itemId || "";
|
|
1706
|
+
if (!itemId) {
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1709
|
+
const id = `command-${itemId}`;
|
|
1710
|
+
const existingIndex = viewById.get(id);
|
|
1711
|
+
const existing = existingIndex === undefined ? null : views[existingIndex];
|
|
1712
|
+
const outputChunk = payload.chunk || jsonPayload.delta || "";
|
|
1713
|
+
const metadata = structuredEventFields({
|
|
1714
|
+
...existing, ...jsonPayload,
|
|
1715
|
+
type: jsonPayload.type || jsonPayload.itemType
|
|
1716
|
+
|| (jsonPayload.sourceProvider === "deepseek-harness" ? undefined : "commandExecution"),
|
|
1717
|
+
eventStatus: jsonPayload.status ?? existing?.eventStatus ?? "running",
|
|
1718
|
+
});
|
|
1719
|
+
// 输出增量不代表重新开始,已知终态及对应等级必须保留。
|
|
1720
|
+
if (["completed", "failed", "cancelled", "interrupted"].includes(existing?.eventStatus)) {
|
|
1721
|
+
metadata.eventStatus = existing.eventStatus;
|
|
1722
|
+
metadata.eventLevel = existing.eventLevel;
|
|
1723
|
+
}
|
|
1724
|
+
if (jsonPayload.sourceProvider === "deepseek-harness") {
|
|
1725
|
+
const previousDetail = existing?.details?.find((detail) => detail.title === "执行结果")?.body || "";
|
|
1726
|
+
const mergedOutput = `${previousDetail}${outputChunk}`;
|
|
1727
|
+
const command = String(jsonPayload.command || "").trim();
|
|
1728
|
+
const path = String(jsonPayload.path || "").trim();
|
|
1729
|
+
const summary = normalizeInlineText(jsonPayload.summary || "", 480);
|
|
1730
|
+
const toolName = normalizeInlineText(jsonPayload.toolName || "", 120);
|
|
1731
|
+
const retainedDetails = Array.isArray(existing?.details)
|
|
1732
|
+
? existing.details.filter((detail) => detail.title !== "执行结果")
|
|
1733
|
+
: buildEventDetails(
|
|
1734
|
+
message,
|
|
1735
|
+
jsonPayload,
|
|
1736
|
+
[
|
|
1737
|
+
...(command ? [{ title: "命令", body: command }] : []),
|
|
1738
|
+
...(path ? [{ title: "目标", body: path }] : []),
|
|
1739
|
+
],
|
|
1740
|
+
{ hideRawStructure: true },
|
|
1741
|
+
);
|
|
1742
|
+
upsertSessionView(views, viewById, {
|
|
1743
|
+
...metadata,
|
|
1744
|
+
eventType: "tool-call",
|
|
1745
|
+
id,
|
|
1746
|
+
kind: "event",
|
|
1747
|
+
label: existing?.label || toolName || "工具执行",
|
|
1748
|
+
text: existing?.text || summary || path || (command ? normalizeCommandText(command) : "工具执行中"),
|
|
1749
|
+
timestamp: message.timestamp,
|
|
1750
|
+
tone: existing?.tone || "",
|
|
1751
|
+
details: [
|
|
1752
|
+
...retainedDetails,
|
|
1753
|
+
{
|
|
1754
|
+
title: "执行结果",
|
|
1755
|
+
body: mergedOutput.trim() ? mergedOutput : "暂无输出",
|
|
1756
|
+
},
|
|
1757
|
+
],
|
|
1758
|
+
});
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1761
|
+
const previousDetail = existing?.details?.find((detail) => detail.title === "实时输出")?.body || "";
|
|
1762
|
+
const mergedOutput = `${previousDetail}${outputChunk}`;
|
|
1763
|
+
upsertSessionView(views, viewById, {
|
|
1764
|
+
...metadata,
|
|
1765
|
+
eventType: "tool-call",
|
|
1766
|
+
id,
|
|
1767
|
+
kind: "event",
|
|
1768
|
+
label: "输出流",
|
|
1769
|
+
text: existing?.text || "命令执行中",
|
|
1770
|
+
timestamp: message.timestamp,
|
|
1771
|
+
tone: "",
|
|
1772
|
+
details: buildEventDetails(
|
|
1773
|
+
message,
|
|
1774
|
+
jsonPayload,
|
|
1775
|
+
[{
|
|
1776
|
+
title: "实时输出",
|
|
1777
|
+
body: mergedOutput.trim() ? mergedOutput : "暂无输出",
|
|
1778
|
+
}],
|
|
1779
|
+
{ hideRawStructure: true },
|
|
1780
|
+
),
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
function normalizeGeneratedImageView(message) {
|
|
1785
|
+
if (message?.type !== "session-generated-image") {
|
|
1786
|
+
return null;
|
|
1787
|
+
}
|
|
1788
|
+
const payload = message.payload || {};
|
|
1789
|
+
const imageId = String(payload.imageId || "").trim();
|
|
1790
|
+
const sha256 = String(payload.sha256 || "").trim().toLowerCase();
|
|
1791
|
+
const relativePath = String(payload.relativePath || "").trim();
|
|
1792
|
+
const identity = imageId || sha256 || relativePath;
|
|
1793
|
+
if (!identity || !relativePath) {
|
|
1794
|
+
return null;
|
|
1795
|
+
}
|
|
1796
|
+
const turnId = String(payload.turnId || "").trim();
|
|
1797
|
+
const byteSize = Number(payload.byteSize);
|
|
1798
|
+
return {
|
|
1799
|
+
id: turnId ? `generated-images-${turnId}` : `generated-image-${identity}`,
|
|
1800
|
+
kind: "generated-image",
|
|
1801
|
+
label: "图片",
|
|
1802
|
+
text: String(payload.revisedPrompt || "").trim() || "生成图片",
|
|
1803
|
+
sessionId: String(message.sessionId || payload.sessionId || "").trim(),
|
|
1804
|
+
turnId,
|
|
1805
|
+
timestamp: message.timestamp,
|
|
1806
|
+
images: [{
|
|
1807
|
+
imageId,
|
|
1808
|
+
sha256,
|
|
1809
|
+
mimeType: String(payload.mimeType || "application/octet-stream").trim(),
|
|
1810
|
+
byteSize: Number.isFinite(byteSize) && byteSize > 0 ? Math.round(byteSize) : 0,
|
|
1811
|
+
relativePath,
|
|
1812
|
+
revisedPrompt: String(payload.revisedPrompt || "").trim(),
|
|
1813
|
+
}],
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
function generatedImageIdentity(image) {
|
|
1818
|
+
return String(image?.imageId || image?.sha256 || image?.relativePath || "").trim();
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
function appendGeneratedImageView(views, viewById, message) {
|
|
1822
|
+
const incoming = normalizeGeneratedImageView(message);
|
|
1823
|
+
if (!incoming) {
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
const existingIndex = viewById.get(incoming.id);
|
|
1827
|
+
if (existingIndex === undefined) {
|
|
1828
|
+
upsertSessionView(views, viewById, incoming);
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
const existing = views[existingIndex];
|
|
1832
|
+
const identities = new Set((existing.images || []).map(generatedImageIdentity));
|
|
1833
|
+
const image = incoming.images[0];
|
|
1834
|
+
const identity = generatedImageIdentity(image);
|
|
1835
|
+
if (!identity || identities.has(identity)) {
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
// 图片事件可能分多次到达;只在新增图片时推进时间,重复快照不改变视图。
|
|
1839
|
+
views[existingIndex] = {
|
|
1840
|
+
...existing,
|
|
1841
|
+
text: existing.text === "生成图片" ? incoming.text : existing.text,
|
|
1842
|
+
timestamp: incoming.timestamp,
|
|
1843
|
+
images: [...existing.images, image],
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
export function sessionMessageViews(entries, currentRequests = []) {
|
|
1848
|
+
const questions = questionIndex(entries, currentRequests);
|
|
1849
|
+
const views = [];
|
|
1850
|
+
const streamingByKey = new Map();
|
|
1851
|
+
const fallbackRef = { current: null };
|
|
1852
|
+
const viewById = new Map();
|
|
1853
|
+
const assistantByItemId = new Map();
|
|
1854
|
+
const assistantByTurnId = new Map();
|
|
1855
|
+
const pendingMemoryCitations = [];
|
|
1856
|
+
const seenMessages = new Set();
|
|
1857
|
+
const activeCompactions = new Map();
|
|
1858
|
+
const pendingPiViews = new Map();
|
|
1859
|
+
const upsertCompactionAware = (view) => {
|
|
1860
|
+
upsertSessionView(views, viewById, view);
|
|
1861
|
+
if (view.piEventType) {
|
|
1862
|
+
const current = views[viewById.get(view.id)];
|
|
1863
|
+
if (isPendingPiView(current)) pendingPiViews.set(view.id, current);
|
|
1864
|
+
else pendingPiViews.delete(view.id);
|
|
1865
|
+
}
|
|
1866
|
+
if (!view.compactionStatus) return;
|
|
1867
|
+
const current = views[viewById.get(view.id)];
|
|
1868
|
+
if (current.compactionStatus === "running") activeCompactions.set(view.id, current);
|
|
1869
|
+
else activeCompactions.delete(view.id);
|
|
1870
|
+
};
|
|
1871
|
+
const hasUnifiedTimeline = hasAgentTimelineEntries(entries);
|
|
1872
|
+
const unifiedTimelineTurnIds = hasUnifiedTimeline
|
|
1873
|
+
? agentTimelineCoveredTurnIds(entries)
|
|
1874
|
+
: new Set();
|
|
1875
|
+
|
|
1876
|
+
const registerAssistantView = (view) => {
|
|
1877
|
+
if (!view) {
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
if (view.itemId) {
|
|
1881
|
+
assistantByItemId.set(view.itemId, view);
|
|
1882
|
+
}
|
|
1883
|
+
if (view.turnId) {
|
|
1884
|
+
assistantByTurnId.set(view.turnId, view);
|
|
1885
|
+
}
|
|
1886
|
+
for (let index = pendingMemoryCitations.length - 1; index >= 0; index -= 1) {
|
|
1887
|
+
const citation = pendingMemoryCitations[index];
|
|
1888
|
+
const matchesItem = citation.itemId && citation.itemId === view.itemId;
|
|
1889
|
+
const matchesTurnWithoutItem = !citation.itemId
|
|
1890
|
+
&& citation.turnId
|
|
1891
|
+
&& citation.turnId === view.turnId;
|
|
1892
|
+
if (matchesItem || matchesTurnWithoutItem) {
|
|
1893
|
+
attachSessionMemoryCitation(view, citation);
|
|
1894
|
+
pendingMemoryCitations.splice(index, 1);
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
};
|
|
1898
|
+
|
|
1899
|
+
for (const entry of entries) {
|
|
1900
|
+
const messageKey = sessionEventMessageKey(entry);
|
|
1901
|
+
if (messageKey && seenMessages.has(messageKey)) {
|
|
1902
|
+
continue;
|
|
1903
|
+
}
|
|
1904
|
+
if (messageKey) {
|
|
1905
|
+
seenMessages.add(messageKey);
|
|
1906
|
+
}
|
|
1907
|
+
const message = entry?.message || entry;
|
|
1908
|
+
const payload = message?.payload || {};
|
|
1909
|
+
const jsonPayload = payload.jsonPayload || {};
|
|
1910
|
+
const item = jsonPayload.item || {};
|
|
1911
|
+
|
|
1912
|
+
if (message?.type === "session-finished" ||
|
|
1913
|
+
(message?.type === "session-output" && payload.eventType === "turn/completed")) {
|
|
1914
|
+
const turnId = jsonPayload.turnId || jsonPayload.turn?.id;
|
|
1915
|
+
for (const current of activeCompactions.values()) {
|
|
1916
|
+
if (message.type !== "session-finished" && (!turnId || turnId !== current.turnId)) continue;
|
|
1917
|
+
upsertCompactionAware(contextCompactionView({ status: "cancelled" }, current));
|
|
1918
|
+
}
|
|
1919
|
+
const status = jsonPayload.turn?.status || payload.status || payload.session?.status;
|
|
1920
|
+
for (const current of pendingPiViews.values()) {
|
|
1921
|
+
if (message.type !== 'session-finished' && (!turnId || turnId !== current.turnId)) continue;
|
|
1922
|
+
const closed = interruptPiView(current, status);
|
|
1923
|
+
if (closed) upsertCompactionAware(closed);
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
const request = ["input-requested", "input-resolved"].includes(message?.type)
|
|
1928
|
+
? questions.byId.get(payload.request?.id)
|
|
1929
|
+
: questions.byItem.get(item.id || jsonPayload.itemId);
|
|
1930
|
+
if (request) {
|
|
1931
|
+
upsertSessionView(views, viewById, inputQuestionView(request));
|
|
1932
|
+
continue;
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
const memoryCitation = normalizeSessionMemoryCitationView(message);
|
|
1936
|
+
if (memoryCitation) {
|
|
1937
|
+
const exactView = memoryCitation.itemId
|
|
1938
|
+
? assistantByItemId.get(memoryCitation.itemId)
|
|
1939
|
+
: null;
|
|
1940
|
+
const turnView = !memoryCitation.itemId && memoryCitation.turnId
|
|
1941
|
+
? assistantByTurnId.get(memoryCitation.turnId)
|
|
1942
|
+
: null;
|
|
1943
|
+
if (!attachSessionMemoryCitation(exactView || turnView, memoryCitation)) {
|
|
1944
|
+
pendingMemoryCitations.push(memoryCitation);
|
|
1945
|
+
}
|
|
1946
|
+
continue;
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
if (message?.type === "session-generated-image") {
|
|
1950
|
+
appendGeneratedImageView(views, viewById, message);
|
|
1951
|
+
continue;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
if (message?.type === "schedule-draft") {
|
|
1955
|
+
const draftView = scheduleDraftViewFromEvent(message);
|
|
1956
|
+
if (draftView) upsertSessionView(views, viewById, draftView);
|
|
1957
|
+
continue;
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
if (message?.type === "schedule-draft-updated") {
|
|
1961
|
+
const draftId = String(message.payload?.draftId || "").trim();
|
|
1962
|
+
const viewId = `schedule-draft-${draftId}`;
|
|
1963
|
+
const existingIndex = viewById.get(viewId);
|
|
1964
|
+
if (existingIndex !== undefined) {
|
|
1965
|
+
views[existingIndex] = applyScheduleDraftUpdate(views[existingIndex], message);
|
|
1966
|
+
}
|
|
1967
|
+
continue;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
if (message?.type === "schedule-run-result") {
|
|
1971
|
+
const resultView = scheduleRunResultViewFromEvent(message);
|
|
1972
|
+
if (resultView) upsertSessionView(views, viewById, resultView);
|
|
1973
|
+
continue;
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
if (message?.type === "session-plan-updated"
|
|
1977
|
+
|| (message?.type === "session-output" && payload.eventType === "turn/plan/updated")) {
|
|
1978
|
+
const planView = sessionPlanViewFromSnapshot(sessionPlanSnapshotFromMessage(message), message);
|
|
1979
|
+
if (planView) upsertSessionView(views, viewById, planView);
|
|
1980
|
+
continue;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
if (message?.type === "session-timeline") {
|
|
1984
|
+
const timelinePlanSnapshot = sessionPlanSnapshotFromMessage(message);
|
|
1985
|
+
const timelinePlanView = sessionPlanViewFromSnapshot(timelinePlanSnapshot, message);
|
|
1986
|
+
for (const timelineView of agentTimelineViews(message)) {
|
|
1987
|
+
upsertCompactionAware(timelineView);
|
|
1988
|
+
if (timelineView.kind === "assistant") {
|
|
1989
|
+
registerAssistantView(timelineView);
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
if (timelinePlanView) {
|
|
1993
|
+
upsertSessionView(views, viewById, timelinePlanView);
|
|
1994
|
+
}
|
|
1995
|
+
continue;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
// 新时间线已经包含同一批 Claude 内容时,不再同时渲染兼容 session-output。
|
|
1999
|
+
if (
|
|
2000
|
+
hasUnifiedTimeline
|
|
2001
|
+
&& message?.type === "session-output"
|
|
2002
|
+
&& unifiedTimelineTurnIds.has(String(jsonPayload.turnId || "").trim())
|
|
2003
|
+
) {
|
|
2004
|
+
continue;
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
if (message?.type === "session-output" && ["item/reasoning/textDelta", "item/reasoning/summaryTextDelta", "item/reasoning/completed"].includes(payload.eventType)) {
|
|
2008
|
+
const itemId = jsonPayload.itemId || item.id || jsonPayload.turnId || message.timestamp;
|
|
2009
|
+
const id = `reasoning-${itemId}`;
|
|
2010
|
+
const previous = views[viewById.get(id)];
|
|
2011
|
+
const ended = payload.eventType === 'item/reasoning/completed';
|
|
2012
|
+
if (!ended && previous?.reasoningComplete) continue;
|
|
2013
|
+
const body = ended ? String(jsonPayload.text || previous?.details?.[0]?.body || '')
|
|
2014
|
+
: `${previous?.details?.[0]?.body || ''}${payload.chunk || jsonPayload.delta || ''}`;
|
|
2015
|
+
upsertCompactionAware({ ...structuredEventFields(jsonPayload, ended ? 'completed' : 'running'),
|
|
2016
|
+
id, kind: 'event', label: '思考', piEventType: 'reasoning',
|
|
2017
|
+
sessionId: message.sessionId || payload.sessionId || '', itemId,
|
|
2018
|
+
text: ended ? jsonPayload.status === 'cancelled' ? '思考已中断' : jsonPayload.status === 'failed' ? '思考未完成' : '思考完成' : body,
|
|
2019
|
+
reasoningComplete: ended, eventType: 'reasoning',
|
|
2020
|
+
details: [{ title: '思考过程', body, expanded: false, agentContent: jsonPayload.textContent },
|
|
2021
|
+
...(jsonPayload.textTruncated ? [{ title: '提示', body: jsonPayload.textContent
|
|
2022
|
+
? '思考较长,已显示预览' : '思考预览已截断,完整内容未保留' }] : [])],
|
|
2023
|
+
timestamp: previous?.timestamp || message.timestamp, turnId: jsonPayload.turnId });
|
|
2024
|
+
continue;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
if (message?.type === "session-output" && payload.eventType === "item/completed" && item.type === "reasoning") {
|
|
2028
|
+
const itemId = item.id || jsonPayload.itemId || message.timestamp;
|
|
2029
|
+
const id = `reasoning-${itemId}`;
|
|
2030
|
+
const previous = views[viewById.get(id)];
|
|
2031
|
+
const body = extractReasoningItemText(item) || previous?.details?.[0]?.body || "";
|
|
2032
|
+
if (body) {
|
|
2033
|
+
upsertCompactionAware({
|
|
2034
|
+
...structuredEventFields({ ...jsonPayload, ...item }, "completed"),
|
|
2035
|
+
id,
|
|
2036
|
+
kind: "event",
|
|
2037
|
+
label: "思考",
|
|
2038
|
+
piEventType: "reasoning",
|
|
2039
|
+
sessionId: message.sessionId || payload.sessionId || "",
|
|
2040
|
+
itemId,
|
|
2041
|
+
text: "思考完成",
|
|
2042
|
+
reasoningComplete: true,
|
|
2043
|
+
eventType: "reasoning",
|
|
2044
|
+
details: [{ title: "思考过程", body, expanded: false, agentContent: jsonPayload.textContent }],
|
|
2045
|
+
timestamp: previous?.timestamp || message.timestamp,
|
|
2046
|
+
turnId: jsonPayload.turnId,
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
continue;
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
if (message?.type === "session-output" && jsonPayload.sourceProvider === "claude-code" && item.timelineItem) {
|
|
2053
|
+
const view = claudeToolView(message, payload);
|
|
2054
|
+
if (view) upsertCompactionAware(view);
|
|
2055
|
+
continue;
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
if (message?.type === "session-output" && payload.eventType === "item/agentMessage/delta") {
|
|
2059
|
+
registerAssistantView(
|
|
2060
|
+
appendAssistantDelta(views, streamingByKey, fallbackRef, message, payload, jsonPayload),
|
|
2061
|
+
);
|
|
2062
|
+
continue;
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
if (message?.type === "session-output" && payload.eventType === "item/completed" && item.type === "agentMessage") {
|
|
2066
|
+
registerAssistantView(
|
|
2067
|
+
completeAssistantMessage(views, streamingByKey, fallbackRef, message, payload, jsonPayload, item),
|
|
2068
|
+
);
|
|
2069
|
+
continue;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
if (message?.type === "session-output" && payload.eventType === "item/commandExecution/outputDelta") {
|
|
2073
|
+
appendCommandOutputDelta(views, viewById, message, payload, jsonPayload);
|
|
2074
|
+
continue;
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
const view = sessionMessageView(message);
|
|
2078
|
+
if (view) {
|
|
2079
|
+
if (view.eventType === "context/compaction-advisory" &&
|
|
2080
|
+
views.at(-1)?.compactionStatus === "completed") continue;
|
|
2081
|
+
if (view.kind === "user") {
|
|
2082
|
+
const previous = [...views].reverse().find((item) => item.kind !== "event");
|
|
2083
|
+
if (
|
|
2084
|
+
previous?.kind === "user"
|
|
2085
|
+
&& !message.payload?.clientUserMessageId
|
|
2086
|
+
&& previous.text.trim() === view.text.trim()
|
|
2087
|
+
&& messageContextSignature(previous) === messageContextSignature(view)
|
|
2088
|
+
) {
|
|
2089
|
+
continue;
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
upsertCompactionAware(view);
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
// 引用带有 itemId 时优先等待精确助手项,事件流结束后才按 turnId 降级关联。
|
|
2097
|
+
for (const citation of pendingMemoryCitations) {
|
|
2098
|
+
const view = citation.itemId ? assistantByItemId.get(citation.itemId) : null;
|
|
2099
|
+
attachSessionMemoryCitation(
|
|
2100
|
+
view || (citation.turnId ? assistantByTurnId.get(citation.turnId) : null),
|
|
2101
|
+
citation,
|
|
2102
|
+
);
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
return views;
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
export function sessionMessageCategory(view) {
|
|
2109
|
+
const details = Array.isArray(view.details) ? view.details : [];
|
|
2110
|
+
const detailTitles = details.map((detail) => detail.title || "").join(" ");
|
|
2111
|
+
const label = view.label || "";
|
|
2112
|
+
const text = view.text || "";
|
|
2113
|
+
if (view.kind === "assistant") {
|
|
2114
|
+
return "assistant";
|
|
2115
|
+
}
|
|
2116
|
+
if (view.kind === "plan") {
|
|
2117
|
+
return "status";
|
|
2118
|
+
}
|
|
2119
|
+
if (view.kind === "input-request" || view.kind === "schedule-draft" || view.kind === "schedule-run-result") {
|
|
2120
|
+
return "input";
|
|
2121
|
+
}
|
|
2122
|
+
if (view.kind === "error" || label.includes("错误")) {
|
|
2123
|
+
return "error";
|
|
2124
|
+
}
|
|
2125
|
+
if (label.includes("警告")) {
|
|
2126
|
+
return "warning";
|
|
2127
|
+
}
|
|
2128
|
+
if (label.includes("状态")) {
|
|
2129
|
+
return "status";
|
|
2130
|
+
}
|
|
2131
|
+
if (label.includes("授权")) {
|
|
2132
|
+
return "approval";
|
|
2133
|
+
}
|
|
2134
|
+
if (label.includes("输入")) {
|
|
2135
|
+
return "input";
|
|
2136
|
+
}
|
|
2137
|
+
// 结构化 shell 事件优先按命令分类;命令输出可能带有 Diff 详情,不能因此伪装成文件变更。
|
|
2138
|
+
if (view.toolType === "shell" || view.isCommand === true) {
|
|
2139
|
+
return "command";
|
|
2140
|
+
}
|
|
2141
|
+
if (
|
|
2142
|
+
label.includes("代码变更") ||
|
|
2143
|
+
detailTitles.includes("变更详情") ||
|
|
2144
|
+
detailTitles.includes("Diff 详情")
|
|
2145
|
+
) {
|
|
2146
|
+
return "file";
|
|
2147
|
+
}
|
|
2148
|
+
if (
|
|
2149
|
+
label.includes("命令") ||
|
|
2150
|
+
label.includes("输出流") ||
|
|
2151
|
+
text.includes("命令执行") ||
|
|
2152
|
+
detailTitles.includes("命令") ||
|
|
2153
|
+
detailTitles.includes("输出") ||
|
|
2154
|
+
detailTitles.includes("实时输出")
|
|
2155
|
+
) {
|
|
2156
|
+
return "command";
|
|
2157
|
+
}
|
|
2158
|
+
return view.kind || "event";
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
export function sessionMessageSearchText(view) {
|
|
2162
|
+
const details = Array.isArray(view.details) ? view.details : [];
|
|
2163
|
+
const memoryEntries = Array.isArray(view.memoryCitation?.entries)
|
|
2164
|
+
? view.memoryCitation.entries
|
|
2165
|
+
: [];
|
|
2166
|
+
return [
|
|
2167
|
+
view.label,
|
|
2168
|
+
view.text,
|
|
2169
|
+
view.kind,
|
|
2170
|
+
view.explanation,
|
|
2171
|
+
...(view.steps || []).map((step) => step?.step),
|
|
2172
|
+
...(view.attachments || []).flatMap((item) => [item.name, item.relativePath]),
|
|
2173
|
+
...(view.workspaceFileRefs || []).flatMap((item) => [item.name, item.path]),
|
|
2174
|
+
view.memoryCitation ? "引用了历史记忆" : "",
|
|
2175
|
+
view.memoryCitation?.sourceThreadCount
|
|
2176
|
+
? `${view.memoryCitation.sourceThreadCount} 个来源会话`
|
|
2177
|
+
: "",
|
|
2178
|
+
...scheduleDraftSearchTerms(view.draft),
|
|
2179
|
+
...scheduleRunResultSearchTerms(view.result),
|
|
2180
|
+
...memoryEntries.flatMap((item) => [item.sourceLabel, item.note]),
|
|
2181
|
+
...details.flatMap((detail) => [detail.title, detail.body]),
|
|
2182
|
+
].join(" ").toLowerCase();
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
export function compactEventText(value, maxLength = 180) {
|
|
2186
|
+
const normalized = String(value || "").replace(/\s+/g, " ").trim();
|
|
2187
|
+
if (!normalized) {
|
|
2188
|
+
return "事件已更新";
|
|
2189
|
+
}
|
|
2190
|
+
return normalized.length > maxLength ? `${normalized.slice(0, maxLength - 3)}...` : normalized;
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
import { piEventView, interruptPiView, isPendingPiView } from "./console-pi-events.js?v=process-tones-20261030";
|
|
2194
|
+
|
|
2195
|
+
export function sessionMessageView(entry) {
|
|
2196
|
+
const message = entry?.message || entry;
|
|
2197
|
+
const view = sessionMessageViewContent(entry);
|
|
2198
|
+
if (!view) return null;
|
|
2199
|
+
const payload = message.payload || {};
|
|
2200
|
+
const data = payload.jsonPayload || payload;
|
|
2201
|
+
const source = { ...data, ...data.item };
|
|
2202
|
+
const eventType = payload.eventType || "";
|
|
2203
|
+
const itemEvent = ["item/started", "item/completed"].includes(eventType);
|
|
2204
|
+
const level = message.type === "error" || eventType.startsWith("error") ? "error"
|
|
2205
|
+
: eventType.startsWith("warning") ? "warning" : source.level;
|
|
2206
|
+
const metadata = structuredEventFields({ ...source, level },
|
|
2207
|
+
message.type === "error" ? "failed" : itemEvent ? (eventType === "item/started" ? "running" : "completed") : undefined);
|
|
2208
|
+
return {
|
|
2209
|
+
...metadata,
|
|
2210
|
+
...(itemEvent ? {
|
|
2211
|
+
eventType: source.type === "reasoning" ? "reasoning" : "tool-call",
|
|
2212
|
+
callId: String(data.item?.id || data.itemId || ""),
|
|
2213
|
+
turnId: String(data.turnId || data.turn?.id || payload.turnId || ""),
|
|
2214
|
+
...(source.type === "collabAgentToolCall" && String(source.tool || "").toLowerCase() === "spawnagent"
|
|
2215
|
+
? { agentLaunch: true } : {}),
|
|
2216
|
+
} : {}),
|
|
2217
|
+
...view,
|
|
2218
|
+
};
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
function sessionMessageViewContent(entry) {
|
|
2222
|
+
const message = entry?.message || entry;
|
|
2223
|
+
if (!message) {
|
|
2224
|
+
return null;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
if (message.type === "session-user-input") {
|
|
2228
|
+
const text = message.payload?.prompt || "";
|
|
2229
|
+
if (!String(text).trim()) {
|
|
2230
|
+
return null;
|
|
2231
|
+
}
|
|
2232
|
+
return {
|
|
2233
|
+
id: message.payload?.clientUserMessageId || `user-${message.sessionId || ""}-${message.timestamp}`,
|
|
2234
|
+
kind: "user",
|
|
2235
|
+
label: "用户",
|
|
2236
|
+
text,
|
|
2237
|
+
timestamp: message.timestamp,
|
|
2238
|
+
markdown: false,
|
|
2239
|
+
sessionId: message.sessionId || "",
|
|
2240
|
+
attachments: normalizeMessageAttachments(message.payload?.attachments),
|
|
2241
|
+
workspaceFileRefs: normalizeMessageWorkspaceFileRefs(
|
|
2242
|
+
message.payload?.workspaceFileRefs,
|
|
2243
|
+
),
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
if (message.type === "error") {
|
|
2248
|
+
return {
|
|
2249
|
+
id: `error-${message.timestamp}`,
|
|
2250
|
+
kind: "error",
|
|
2251
|
+
label: "错误",
|
|
2252
|
+
text: message.payload?.message || "发生错误",
|
|
2253
|
+
timestamp: message.timestamp,
|
|
2254
|
+
markdown: false,
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
if (message.type === "approval-requested") {
|
|
2259
|
+
const approval = message.payload?.approval || {};
|
|
2260
|
+
const lines = ["检测到新的授权申请,请先确认后再继续执行。"];
|
|
2261
|
+
if (approval.summary) {
|
|
2262
|
+
lines.push(`待确认内容:${approval.summary}`);
|
|
2263
|
+
}
|
|
2264
|
+
if (approval.reason) {
|
|
2265
|
+
lines.push(`触发原因:${approval.reason}`);
|
|
2266
|
+
}
|
|
2267
|
+
return {
|
|
2268
|
+
id: `approval-requested-${approval.id || message.timestamp}`,
|
|
2269
|
+
kind: "event",
|
|
2270
|
+
label: "授权申请",
|
|
2271
|
+
text: lines.join("\n"),
|
|
2272
|
+
timestamp: message.timestamp,
|
|
2273
|
+
tone: "warning",
|
|
2274
|
+
details: buildEventDetails(message, approval, [
|
|
2275
|
+
...(approval.command ? [{ title: "命令", body: approval.command }] : []),
|
|
2276
|
+
...(approval.cwd ? [{ title: "工作目录", body: approval.cwd }] : []),
|
|
2277
|
+
...(approval.requestMethod ? [{ title: "授权类型", body: approval.requestMethod }] : []),
|
|
2278
|
+
...(approval.sourceEventType ? [{ title: "来源事件", body: approval.sourceEventType }] : []),
|
|
2279
|
+
]),
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
if (message.type === "approval-resolved") {
|
|
2284
|
+
const approval = message.payload?.approval || {};
|
|
2285
|
+
const decision = message.payload?.decision || approval.status || "";
|
|
2286
|
+
const decisionNote = approval.decisionNote || "";
|
|
2287
|
+
const lines = [];
|
|
2288
|
+
if (decisionNote === "auto-approved-for-workspace") {
|
|
2289
|
+
lines.push("该授权已按当前项目规则自动放行。");
|
|
2290
|
+
} else if (decisionNote === "always-approved-for-workspace") {
|
|
2291
|
+
lines.push("该授权已处理,并已加入当前项目的自动允许规则。");
|
|
2292
|
+
} else if (decision === "approved") {
|
|
2293
|
+
lines.push("该授权已批准,本轮继续执行。");
|
|
2294
|
+
} else if (decision === "rejected") {
|
|
2295
|
+
lines.push("该授权已拒绝,本轮已停止继续执行。");
|
|
2296
|
+
} else {
|
|
2297
|
+
lines.push("该授权状态已更新。");
|
|
2298
|
+
}
|
|
2299
|
+
if (approval.summary) {
|
|
2300
|
+
lines.push(`处理内容:${approval.summary}`);
|
|
2301
|
+
}
|
|
2302
|
+
return {
|
|
2303
|
+
id: `approval-resolved-${approval.id || message.timestamp}-${decisionNote || decision}`,
|
|
2304
|
+
kind: "event",
|
|
2305
|
+
label: "授权结果",
|
|
2306
|
+
text: lines.join("\n"),
|
|
2307
|
+
timestamp: message.timestamp,
|
|
2308
|
+
tone: "warning",
|
|
2309
|
+
details: buildEventDetails(message, approval, [
|
|
2310
|
+
...(approval.resolvedAt ? [{ title: "处理时间", body: approval.resolvedAt }] : []),
|
|
2311
|
+
...(approval.command ? [{ title: "命令", body: approval.command }] : []),
|
|
2312
|
+
...(approval.cwd ? [{ title: "工作目录", body: approval.cwd }] : []),
|
|
2313
|
+
]),
|
|
2314
|
+
};
|
|
2315
|
+
}
|
|
2316
|
+
|
|
2317
|
+
if (message.type === "input-requested") {
|
|
2318
|
+
const request = message.payload?.request || {};
|
|
2319
|
+
const questions = Array.isArray(request.questions) ? request.questions : [];
|
|
2320
|
+
const detailBody = questions.map((question) => {
|
|
2321
|
+
const options = Array.isArray(question.options) ? question.options.map((option) => option.label).filter(Boolean).join(" / ") : "";
|
|
2322
|
+
return `${question.header || "未命名问题"}\n${question.question || ""}${options ? `\n可选项:${options}` : ""}`;
|
|
2323
|
+
}).join("\n\n");
|
|
2324
|
+
return {
|
|
2325
|
+
id: `input-requested-${request.id || message.timestamp}`,
|
|
2326
|
+
kind: "event",
|
|
2327
|
+
label: "输入请求",
|
|
2328
|
+
text: "AI 助手需要你补充一个选择项后才能继续。",
|
|
2329
|
+
timestamp: message.timestamp,
|
|
2330
|
+
tone: "warning",
|
|
2331
|
+
details: buildEventDetails(message, request, [{
|
|
2332
|
+
title: "问题详情",
|
|
2333
|
+
body: detailBody || "无题目明细",
|
|
2334
|
+
}]),
|
|
2335
|
+
};
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
if (message.type === "input-resolved") {
|
|
2339
|
+
const request = message.payload?.request || {};
|
|
2340
|
+
const answers = request.answers || {};
|
|
2341
|
+
const answerBody = Object.entries(answers).map(([key, value]) => `${key}: ${Array.isArray(value) ? value.join(" / ") : value}`).join("\n");
|
|
2342
|
+
return {
|
|
2343
|
+
id: `input-resolved-${request.id || message.timestamp}`,
|
|
2344
|
+
kind: "event",
|
|
2345
|
+
label: "输入完成",
|
|
2346
|
+
text: "选择项已提交,AI 助手将按你的选择继续执行。",
|
|
2347
|
+
timestamp: message.timestamp,
|
|
2348
|
+
tone: "warning",
|
|
2349
|
+
details: buildEventDetails(message, request, [{
|
|
2350
|
+
title: "已提交答案",
|
|
2351
|
+
body: answerBody || "无答案明细",
|
|
2352
|
+
}]),
|
|
2353
|
+
};
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
if (message.type === "session-status") {
|
|
2357
|
+
return null;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
if (message.type === "session-finished") {
|
|
2361
|
+
const status = message.payload?.status || message.payload?.session?.status;
|
|
2362
|
+
return {
|
|
2363
|
+
id: `finish-${message.sessionId || ""}-${message.timestamp}`,
|
|
2364
|
+
kind: "event",
|
|
2365
|
+
label: "状态",
|
|
2366
|
+
text: status === "completed" ? "本次会话已完成" : status === "failed" ? "本次会话执行失败" : status === "cancelled" ? "本次会话已取消" : "本次会话已结束",
|
|
2367
|
+
timestamp: message.timestamp,
|
|
2368
|
+
sessionStatus: status || "",
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
if (message.type !== "session-output") {
|
|
2373
|
+
return null;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
const payload = message.payload || {};
|
|
2377
|
+
const jsonPayload = payload.jsonPayload || {};
|
|
2378
|
+
const item = jsonPayload.item || {};
|
|
2379
|
+
const antigravityView = antigravityEventView(message, payload);
|
|
2380
|
+
if (antigravityView) return antigravityView;
|
|
2381
|
+
// 统计快照只更新指示器,不因 JSON 较长而落到通用正文兜底。
|
|
2382
|
+
if (["claude-code/toolSnapshot", "thread/tokenUsage/updated", "thread/contextUsage/updated"].includes(payload.eventType)) return null;
|
|
2383
|
+
const claudeView = claudeToolView(message, payload);
|
|
2384
|
+
if (claudeView) return claudeView;
|
|
2385
|
+
const piView = piEventView(message, payload);
|
|
2386
|
+
if (piView) return piView;
|
|
2387
|
+
if (payload.eventType === "pi-agent/inputStatus") {
|
|
2388
|
+
const labels = { queued: jsonPayload.mode === "followUp" ? "输入已排队" : "插话已提交", sent: "输入已送入模型", cancelled: "输入未处理,已取消", failed: "输入未送入,请重试" };
|
|
2389
|
+
const status = jsonPayload.status;
|
|
2390
|
+
if (!jsonPayload.inputId || !labels[status]) return null;
|
|
2391
|
+
return { id: `pi-input-${jsonPayload.turnId}-${jsonPayload.inputId}`, kind: "event", label: "输入状态",
|
|
2392
|
+
text: labels[status], timestamp: message.timestamp, tone: status === "failed" ? "danger" : "muted",
|
|
2393
|
+
turnId: jsonPayload.turnId, piEventType: payload.eventType, piStatus: status };
|
|
2394
|
+
}
|
|
2395
|
+
if ((payload.eventType === "item/started" || payload.eventType === "item/completed") &&
|
|
2396
|
+
item.type === "contextCompaction") {
|
|
2397
|
+
if (!item.id) return null;
|
|
2398
|
+
return contextCompactionView({
|
|
2399
|
+
trigger: item.trigger, error: item.error, summary: item.summary, summaryContent: item.summaryContent,
|
|
2400
|
+
summaryTruncated: item.summaryTruncated, tokensBefore: item.tokensBefore,
|
|
2401
|
+
status: ["failed", "cancelled"].includes(item.status) ? item.status
|
|
2402
|
+
: payload.eventType === "item/started" ? "running" : "completed",
|
|
2403
|
+
}, { id: item.id, itemId: item.id, sessionId: message.sessionId || payload.sessionId || "", timestamp: message.timestamp, turnId: jsonPayload.turnId });
|
|
2404
|
+
}
|
|
2405
|
+
if (payload.eventType === "item/completed" && item.type === "collabAgentToolCall") {
|
|
2406
|
+
return {
|
|
2407
|
+
id: `started-${jsonPayload.itemId || item.id || message.timestamp}`,
|
|
2408
|
+
kind: "event",
|
|
2409
|
+
label: item.tool || "子 Agent 调度",
|
|
2410
|
+
text: `${item.tool || "子 Agent 调度"} · ${item.status === "failed" ? "执行失败" : "已完成"}`,
|
|
2411
|
+
timestamp: message.timestamp,
|
|
2412
|
+
details: buildEventDetails(message, jsonPayload),
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2415
|
+
if (payload.eventType === "item/completed" && item.type === "agentMessage") {
|
|
2416
|
+
return null;
|
|
2417
|
+
}
|
|
2418
|
+
if (payload.eventType === "item/agentMessage/delta") {
|
|
2419
|
+
return null;
|
|
2420
|
+
}
|
|
2421
|
+
if (payload.eventType === "item/completed" && item.type === "commandExecution") {
|
|
2422
|
+
const command = item.command || "未知命令";
|
|
2423
|
+
const output = item.aggregatedOutput || "";
|
|
2424
|
+
const exitCode = item.exitCode == null ? "未知" : String(item.exitCode);
|
|
2425
|
+
return {
|
|
2426
|
+
id: `command-${item.id || message.timestamp}`,
|
|
2427
|
+
kind: "event",
|
|
2428
|
+
label: commandTag(command),
|
|
2429
|
+
text: normalizeInlineText(normalizeCommandText(command), 480),
|
|
2430
|
+
timestamp: message.timestamp,
|
|
2431
|
+
details: buildEventDetails(message, jsonPayload, [
|
|
2432
|
+
{ title: "命令", body: command },
|
|
2433
|
+
{ title: "输出", body: output || "无输出" },
|
|
2434
|
+
{ title: "退出码", body: exitCode },
|
|
2435
|
+
...(item.phase ? [{ title: "阶段", body: item.phase }] : []),
|
|
2436
|
+
]),
|
|
2437
|
+
};
|
|
2438
|
+
}
|
|
2439
|
+
if (payload.eventType === "item/completed" && item.type === "fileChange") {
|
|
2440
|
+
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
2441
|
+
const fileNames = changes.slice(0, 3).map((change) => String(change.path || "未知文件").split("/").pop());
|
|
2442
|
+
const suffix = changes.length > 3 ? ` 等 ${changes.length} 个文件` : "";
|
|
2443
|
+
const detailBody = changes.map((change) => `${change.path || "未知路径"}\n${change.diff || ""}`).join("\n\n");
|
|
2444
|
+
return {
|
|
2445
|
+
id: `file-change-${item.id || message.timestamp}`,
|
|
2446
|
+
kind: "event",
|
|
2447
|
+
label: "代码变更",
|
|
2448
|
+
text: normalizeInlineText(fileNames.length ? `${fileNames.join("、")}${suffix}` : "文件变更", 480),
|
|
2449
|
+
timestamp: message.timestamp,
|
|
2450
|
+
details: buildEventDetails(message, jsonPayload, [
|
|
2451
|
+
{ title: "摘要", body: changes.length ? `${changes.length} 个文件变更` : "文件变更" },
|
|
2452
|
+
{ title: "变更详情", body: detailBody || "无明细" },
|
|
2453
|
+
]),
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
if (payload.eventType === "turn/diff/updated") {
|
|
2458
|
+
const diff = jsonPayload.diff || payload.chunk || "";
|
|
2459
|
+
return {
|
|
2460
|
+
id: `diff-${message.timestamp}`,
|
|
2461
|
+
kind: "event",
|
|
2462
|
+
label: "代码变更",
|
|
2463
|
+
text: "本轮生成了代码变更",
|
|
2464
|
+
timestamp: message.timestamp,
|
|
2465
|
+
details: buildEventDetails(message, jsonPayload, [{
|
|
2466
|
+
title: "Diff 详情",
|
|
2467
|
+
body: diff || "无 diff 内容",
|
|
2468
|
+
}]),
|
|
2469
|
+
};
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
if (payload.eventType === "foreground/approval-alert") {
|
|
2473
|
+
const summary = String(jsonPayload.summary || "").trim();
|
|
2474
|
+
const reason = String(jsonPayload.reason || "").trim();
|
|
2475
|
+
const lines = ["检测到新的待授权操作,请先完成确认后再继续执行。"];
|
|
2476
|
+
if (summary) {
|
|
2477
|
+
lines.push(`待确认内容:${summary}`);
|
|
2478
|
+
}
|
|
2479
|
+
if (reason) {
|
|
2480
|
+
lines.push(`触发原因:${reason}`);
|
|
2481
|
+
}
|
|
2482
|
+
return {
|
|
2483
|
+
id: `foreground-approval-${message.sessionId || ""}-${message.timestamp}`,
|
|
2484
|
+
kind: "event",
|
|
2485
|
+
label: "授权申请",
|
|
2486
|
+
text: lines.join("\n"),
|
|
2487
|
+
timestamp: message.timestamp,
|
|
2488
|
+
tone: "warning",
|
|
2489
|
+
};
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
if (String(payload.eventType || "").startsWith("warning") || String(payload.eventType || "").startsWith("error")) {
|
|
2493
|
+
const text = warningOrErrorText({ eventType: payload.eventType || "", chunk: payload.chunk || "", jsonPayload, payload });
|
|
2494
|
+
if (String(payload.eventType || "").startsWith("warning") && isCompactionAdvisory(text)) {
|
|
2495
|
+
return compactionAdvisoryView({ id: `system-${message.timestamp}`, timestamp: message.timestamp });
|
|
2496
|
+
}
|
|
2497
|
+
return {
|
|
2498
|
+
id: `system-${message.timestamp}`,
|
|
2499
|
+
kind: "event",
|
|
2500
|
+
label: String(payload.eventType || "").startsWith("error") ? "错误" : "警告",
|
|
2501
|
+
text,
|
|
2502
|
+
timestamp: message.timestamp,
|
|
2503
|
+
tone: String(payload.eventType || "").startsWith("error") ? "danger" : "warning",
|
|
2504
|
+
details: buildEventDetails(message, jsonPayload),
|
|
2505
|
+
};
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
// -- 扩展事件类型:工具开始、思考、子任务、内存回忆、通知 --
|
|
2509
|
+
|
|
2510
|
+
if (payload.eventType === "provider/contextInjected") {
|
|
2511
|
+
const label = normalizeInlineText(jsonPayload.label || "运行时上下文", 480);
|
|
2512
|
+
const path = String(jsonPayload.path || "").trim();
|
|
2513
|
+
return {
|
|
2514
|
+
id: `context-${jsonPayload.itemId || message.timestamp}`,
|
|
2515
|
+
kind: "event",
|
|
2516
|
+
label: "上下文注入",
|
|
2517
|
+
text: label,
|
|
2518
|
+
timestamp: message.timestamp,
|
|
2519
|
+
tone: "muted",
|
|
2520
|
+
details: buildEventDetails(
|
|
2521
|
+
message,
|
|
2522
|
+
jsonPayload,
|
|
2523
|
+
path && path !== label ? [{ title: "目标", body: path }] : [],
|
|
2524
|
+
{ hideRawStructure: true },
|
|
2525
|
+
),
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
// 有些历史窗口只保留启动调用的回执;与开始帧共用 started-ID,不生成第二个派发行。
|
|
2530
|
+
if (payload.eventType === "item/started" || (payload.eventType === "item/completed"
|
|
2531
|
+
&& item.type === "subAgentActivity" && item.kind === "started")) {
|
|
2532
|
+
const itemType = String(item.type || jsonPayload.itemType || "").trim();
|
|
2533
|
+
const toolName = normalizeInlineText(
|
|
2534
|
+
item.toolName
|
|
2535
|
+
|| jsonPayload.toolName
|
|
2536
|
+
|| item.tool
|
|
2537
|
+
|| jsonPayload.tool
|
|
2538
|
+
|| item.name
|
|
2539
|
+
|| jsonPayload.name
|
|
2540
|
+
|| "",
|
|
2541
|
+
120,
|
|
2542
|
+
);
|
|
2543
|
+
const command = String(item.command || jsonPayload.command || "").trim();
|
|
2544
|
+
const path = String(item.path || jsonPayload.path || "").trim();
|
|
2545
|
+
const summary = normalizeInlineText(item.summary || jsonPayload.summary || "", 480);
|
|
2546
|
+
const sourceProvider = String(jsonPayload.sourceProvider || "").trim();
|
|
2547
|
+
const itemId = jsonPayload.itemId || item.id || message.timestamp;
|
|
2548
|
+
const isDeepSeekHarness = sourceProvider === "deepseek-harness";
|
|
2549
|
+
const agentDescription = normalizeInlineText(
|
|
2550
|
+
item.agentDescription || item.description || item.agentId || jsonPayload.agentDescription || "",
|
|
2551
|
+
160,
|
|
2552
|
+
);
|
|
2553
|
+
const isSubAgent = itemType === "subAgentActivity";
|
|
2554
|
+
const structuredLabel = Object.prototype.hasOwnProperty.call(STARTED_TOOL_TYPE_LABELS, itemType)
|
|
2555
|
+
? STARTED_TOOL_TYPE_LABELS[itemType]
|
|
2556
|
+
: "";
|
|
2557
|
+
|
|
2558
|
+
// Codex 某些版本只发送 threadId/turnId 的裸开始事件;它不包含可展示信息,
|
|
2559
|
+
// 继续渲染只会形成“执行工具:”空卡片并放大长会话的 DOM 开销。
|
|
2560
|
+
if (!isSubAgent && !toolName && !structuredLabel && !command) {
|
|
2561
|
+
return null;
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
const label = isSubAgent
|
|
2565
|
+
? (agentDescription || "子任务")
|
|
2566
|
+
: (toolName || structuredLabel || "工具执行");
|
|
2567
|
+
let text;
|
|
2568
|
+
if (isDeepSeekHarness && summary) {
|
|
2569
|
+
text = summary;
|
|
2570
|
+
} else if (isSubAgent) {
|
|
2571
|
+
text = agentDescription ? `启动子任务:${agentDescription}` : "正在启动子任务";
|
|
2572
|
+
} else if (itemType === "commandExecution") {
|
|
2573
|
+
text = command ? `执行命令:${normalizeInlineText(normalizeCommandText(command), 480)}` : "正在执行命令";
|
|
2574
|
+
} else if (itemType === "fileChange") {
|
|
2575
|
+
text = "正在修改文件";
|
|
2576
|
+
} else if (itemType === "imageGeneration") {
|
|
2577
|
+
text = "正在生成图片";
|
|
2578
|
+
} else if (itemType === "webSearch") {
|
|
2579
|
+
text = "正在联网搜索";
|
|
2580
|
+
} else {
|
|
2581
|
+
text = toolName ? `执行工具:${toolName}` : "正在执行工具";
|
|
2582
|
+
}
|
|
2583
|
+
return {
|
|
2584
|
+
id: isDeepSeekHarness || itemType === "commandExecution" ? `command-${itemId}` : `started-${itemId}`,
|
|
2585
|
+
kind: "event",
|
|
2586
|
+
label,
|
|
2587
|
+
text,
|
|
2588
|
+
timestamp: message.timestamp,
|
|
2589
|
+
details: buildEventDetails(
|
|
2590
|
+
message,
|
|
2591
|
+
jsonPayload,
|
|
2592
|
+
isDeepSeekHarness
|
|
2593
|
+
? [
|
|
2594
|
+
...(command ? [{ title: "命令", body: command }] : []),
|
|
2595
|
+
...(path ? [{ title: "目标", body: path }] : []),
|
|
2596
|
+
]
|
|
2597
|
+
: [],
|
|
2598
|
+
{ hideRawStructure: isDeepSeekHarness },
|
|
2599
|
+
),
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
if (payload.eventType === "item/agentMessage/thinking") {
|
|
2604
|
+
const tokens = jsonPayload.thinkingTokens || 0;
|
|
2605
|
+
return {
|
|
2606
|
+
id: `thinking-${message.timestamp}`,
|
|
2607
|
+
eventType: "reasoning",
|
|
2608
|
+
...structuredEventFields(jsonPayload, "running"),
|
|
2609
|
+
kind: "event",
|
|
2610
|
+
label: "思考中",
|
|
2611
|
+
text: `已使用 ${tokens.toLocaleString()} thinking tokens`,
|
|
2612
|
+
timestamp: message.timestamp,
|
|
2613
|
+
tone: "muted",
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
if (payload.eventType === "session/memory-recall") {
|
|
2618
|
+
const recall = jsonPayload.memoryRecall || {};
|
|
2619
|
+
return {
|
|
2620
|
+
id: `memory-${message.timestamp}`,
|
|
2621
|
+
kind: "event",
|
|
2622
|
+
label: "记忆回忆",
|
|
2623
|
+
text: `回忆了 ${recall.count || 0} 条${recall.mode === "synthesize" ? "综合" : ""}记忆`,
|
|
2624
|
+
timestamp: message.timestamp,
|
|
2625
|
+
};
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
if (String(payload.eventType || "").startsWith("info/")) {
|
|
2629
|
+
const text = jsonPayload.message || payload.chunk || "";
|
|
2630
|
+
if (text) {
|
|
2631
|
+
return {
|
|
2632
|
+
id: `info-${message.timestamp}`,
|
|
2633
|
+
kind: "event",
|
|
2634
|
+
label: "信息",
|
|
2635
|
+
text,
|
|
2636
|
+
timestamp: message.timestamp,
|
|
2637
|
+
tone: "muted",
|
|
2638
|
+
};
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
// -- Fallback:未知 eventType 但有 chunk 文本时,作为通用事件显示 --
|
|
2643
|
+
if (payload.chunk && String(payload.chunk).trim()) {
|
|
2644
|
+
const chunkText = String(payload.chunk).trim();
|
|
2645
|
+
// 跳过纯 JSON 状态更新(如 tokenUsage)
|
|
2646
|
+
if (!chunkText.startsWith("{") || chunkText.length > 200) {
|
|
2647
|
+
return {
|
|
2648
|
+
id: `event-${message.timestamp}`,
|
|
2649
|
+
kind: "event",
|
|
2650
|
+
label: String(payload.eventType || "事件").split("/").pop() || "事件",
|
|
2651
|
+
text: chunkText.length > 500 ? `${chunkText.slice(0, 500)}…` : chunkText,
|
|
2652
|
+
timestamp: message.timestamp,
|
|
2653
|
+
tone: "muted",
|
|
2654
|
+
};
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
return null;
|
|
2659
|
+
}
|