@waq666/pneuma 0.0.0-stage → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +144 -2
- package/bin/dsc.js +91 -0
- package/bin/headless.cjs +40 -0
- package/lib/adapter/core-runtime.d.ts +11 -0
- package/lib/adapter/core-runtime.js +259 -0
- package/lib/adapter/host.d.ts +18 -0
- package/lib/adapter/host.js +14 -0
- package/lib/adapter/runtime.d.ts +15 -0
- package/lib/adapter/runtime.js +290 -0
- package/lib/adapter/transcript.d.ts +184 -0
- package/lib/adapter/transcript.js +605 -0
- package/lib/app/AgentsOverlay.d.ts +18 -0
- package/lib/app/AgentsOverlay.js +63 -0
- package/lib/app/App.d.ts +13 -0
- package/lib/app/App.js +1498 -0
- package/lib/app/ApprovalCard.d.ts +12 -0
- package/lib/app/ApprovalCard.js +76 -0
- package/lib/app/AskCard.d.ts +20 -0
- package/lib/app/AskCard.js +45 -0
- package/lib/app/ChatView.d.ts +32 -0
- package/lib/app/ChatView.js +198 -0
- package/lib/app/Composer.d.ts +50 -0
- package/lib/app/Composer.js +282 -0
- package/lib/app/DiffBlock.d.ts +6 -0
- package/lib/app/DiffBlock.js +37 -0
- package/lib/app/MarkdownView.d.ts +6 -0
- package/lib/app/MarkdownView.js +99 -0
- package/lib/app/ModelPicker.d.ts +7 -0
- package/lib/app/ModelPicker.js +18 -0
- package/lib/app/PlanReviewCard.d.ts +13 -0
- package/lib/app/PlanReviewCard.js +54 -0
- package/lib/app/PresetPicker.d.ts +11 -0
- package/lib/app/PresetPicker.js +19 -0
- package/lib/app/PreviewOverlay.d.ts +14 -0
- package/lib/app/PreviewOverlay.js +22 -0
- package/lib/app/SessionPicker.d.ts +43 -0
- package/lib/app/SessionPicker.js +56 -0
- package/lib/app/SettingsOverlay.d.ts +32 -0
- package/lib/app/SettingsOverlay.js +157 -0
- package/lib/app/SkillsPicker.d.ts +7 -0
- package/lib/app/SkillsPicker.js +19 -0
- package/lib/app/StatusBar.d.ts +22 -0
- package/lib/app/StatusBar.js +272 -0
- package/lib/app/TaskStrips.d.ts +13 -0
- package/lib/app/TaskStrips.js +40 -0
- package/lib/app/ToolCard.d.ts +5 -0
- package/lib/app/ToolCard.js +40 -0
- package/lib/app/TranscriptOverlay.d.ts +12 -0
- package/lib/app/TranscriptOverlay.js +17 -0
- package/lib/app/Welcome.d.ts +6 -0
- package/lib/app/Welcome.js +66 -0
- package/lib/app/attach.d.ts +16 -0
- package/lib/app/attach.js +58 -0
- package/lib/app/click.d.ts +27 -0
- package/lib/app/click.js +89 -0
- package/lib/app/clipboard-image.d.ts +11 -0
- package/lib/app/clipboard-image.js +66 -0
- package/lib/app/cursor.d.ts +4 -0
- package/lib/app/cursor.js +24 -0
- package/lib/app/hello.d.ts +11 -0
- package/lib/app/hello.js +8 -0
- package/lib/app/history-store.d.ts +4 -0
- package/lib/app/history-store.js +41 -0
- package/lib/app/image-blocks.d.ts +12 -0
- package/lib/app/image-blocks.js +125 -0
- package/lib/app/markdown.d.ts +54 -0
- package/lib/app/markdown.js +189 -0
- package/lib/app/settings-model.d.ts +69 -0
- package/lib/app/settings-model.js +114 -0
- package/lib/app/theme.d.ts +166 -0
- package/lib/app/theme.js +141 -0
- package/lib/boot.d.ts +1 -0
- package/lib/boot.js +34 -0
- package/lib/commands.d.ts +49 -0
- package/lib/commands.js +115 -0
- package/lib/contract.d.ts +1973 -0
- package/lib/contract.js +36 -0
- package/lib/core/agent-roles.d.ts +52 -0
- package/lib/core/agent-roles.js +274 -0
- package/lib/core/approval-floor.d.ts +183 -0
- package/lib/core/approval-floor.js +679 -0
- package/lib/core/approval.d.ts +42 -0
- package/lib/core/approval.js +8 -0
- package/lib/core/audit.d.ts +61 -0
- package/lib/core/audit.js +59 -0
- package/lib/core/boot-notices.d.ts +6 -0
- package/lib/core/boot-notices.js +61 -0
- package/lib/core/cdp/actions.d.ts +182 -0
- package/lib/core/cdp/actions.js +649 -0
- package/lib/core/cdp/launch.d.ts +192 -0
- package/lib/core/cdp/launch.js +491 -0
- package/lib/core/cdp/snapshot.d.ts +139 -0
- package/lib/core/cdp/snapshot.js +316 -0
- package/lib/core/cdp/transport.d.ts +160 -0
- package/lib/core/cdp/transport.js +359 -0
- package/lib/core/command-policy.d.ts +108 -0
- package/lib/core/command-policy.js +580 -0
- package/lib/core/commands-completion.d.ts +78 -0
- package/lib/core/commands-completion.js +167 -0
- package/lib/core/compact-anchors.d.ts +76 -0
- package/lib/core/compact-anchors.js +284 -0
- package/lib/core/compact.d.ts +110 -0
- package/lib/core/compact.js +210 -0
- package/lib/core/config-store.d.ts +38 -0
- package/lib/core/config-store.js +307 -0
- package/lib/core/config.d.ts +36 -0
- package/lib/core/config.js +124 -0
- package/lib/core/connection-test.d.ts +60 -0
- package/lib/core/connection-test.js +84 -0
- package/lib/core/desktop-control.d.ts +298 -0
- package/lib/core/desktop-control.js +1311 -0
- package/lib/core/diff-text.d.ts +74 -0
- package/lib/core/diff-text.js +257 -0
- package/lib/core/dock-browser.d.ts +137 -0
- package/lib/core/dock-browser.js +146 -0
- package/lib/core/dock-ops.d.ts +59 -0
- package/lib/core/dock-ops.js +104 -0
- package/lib/core/dock-session.d.ts +39 -0
- package/lib/core/dock-session.js +28 -0
- package/lib/core/dsh-compat/hook.d.ts +18 -0
- package/lib/core/dsh-compat/hook.js +52 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
- package/lib/core/dsh-compat/resolve-hook.js +59 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
- package/lib/core/dsh-compat/tools-facade.js +108 -0
- package/lib/core/err-text.d.ts +13 -0
- package/lib/core/err-text.js +15 -0
- package/lib/core/events.d.ts +149 -0
- package/lib/core/events.js +1 -0
- package/lib/core/git-exec.d.ts +23 -0
- package/lib/core/git-exec.js +72 -0
- package/lib/core/git-info.d.ts +47 -0
- package/lib/core/git-info.js +157 -0
- package/lib/core/goal.d.ts +89 -0
- package/lib/core/goal.js +189 -0
- package/lib/core/hooks.d.ts +272 -0
- package/lib/core/hooks.js +818 -0
- package/lib/core/host-browser-link.d.ts +59 -0
- package/lib/core/host-browser-link.js +9 -0
- package/lib/core/host-methods.d.ts +25 -0
- package/lib/core/host-methods.js +103 -0
- package/lib/core/image-diet.d.ts +77 -0
- package/lib/core/image-diet.js +127 -0
- package/lib/core/learnings/ledger.d.ts +73 -0
- package/lib/core/learnings/ledger.js +273 -0
- package/lib/core/learnings/skill-write.d.ts +250 -0
- package/lib/core/learnings/skill-write.js +854 -0
- package/lib/core/learnings/store.d.ts +102 -0
- package/lib/core/learnings/store.js +266 -0
- package/lib/core/lifecycle-hooks.d.ts +189 -0
- package/lib/core/lifecycle-hooks.js +576 -0
- package/lib/core/llm.d.ts +272 -0
- package/lib/core/llm.js +548 -0
- package/lib/core/lockfile.d.ts +17 -0
- package/lib/core/lockfile.js +110 -0
- package/lib/core/loop.d.ts +185 -0
- package/lib/core/loop.js +587 -0
- package/lib/core/lsp/client.d.ts +189 -0
- package/lib/core/lsp/client.js +690 -0
- package/lib/core/lsp/framing.d.ts +84 -0
- package/lib/core/lsp/framing.js +181 -0
- package/lib/core/lsp/line-shift.d.ts +28 -0
- package/lib/core/lsp/line-shift.js +127 -0
- package/lib/core/lsp/manager.d.ts +93 -0
- package/lib/core/lsp/manager.js +418 -0
- package/lib/core/lsp/normalize.d.ts +32 -0
- package/lib/core/lsp/normalize.js +139 -0
- package/lib/core/lsp/servers.d.ts +106 -0
- package/lib/core/lsp/servers.js +352 -0
- package/lib/core/lsp/uri.d.ts +76 -0
- package/lib/core/lsp/uri.js +179 -0
- package/lib/core/market.d.ts +51 -0
- package/lib/core/market.js +358 -0
- package/lib/core/mcp.d.ts +201 -0
- package/lib/core/mcp.js +836 -0
- package/lib/core/memory-eval.d.ts +158 -0
- package/lib/core/memory-eval.js +215 -0
- package/lib/core/memory.d.ts +266 -0
- package/lib/core/memory.js +703 -0
- package/lib/core/mention.d.ts +57 -0
- package/lib/core/mention.js +129 -0
- package/lib/core/microcompact.d.ts +48 -0
- package/lib/core/microcompact.js +79 -0
- package/lib/core/migrate.d.ts +56 -0
- package/lib/core/migrate.js +134 -0
- package/lib/core/model-caps.d.ts +83 -0
- package/lib/core/model-caps.js +150 -0
- package/lib/core/model-discovery.d.ts +19 -0
- package/lib/core/model-discovery.js +69 -0
- package/lib/core/modes.d.ts +72 -0
- package/lib/core/modes.js +152 -0
- package/lib/core/native-bridge.d.ts +135 -0
- package/lib/core/native-bridge.js +563 -0
- package/lib/core/path-policy.d.ts +32 -0
- package/lib/core/path-policy.js +248 -0
- package/lib/core/permission-presets.d.ts +67 -0
- package/lib/core/permission-presets.js +75 -0
- package/lib/core/plugin-loader.d.ts +36 -0
- package/lib/core/plugin-loader.js +294 -0
- package/lib/core/plugin-registry.d.ts +113 -0
- package/lib/core/plugin-registry.js +256 -0
- package/lib/core/prefs.d.ts +82 -0
- package/lib/core/prefs.js +372 -0
- package/lib/core/presets.d.ts +80 -0
- package/lib/core/presets.js +373 -0
- package/lib/core/pricing.d.ts +90 -0
- package/lib/core/pricing.js +126 -0
- package/lib/core/prompt.d.ts +92 -0
- package/lib/core/prompt.js +339 -0
- package/lib/core/ptc.d.ts +66 -0
- package/lib/core/ptc.js +70 -0
- package/lib/core/remote/frames.d.ts +91 -0
- package/lib/core/remote/frames.js +174 -0
- package/lib/core/remote/notify.d.ts +54 -0
- package/lib/core/remote/notify.js +77 -0
- package/lib/core/remote/owner.d.ts +32 -0
- package/lib/core/remote/owner.js +75 -0
- package/lib/core/remote/pairing.d.ts +104 -0
- package/lib/core/remote/pairing.js +261 -0
- package/lib/core/remote/push.d.ts +80 -0
- package/lib/core/remote/push.js +222 -0
- package/lib/core/remote/store.d.ts +18 -0
- package/lib/core/remote/store.js +59 -0
- package/lib/core/remote/tickets.d.ts +20 -0
- package/lib/core/remote/tickets.js +49 -0
- package/lib/core/remote/uploads.d.ts +63 -0
- package/lib/core/remote/uploads.js +161 -0
- package/lib/core/request-attribution.d.ts +26 -0
- package/lib/core/request-attribution.js +86 -0
- package/lib/core/request-invariant.d.ts +61 -0
- package/lib/core/request-invariant.js +199 -0
- package/lib/core/sandbox/backends.d.ts +64 -0
- package/lib/core/sandbox/backends.js +194 -0
- package/lib/core/sandbox/execpolicy.d.ts +93 -0
- package/lib/core/sandbox/execpolicy.js +452 -0
- package/lib/core/sandbox/net-proxy.d.ts +31 -0
- package/lib/core/sandbox/net-proxy.js +162 -0
- package/lib/core/sandbox/policy.d.ts +211 -0
- package/lib/core/sandbox/policy.js +559 -0
- package/lib/core/sandbox/win/abi.d.ts +161 -0
- package/lib/core/sandbox/win/abi.js +169 -0
- package/lib/core/sandbox/win/account.d.ts +71 -0
- package/lib/core/sandbox/win/account.js +206 -0
- package/lib/core/sandbox/win/acl.d.ts +54 -0
- package/lib/core/sandbox/win/acl.js +339 -0
- package/lib/core/sandbox/win/backend.d.ts +61 -0
- package/lib/core/sandbox/win/backend.js +249 -0
- package/lib/core/sandbox/win/doctor.d.ts +24 -0
- package/lib/core/sandbox/win/doctor.js +272 -0
- package/lib/core/sandbox/win/ffi.d.ts +107 -0
- package/lib/core/sandbox/win/ffi.js +166 -0
- package/lib/core/sandbox/win/net-abi.d.ts +154 -0
- package/lib/core/sandbox/win/net-abi.js +316 -0
- package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
- package/lib/core/sandbox/win/runner-entry.js +391 -0
- package/lib/core/sandbox/win/setup.d.ts +60 -0
- package/lib/core/sandbox/win/setup.js +986 -0
- package/lib/core/sandbox/win/token.d.ts +35 -0
- package/lib/core/sandbox/win/token.js +238 -0
- package/lib/core/sandbox/win/wfp.d.ts +41 -0
- package/lib/core/sandbox/win/wfp.js +200 -0
- package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
- package/lib/core/sandbox/win/workspace-sid.js +45 -0
- package/lib/core/schedule/rule.d.ts +184 -0
- package/lib/core/schedule/rule.js +745 -0
- package/lib/core/schedule/runner.d.ts +185 -0
- package/lib/core/schedule/runner.js +678 -0
- package/lib/core/schedule/store.d.ts +182 -0
- package/lib/core/schedule/store.js +455 -0
- package/lib/core/secrets.d.ts +41 -0
- package/lib/core/secrets.js +150 -0
- package/lib/core/session-export.d.ts +18 -0
- package/lib/core/session-export.js +73 -0
- package/lib/core/session-index.d.ts +159 -0
- package/lib/core/session-index.js +683 -0
- package/lib/core/session-meta.d.ts +41 -0
- package/lib/core/session-meta.js +97 -0
- package/lib/core/session.d.ts +356 -0
- package/lib/core/session.js +998 -0
- package/lib/core/skills.d.ts +60 -0
- package/lib/core/skills.js +171 -0
- package/lib/core/spill.d.ts +159 -0
- package/lib/core/spill.js +329 -0
- package/lib/core/surface-registry.d.ts +45 -0
- package/lib/core/surface-registry.js +67 -0
- package/lib/core/team-board.d.ts +95 -0
- package/lib/core/team-board.js +316 -0
- package/lib/core/throughput.d.ts +46 -0
- package/lib/core/throughput.js +40 -0
- package/lib/core/todo-reminder.d.ts +44 -0
- package/lib/core/todo-reminder.js +55 -0
- package/lib/core/todo.d.ts +81 -0
- package/lib/core/todo.js +222 -0
- package/lib/core/token-estimate.d.ts +55 -0
- package/lib/core/token-estimate.js +82 -0
- package/lib/core/tool-guards.d.ts +103 -0
- package/lib/core/tool-guards.js +77 -0
- package/lib/core/tool-search.d.ts +152 -0
- package/lib/core/tool-search.js +311 -0
- package/lib/core/tools/bash.d.ts +281 -0
- package/lib/core/tools/bash.js +871 -0
- package/lib/core/tools/command-runner.d.ts +84 -0
- package/lib/core/tools/command-runner.js +68 -0
- package/lib/core/tools/fs-tools.d.ts +23 -0
- package/lib/core/tools/fs-tools.js +247 -0
- package/lib/core/tools/index.d.ts +8 -0
- package/lib/core/tools/index.js +4 -0
- package/lib/core/tools/sandbox-args.d.ts +51 -0
- package/lib/core/tools/sandbox-args.js +90 -0
- package/lib/core/tools/search-tools.d.ts +3 -0
- package/lib/core/tools/search-tools.js +153 -0
- package/lib/core/tools.d.ts +96 -0
- package/lib/core/tools.js +53 -0
- package/lib/core/ui-boot-source.d.ts +71 -0
- package/lib/core/ui-boot-source.js +121 -0
- package/lib/core/ui-bundles.d.ts +249 -0
- package/lib/core/ui-bundles.js +830 -0
- package/lib/core/ui-combo.d.ts +49 -0
- package/lib/core/ui-combo.js +55 -0
- package/lib/core/ui-events.d.ts +81 -0
- package/lib/core/ui-events.js +364 -0
- package/lib/core/ui-hmr.d.ts +36 -0
- package/lib/core/ui-hmr.js +128 -0
- package/lib/core/ui-methods.d.ts +69 -0
- package/lib/core/ui-methods.js +341 -0
- package/lib/core/ui-route.d.ts +69 -0
- package/lib/core/ui-route.js +122 -0
- package/lib/core/ui-server.d.ts +75 -0
- package/lib/core/ui-server.js +369 -0
- package/lib/core/ui-trust.d.ts +47 -0
- package/lib/core/ui-trust.js +164 -0
- package/lib/core/untrusted.d.ts +30 -0
- package/lib/core/untrusted.js +48 -0
- package/lib/core/update-check.d.ts +81 -0
- package/lib/core/update-check.js +177 -0
- package/lib/core/usage-log.d.ts +82 -0
- package/lib/core/usage-log.js +306 -0
- package/lib/core/version.d.ts +1 -0
- package/lib/core/version.js +37 -0
- package/lib/core/web-http.d.ts +57 -0
- package/lib/core/web-http.js +137 -0
- package/lib/core/web-static.d.ts +31 -0
- package/lib/core/web-static.js +75 -0
- package/lib/headless.d.ts +1 -0
- package/lib/headless.js +31 -0
- package/lib/host/kernel.d.ts +33 -0
- package/lib/host/kernel.js +451 -0
- package/lib/index.d.ts +41 -0
- package/lib/index.js +35 -0
- package/lib/plugins/agent.d.ts +2 -0
- package/lib/plugins/agent.js +274 -0
- package/lib/plugins/approval-floor.d.ts +2 -0
- package/lib/plugins/approval-floor.js +223 -0
- package/lib/plugins/approval.d.ts +16 -0
- package/lib/plugins/approval.js +674 -0
- package/lib/plugins/ask.d.ts +2 -0
- package/lib/plugins/ask.js +245 -0
- package/lib/plugins/browser.d.ts +68 -0
- package/lib/plugins/browser.js +1341 -0
- package/lib/plugins/commands.d.ts +23 -0
- package/lib/plugins/commands.js +498 -0
- package/lib/plugins/compact.d.ts +21 -0
- package/lib/plugins/compact.js +274 -0
- package/lib/plugins/computer-use.d.ts +47 -0
- package/lib/plugins/computer-use.js +539 -0
- package/lib/plugins/desktop-dock.d.ts +2 -0
- package/lib/plugins/desktop-dock.js +626 -0
- package/lib/plugins/dock-browser.d.ts +34 -0
- package/lib/plugins/dock-browser.js +765 -0
- package/lib/plugins/dsh-compat.d.ts +25 -0
- package/lib/plugins/dsh-compat.js +37 -0
- package/lib/plugins/file-review.d.ts +108 -0
- package/lib/plugins/file-review.js +393 -0
- package/lib/plugins/git.d.ts +26 -0
- package/lib/plugins/git.js +132 -0
- package/lib/plugins/goal.d.ts +20 -0
- package/lib/plugins/goal.js +245 -0
- package/lib/plugins/guards.d.ts +14 -0
- package/lib/plugins/guards.js +18 -0
- package/lib/plugins/hooks.d.ts +19 -0
- package/lib/plugins/hooks.js +583 -0
- package/lib/plugins/host-stdio.d.ts +88 -0
- package/lib/plugins/host-stdio.js +317 -0
- package/lib/plugins/image-diet.d.ts +17 -0
- package/lib/plugins/image-diet.js +85 -0
- package/lib/plugins/lifecycle-hooks.d.ts +26 -0
- package/lib/plugins/lifecycle-hooks.js +338 -0
- package/lib/plugins/llm.d.ts +13 -0
- package/lib/plugins/llm.js +215 -0
- package/lib/plugins/lsp.d.ts +54 -0
- package/lib/plugins/lsp.js +608 -0
- package/lib/plugins/mcp.d.ts +16 -0
- package/lib/plugins/mcp.js +673 -0
- package/lib/plugins/memory.d.ts +17 -0
- package/lib/plugins/memory.js +858 -0
- package/lib/plugins/microcompact.d.ts +18 -0
- package/lib/plugins/microcompact.js +119 -0
- package/lib/plugins/mode.d.ts +18 -0
- package/lib/plugins/mode.js +115 -0
- package/lib/plugins/permission-presets.d.ts +18 -0
- package/lib/plugins/permission-presets.js +135 -0
- package/lib/plugins/plan.d.ts +2 -0
- package/lib/plugins/plan.js +192 -0
- package/lib/plugins/plugin-manager.d.ts +2 -0
- package/lib/plugins/plugin-manager.js +165 -0
- package/lib/plugins/presets.d.ts +2 -0
- package/lib/plugins/presets.js +182 -0
- package/lib/plugins/prompt.d.ts +2 -0
- package/lib/plugins/prompt.js +264 -0
- package/lib/plugins/ptc.d.ts +2 -0
- package/lib/plugins/ptc.js +272 -0
- package/lib/plugins/remote/http.d.ts +11 -0
- package/lib/plugins/remote/http.js +11 -0
- package/lib/plugins/remote/routes.d.ts +24 -0
- package/lib/plugins/remote/routes.js +384 -0
- package/lib/plugins/remote/types.d.ts +135 -0
- package/lib/plugins/remote/types.js +87 -0
- package/lib/plugins/remote.d.ts +17 -0
- package/lib/plugins/remote.js +1028 -0
- package/lib/plugins/runtime-api.d.ts +16 -0
- package/lib/plugins/runtime-api.js +99 -0
- package/lib/plugins/runtime.d.ts +10 -0
- package/lib/plugins/runtime.js +451 -0
- package/lib/plugins/sandbox.d.ts +2 -0
- package/lib/plugins/sandbox.js +761 -0
- package/lib/plugins/schedule.d.ts +26 -0
- package/lib/plugins/schedule.js +538 -0
- package/lib/plugins/self-improve.d.ts +61 -0
- package/lib/plugins/self-improve.js +953 -0
- package/lib/plugins/session-search.d.ts +16 -0
- package/lib/plugins/session-search.js +308 -0
- package/lib/plugins/session-title.d.ts +19 -0
- package/lib/plugins/session-title.js +109 -0
- package/lib/plugins/session.d.ts +7 -0
- package/lib/plugins/session.js +296 -0
- package/lib/plugins/settings.d.ts +3 -0
- package/lib/plugins/settings.js +705 -0
- package/lib/plugins/skills.d.ts +2 -0
- package/lib/plugins/skills.js +360 -0
- package/lib/plugins/spill.d.ts +16 -0
- package/lib/plugins/spill.js +200 -0
- package/lib/plugins/subagent.d.ts +2 -0
- package/lib/plugins/subagent.js +862 -0
- package/lib/plugins/surfaces.d.ts +11 -0
- package/lib/plugins/surfaces.js +20 -0
- package/lib/plugins/team.d.ts +16 -0
- package/lib/plugins/team.js +149 -0
- package/lib/plugins/todo.d.ts +19 -0
- package/lib/plugins/todo.js +188 -0
- package/lib/plugins/tool-search.d.ts +2 -0
- package/lib/plugins/tool-search.js +425 -0
- package/lib/plugins/tools-default.d.ts +12 -0
- package/lib/plugins/tools-default.js +275 -0
- package/lib/plugins/tools.d.ts +16 -0
- package/lib/plugins/tools.js +62 -0
- package/lib/plugins/transcript.d.ts +15 -0
- package/lib/plugins/transcript.js +311 -0
- package/lib/plugins/tui.d.ts +2 -0
- package/lib/plugins/tui.js +98 -0
- package/lib/plugins/waiting.d.ts +12 -0
- package/lib/plugins/waiting.js +34 -0
- package/lib/plugins/web-search.d.ts +14 -0
- package/lib/plugins/web-search.js +263 -0
- package/lib/plugins/webserver.d.ts +48 -0
- package/lib/plugins/webserver.js +228 -0
- package/lib/remote/assets/app-DAcUCOEn.js +14 -0
- package/lib/remote/assets/icon-192.png +0 -0
- package/lib/remote/assets/icon-512.png +0 -0
- package/lib/remote/assets/index.html +34 -0
- package/lib/remote/assets/manifest.json +27 -0
- package/lib/remote/assets/style-DIB6729x.css +1 -0
- package/lib/remote/assets/sw.js +66 -0
- package/lib/services/types.d.ts +1228 -0
- package/lib/services/types.js +1 -0
- package/lib/tools/config-cli.d.ts +1 -0
- package/lib/tools/config-cli.js +89 -0
- package/lib/ui/arrival.d.ts +72 -0
- package/lib/ui/arrival.js +105 -0
- package/lib/ui/assets/app-B70nVIKd.js +69 -0
- package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
- package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
- package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
- package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
- package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
- package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
- package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
- package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
- package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
- package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
- package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
- package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
- package/lib/ui/assets/chunk-BajyYBss.js +10 -0
- package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
- package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
- package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
- package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
- package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
- package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
- package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
- package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
- package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
- package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
- package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
- package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
- package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
- package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
- package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
- package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
- package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
- package/lib/ui/assets/chunk-CickPsom.js +1 -0
- package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
- package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
- package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
- package/lib/ui/assets/chunk-CqE71os6.js +1 -0
- package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
- package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
- package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
- package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
- package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
- package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
- package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
- package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
- package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
- package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
- package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
- package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
- package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
- package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
- package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
- package/lib/ui/assets/chunk-De0Btta0.js +1 -0
- package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
- package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
- package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
- package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
- package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
- package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
- package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
- package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
- package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
- package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
- package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
- package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
- package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
- package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
- package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
- package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
- package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
- package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
- package/lib/ui/assets/icon.png +0 -0
- package/lib/ui/assets/index.html +14 -0
- package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/lib/ui/assets/style-Bq01xH_b.css +1 -0
- package/lib/ui/frames.d.ts +67 -0
- package/lib/ui/frames.js +146 -0
- package/lib/ui/index.d.ts +59 -0
- package/lib/ui/index.js +50 -0
- package/lib/ui/manifest.d.ts +172 -0
- package/lib/ui/manifest.js +158 -0
- package/lib/ui/plugin.d.ts +161 -0
- package/lib/ui/plugin.js +7 -0
- package/lib/ui/plugins/browser/client.js +290 -0
- package/lib/ui/plugins/browser/icon.png +0 -0
- package/lib/ui/plugins/composer/client.js +1843 -0
- package/lib/ui/plugins/composer/icon.png +0 -0
- package/lib/ui/plugins/files/client.js +646 -0
- package/lib/ui/plugins/files/icon.png +0 -0
- package/lib/ui/plugins/manifest.json +107 -0
- package/lib/ui/plugins/plugins/client.js +682 -0
- package/lib/ui/plugins/plugins/icon.png +0 -0
- package/lib/ui/plugins/preview/client.js +197 -0
- package/lib/ui/plugins/preview/icon.png +0 -0
- package/lib/ui/plugins/prompt/client.js +653 -0
- package/lib/ui/plugins/prompt/icon.png +0 -0
- package/lib/ui/plugins/sessions/client.js +1577 -0
- package/lib/ui/plugins/sessions/icon.png +0 -0
- package/lib/ui/plugins/settings/client.js +5470 -0
- package/lib/ui/plugins/settings/icon.png +0 -0
- package/lib/ui/plugins/skills/client.js +485 -0
- package/lib/ui/plugins/skills/icon.png +0 -0
- package/lib/ui/plugins/status/client.js +1420 -0
- package/lib/ui/plugins/status/icon.png +0 -0
- package/lib/ui/plugins/statusbar/client.js +504 -0
- package/lib/ui/plugins/statusbar/icon.png +0 -0
- package/lib/ui/plugins/tasks/client.js +52 -0
- package/lib/ui/plugins/tasks/icon.png +0 -0
- package/lib/ui/plugins/team/client.js +527 -0
- package/lib/ui/plugins/team/icon.png +0 -0
- package/lib/ui/plugins/terminal/client.js +232 -0
- package/lib/ui/plugins/terminal/icon.png +0 -0
- package/lib/ui/plugins/trace/client.js +1376 -0
- package/lib/ui/plugins/trace/icon.png +0 -0
- package/lib/ui/plugins/transcript/client.js +2661 -0
- package/lib/ui/plugins/transcript/icon.png +0 -0
- package/lib/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/scoped-slots.js +21 -0
- package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
- package/lib/ui/sdk/@dsc/ui/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
- package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
- package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
- package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
- package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
- package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
- package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
- package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
- package/lib/ui/services-react.d.ts +27 -0
- package/lib/ui/services-react.js +32 -0
- package/lib/ui/services.d.ts +63 -0
- package/lib/ui/services.js +121 -0
- package/lib/ui/slots-ink.d.ts +26 -0
- package/lib/ui/slots-ink.js +78 -0
- package/lib/ui/slots-react.d.ts +28 -0
- package/lib/ui/slots-react.js +88 -0
- package/lib/ui/slots.d.ts +481 -0
- package/lib/ui/slots.js +550 -0
- package/lib/ui/store.d.ts +89 -0
- package/lib/ui/store.js +62 -0
- package/lib/ui/tui-plugin-api.d.ts +23 -0
- package/lib/ui/tui-plugin-api.js +23 -0
- package/lib/ui/tui-plugins.d.ts +47 -0
- package/lib/ui/tui-plugins.js +220 -0
- package/package.json +58 -6
|
@@ -0,0 +1,1376 @@
|
|
|
1
|
+
(globalThis.__DSC_UI_FACTORIES__ ??= {})["trace"] = function (require, module, exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const react = require("react");
|
|
6
|
+
const ui$1 = require("@dsc/ui");
|
|
7
|
+
const uiPrimitives = require("@dsc/ui-primitives");
|
|
8
|
+
const KIND_LABEL = {
|
|
9
|
+
tool: "工具调用",
|
|
10
|
+
thinking: "思考",
|
|
11
|
+
subagent: "子代理",
|
|
12
|
+
system: "系统事件",
|
|
13
|
+
plan: "计划卡",
|
|
14
|
+
"turn-end": "轮结束",
|
|
15
|
+
"turn-max-tokens": "长度上限",
|
|
16
|
+
"model-retry": "模型重试",
|
|
17
|
+
user: "用户消息",
|
|
18
|
+
// 对话页轮尾卡的组成数据,轨迹页不渲染它;标签留给检查器兜底(类型上仍可能碰到)
|
|
19
|
+
changes: "文件已更改",
|
|
20
|
+
turnDiff: "回合文件更改"
|
|
21
|
+
};
|
|
22
|
+
function stepName(entry) {
|
|
23
|
+
switch (entry.kind) {
|
|
24
|
+
case "tool":
|
|
25
|
+
return entry.call.name;
|
|
26
|
+
case "thinking":
|
|
27
|
+
return "思考";
|
|
28
|
+
case "system":
|
|
29
|
+
return "系统事件";
|
|
30
|
+
case "plan":
|
|
31
|
+
return "计划卡";
|
|
32
|
+
case "turn-end":
|
|
33
|
+
return entry.reason === "aborted" ? "已停止" : "过程失败";
|
|
34
|
+
case "turn-max-tokens":
|
|
35
|
+
return "达到长度上限";
|
|
36
|
+
case "model-retry":
|
|
37
|
+
return `模型重试(第 ${String(entry.attempt)} 次)`;
|
|
38
|
+
case "subagent":
|
|
39
|
+
return entry.sub.task.length > 24 ? `${entry.sub.task.slice(0, 24)}…` : entry.sub.task;
|
|
40
|
+
case "user":
|
|
41
|
+
return "用户消息";
|
|
42
|
+
default:
|
|
43
|
+
return "正文";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function prettyMaybeJson(text) {
|
|
47
|
+
try {
|
|
48
|
+
return { text: JSON.stringify(JSON.parse(text), null, 2), formatted: true };
|
|
49
|
+
} catch {
|
|
50
|
+
return { text, formatted: false };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function entryUsage(entry) {
|
|
54
|
+
if (entry.kind === "text" || entry.kind === "tool") return entry.usage ?? null;
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function rangeHits(mark, range) {
|
|
58
|
+
const markEnd = mark.end ?? mark.start;
|
|
59
|
+
return mark.start <= range.end && markEnd >= range.start;
|
|
60
|
+
}
|
|
61
|
+
function buildTraceModel(entries) {
|
|
62
|
+
const segments = [];
|
|
63
|
+
const rounds = [];
|
|
64
|
+
const marks = [];
|
|
65
|
+
const boundaries = [];
|
|
66
|
+
let current = null;
|
|
67
|
+
const openRound = (user) => {
|
|
68
|
+
const round = { index: rounds.length, user, steps: [] };
|
|
69
|
+
rounds.push(round);
|
|
70
|
+
segments.push({ type: "round", round });
|
|
71
|
+
current = round;
|
|
72
|
+
return round;
|
|
73
|
+
};
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
const compaction = entry.kind === "user" || entry.kind === "system" ? entry.compaction : void 0;
|
|
76
|
+
if (compaction !== void 0) {
|
|
77
|
+
segments.push({ type: "compaction", count: compaction.count, entry });
|
|
78
|
+
current = null;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (entry.kind === "user") {
|
|
82
|
+
const round2 = openRound(entry);
|
|
83
|
+
const ts2 = uiPrimitives.entryTs(entry);
|
|
84
|
+
if (ts2 !== null) boundaries.push({ round: round2.index, ts: ts2 });
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (entry.kind === "text") continue;
|
|
88
|
+
if (entry.kind === "changes" || entry.kind === "turnDiff") continue;
|
|
89
|
+
const round = current ?? openRound(null);
|
|
90
|
+
round.steps.push(entry);
|
|
91
|
+
const ts = uiPrimitives.entryTs(entry);
|
|
92
|
+
if (entry.kind === "tool") {
|
|
93
|
+
const startedAt = entry.call.startedAt;
|
|
94
|
+
const durationMs = entry.call.durationMs;
|
|
95
|
+
const start = startedAt ?? ts;
|
|
96
|
+
if (start === null) continue;
|
|
97
|
+
const end = startedAt !== void 0 && durationMs !== void 0 ? startedAt + durationMs : null;
|
|
98
|
+
marks.push({
|
|
99
|
+
id: entry.id,
|
|
100
|
+
kind: "tool",
|
|
101
|
+
name: entry.call.name,
|
|
102
|
+
start,
|
|
103
|
+
end,
|
|
104
|
+
durationMs: durationMs ?? null,
|
|
105
|
+
ts,
|
|
106
|
+
round: round.index
|
|
107
|
+
});
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (ts === null) continue;
|
|
111
|
+
marks.push({
|
|
112
|
+
id: entry.id,
|
|
113
|
+
kind: entry.kind,
|
|
114
|
+
name: stepName(entry),
|
|
115
|
+
start: ts,
|
|
116
|
+
end: null,
|
|
117
|
+
durationMs: null,
|
|
118
|
+
ts,
|
|
119
|
+
round: round.index
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
let spanStart = null;
|
|
123
|
+
let spanEnd = null;
|
|
124
|
+
const stretch = (ts) => {
|
|
125
|
+
if (spanStart === null || ts < spanStart) spanStart = ts;
|
|
126
|
+
if (spanEnd === null || ts > spanEnd) spanEnd = ts;
|
|
127
|
+
};
|
|
128
|
+
for (const mark of marks) {
|
|
129
|
+
stretch(mark.start);
|
|
130
|
+
stretch(mark.end ?? mark.start);
|
|
131
|
+
}
|
|
132
|
+
for (const boundary of boundaries) stretch(boundary.ts);
|
|
133
|
+
return { segments, rounds, marks, boundaries, spanStart, spanEnd };
|
|
134
|
+
}
|
|
135
|
+
function stepMatches(entry, query) {
|
|
136
|
+
const needle = query.trim().toLowerCase();
|
|
137
|
+
if (needle === "") return false;
|
|
138
|
+
const parts = [entry.kind, stepName(entry)];
|
|
139
|
+
switch (entry.kind) {
|
|
140
|
+
case "tool":
|
|
141
|
+
parts.push(entry.call.name, entry.call.argsText);
|
|
142
|
+
if (entry.call.resultText !== void 0) parts.push(entry.call.resultText);
|
|
143
|
+
break;
|
|
144
|
+
case "thinking":
|
|
145
|
+
case "system":
|
|
146
|
+
parts.push(entry.text);
|
|
147
|
+
break;
|
|
148
|
+
case "plan":
|
|
149
|
+
parts.push(entry.plan.title, entry.plan.file, entry.plan.text);
|
|
150
|
+
break;
|
|
151
|
+
case "subagent":
|
|
152
|
+
parts.push(entry.sub.task, entry.sub.name, entry.sub.state);
|
|
153
|
+
break;
|
|
154
|
+
case "model-retry":
|
|
155
|
+
parts.push(`第 ${String(entry.attempt)} 次`);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
const haystack = parts.join("\n").toLowerCase();
|
|
159
|
+
return haystack.includes(needle);
|
|
160
|
+
}
|
|
161
|
+
const HOVER_DELAY_MS = 500;
|
|
162
|
+
const DRAG_MIN_PX = 4;
|
|
163
|
+
const PAN_MIN_PX = 3;
|
|
164
|
+
const MIN_ZOOM_DENOM = 50;
|
|
165
|
+
function TraceTimeline(props) {
|
|
166
|
+
const trackRef = react.useRef(null);
|
|
167
|
+
const [hover, setHover] = react.useState(null);
|
|
168
|
+
const hoverTimer = react.useRef(null);
|
|
169
|
+
const [drag, setDrag] = react.useState(null);
|
|
170
|
+
const dragRef = react.useRef(null);
|
|
171
|
+
const [viewport, setViewport] = react.useState(null);
|
|
172
|
+
const panRef = react.useRef(null);
|
|
173
|
+
const suppressMenu = react.useRef(false);
|
|
174
|
+
react.useEffect(() => {
|
|
175
|
+
setViewport(null);
|
|
176
|
+
}, [props.resetKey]);
|
|
177
|
+
const fullSpan = props.spanStart !== null && props.spanEnd !== null ? props.spanEnd - props.spanStart : 0;
|
|
178
|
+
const projectable = props.spanStart !== null && fullSpan > 0;
|
|
179
|
+
const domain = props.spanStart === null || props.spanEnd === null ? null : viewport ?? { start: props.spanStart, end: props.spanEnd };
|
|
180
|
+
const domainSpan = domain === null ? 0 : domain.end - domain.start;
|
|
181
|
+
const percent = (ts) => {
|
|
182
|
+
if (!projectable || domain === null || domainSpan <= 0) return 0;
|
|
183
|
+
return (ts - domain.start) / domainSpan * 100;
|
|
184
|
+
};
|
|
185
|
+
const timeAt = (clientX) => {
|
|
186
|
+
const track = trackRef.current;
|
|
187
|
+
if (track === null || !projectable || domain === null) return null;
|
|
188
|
+
const rect = track.getBoundingClientRect();
|
|
189
|
+
if (rect.width <= 0) return null;
|
|
190
|
+
const ratio = Math.min(1, Math.max(0, (clientX - rect.left) / rect.width));
|
|
191
|
+
return domain.start + ratio * domainSpan;
|
|
192
|
+
};
|
|
193
|
+
react.useEffect(() => {
|
|
194
|
+
const track = trackRef.current;
|
|
195
|
+
const hardStart = props.spanStart;
|
|
196
|
+
const hardEnd = props.spanEnd;
|
|
197
|
+
if (track === null || !projectable || hardStart === null || hardEnd === null) return void 0;
|
|
198
|
+
const onWheel = (event) => {
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
const trackRect = track.getBoundingClientRect();
|
|
201
|
+
if (trackRect.width <= 0) return;
|
|
202
|
+
const ratio = Math.min(1, Math.max(0, (event.clientX - trackRect.left) / trackRect.width));
|
|
203
|
+
const from = viewport ?? { start: hardStart, end: hardEnd };
|
|
204
|
+
const fromSpan = from.end - from.start;
|
|
205
|
+
const anchor = from.start + ratio * fromSpan;
|
|
206
|
+
const factor = event.deltaY < 0 ? 0.8 : 1.25;
|
|
207
|
+
const minSpan = Math.max(1e3, fullSpan / MIN_ZOOM_DENOM);
|
|
208
|
+
const nextSpan = Math.min(fullSpan, Math.max(minSpan, fromSpan * factor));
|
|
209
|
+
let nextStart = anchor - ratio * nextSpan;
|
|
210
|
+
nextStart = Math.min(hardEnd - nextSpan, Math.max(hardStart, nextStart));
|
|
211
|
+
setViewport(nextSpan >= fullSpan * 0.999 ? null : { start: nextStart, end: nextStart + nextSpan });
|
|
212
|
+
};
|
|
213
|
+
track.addEventListener("wheel", onWheel, { passive: false });
|
|
214
|
+
return () => {
|
|
215
|
+
track.removeEventListener("wheel", onWheel);
|
|
216
|
+
};
|
|
217
|
+
}, [projectable, viewport, props.spanStart, props.spanEnd, fullSpan]);
|
|
218
|
+
const clearHover = () => {
|
|
219
|
+
if (hoverTimer.current !== null) {
|
|
220
|
+
window.clearTimeout(hoverTimer.current);
|
|
221
|
+
hoverTimer.current = null;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const armHover = (mark) => {
|
|
225
|
+
clearHover();
|
|
226
|
+
hoverTimer.current = window.setTimeout(() => {
|
|
227
|
+
hoverTimer.current = null;
|
|
228
|
+
setHover(mark);
|
|
229
|
+
}, HOVER_DELAY_MS);
|
|
230
|
+
};
|
|
231
|
+
const disarmHover = () => {
|
|
232
|
+
clearHover();
|
|
233
|
+
setHover(null);
|
|
234
|
+
};
|
|
235
|
+
react.useEffect(() => clearHover, []);
|
|
236
|
+
const onPointerDown = (event) => {
|
|
237
|
+
if (event.button === 2) {
|
|
238
|
+
if (domain === null) return;
|
|
239
|
+
disarmHover();
|
|
240
|
+
panRef.current = { pointerId: event.pointerId, startX: event.clientX, from: domain, moved: false };
|
|
241
|
+
try {
|
|
242
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
243
|
+
} catch {
|
|
244
|
+
}
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (event.button !== 0) return;
|
|
248
|
+
const at = timeAt(event.clientX);
|
|
249
|
+
if (at === null) return;
|
|
250
|
+
disarmHover();
|
|
251
|
+
dragRef.current = { pointerId: event.pointerId, anchorTs: at, moved: false };
|
|
252
|
+
setDrag({ start: at, end: at });
|
|
253
|
+
try {
|
|
254
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
255
|
+
} catch {
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
const onPointerMove = (event) => {
|
|
259
|
+
const pan = panRef.current;
|
|
260
|
+
if (pan !== null && pan.pointerId === event.pointerId) {
|
|
261
|
+
const dx = event.clientX - pan.startX;
|
|
262
|
+
if (!pan.moved && Math.abs(dx) < PAN_MIN_PX) return;
|
|
263
|
+
pan.moved = true;
|
|
264
|
+
const track = trackRef.current;
|
|
265
|
+
const width = track?.getBoundingClientRect().width ?? 0;
|
|
266
|
+
if (width <= 0 || props.spanStart === null || props.spanEnd === null) return;
|
|
267
|
+
const shift = dx / width * (pan.from.end - pan.from.start);
|
|
268
|
+
const span = pan.from.end - pan.from.start;
|
|
269
|
+
let nextStart = pan.from.start - shift;
|
|
270
|
+
nextStart = Math.min(props.spanEnd - span, Math.max(props.spanStart, nextStart));
|
|
271
|
+
setViewport(span >= fullSpan * 0.999 ? null : { start: nextStart, end: nextStart + span });
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const held = dragRef.current;
|
|
275
|
+
if (held === null || held.pointerId !== event.pointerId) return;
|
|
276
|
+
const at = timeAt(event.clientX);
|
|
277
|
+
if (at === null) return;
|
|
278
|
+
if (!held.moved && Math.abs(at - held.anchorTs) > 0) {
|
|
279
|
+
const rect = trackRef.current?.getBoundingClientRect();
|
|
280
|
+
const movedPx = rect === void 0 ? 0 : Math.abs((at - held.anchorTs) / domainSpan * rect.width);
|
|
281
|
+
if (movedPx >= DRAG_MIN_PX) held.moved = true;
|
|
282
|
+
}
|
|
283
|
+
setDrag({ start: Math.min(held.anchorTs, at), end: Math.max(held.anchorTs, at) });
|
|
284
|
+
};
|
|
285
|
+
const onPointerUp = (event) => {
|
|
286
|
+
const pan = panRef.current;
|
|
287
|
+
if (pan !== null && pan.pointerId === event.pointerId) {
|
|
288
|
+
panRef.current = null;
|
|
289
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
290
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
291
|
+
}
|
|
292
|
+
suppressMenu.current = pan.moved;
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const held = dragRef.current;
|
|
296
|
+
if (held === null || held.pointerId !== event.pointerId) return;
|
|
297
|
+
dragRef.current = null;
|
|
298
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
299
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
300
|
+
}
|
|
301
|
+
const at = timeAt(event.clientX) ?? held.anchorTs;
|
|
302
|
+
const range2 = { start: Math.min(held.anchorTs, at), end: Math.max(held.anchorTs, at) };
|
|
303
|
+
setDrag(null);
|
|
304
|
+
if (!held.moved) {
|
|
305
|
+
props.onSelect(null);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
props.onSelect(range2);
|
|
309
|
+
};
|
|
310
|
+
const range = drag ?? props.selected;
|
|
311
|
+
const rangeLabel = range === null ? null : `${uiPrimitives.formatTraceDuration(range.end - range.start) ?? "0.0s"} · ${String(props.selectedCount)} 步`;
|
|
312
|
+
if (props.spanStart === null || props.spanEnd === null) {
|
|
313
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "trace-timeline is-empty", "data-trace-timeline": "empty", children: [
|
|
314
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ttl-title", children: "时间概览" }),
|
|
315
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ttl-note", children: "本会话没有记录时间戳(2026-09 之前的老会话),时间条不画。" })
|
|
316
|
+
] });
|
|
317
|
+
}
|
|
318
|
+
const project = (start, end) => {
|
|
319
|
+
const rawLeft = percent(start);
|
|
320
|
+
const rawRight = end === null ? rawLeft : percent(end);
|
|
321
|
+
const left = Math.max(0, rawLeft);
|
|
322
|
+
const right = Math.min(100, rawRight);
|
|
323
|
+
if (rawRight < 0 || rawLeft > 100) return null;
|
|
324
|
+
return { left, width: end === null ? 0 : Math.max(0.4, right - left) };
|
|
325
|
+
};
|
|
326
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "trace-timeline", "data-trace-timeline": "1", "data-marks": String(props.marks.length), children: [
|
|
327
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ttl-head", children: [
|
|
328
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ttl-title", children: "时间概览" }),
|
|
329
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ttl-range", children: [
|
|
330
|
+
uiPrimitives.formatClockSeconds(props.spanStart),
|
|
331
|
+
" → ",
|
|
332
|
+
uiPrimitives.formatClockSeconds(props.spanEnd),
|
|
333
|
+
" ·",
|
|
334
|
+
" ",
|
|
335
|
+
uiPrimitives.formatTraceDuration(fullSpan) ?? "不足 0.1s"
|
|
336
|
+
] }),
|
|
337
|
+
viewport !== null && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
338
|
+
"button",
|
|
339
|
+
{
|
|
340
|
+
type: "button",
|
|
341
|
+
className: "ttl-chip ttl-zoom-reset",
|
|
342
|
+
"data-trace-zoom-reset": "1",
|
|
343
|
+
"data-tip": "回到全览(滚轮缩放、右键拖动平移)",
|
|
344
|
+
onClick: () => {
|
|
345
|
+
setViewport(null);
|
|
346
|
+
},
|
|
347
|
+
children: [
|
|
348
|
+
"已缩放 ",
|
|
349
|
+
uiPrimitives.formatTraceDuration(domainSpan) ?? "",
|
|
350
|
+
" · 全览"
|
|
351
|
+
]
|
|
352
|
+
}
|
|
353
|
+
),
|
|
354
|
+
rangeLabel !== null && props.selected !== null && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
355
|
+
"button",
|
|
356
|
+
{
|
|
357
|
+
type: "button",
|
|
358
|
+
className: "ttl-chip",
|
|
359
|
+
"data-trace-selection-chip": "1",
|
|
360
|
+
"data-tip": "清除选中的区间。轨道上单击或右键也可以清除。",
|
|
361
|
+
onClick: () => props.onSelect(null),
|
|
362
|
+
children: [
|
|
363
|
+
"已选 ",
|
|
364
|
+
rangeLabel,
|
|
365
|
+
" · 清除"
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
] }),
|
|
370
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
371
|
+
"div",
|
|
372
|
+
{
|
|
373
|
+
className: "ttl-track",
|
|
374
|
+
ref: trackRef,
|
|
375
|
+
"data-trace-track": "1",
|
|
376
|
+
"data-projectable": projectable ? "1" : "0",
|
|
377
|
+
"data-zoomed": viewport === null ? void 0 : "1",
|
|
378
|
+
role: "group",
|
|
379
|
+
"aria-label": "会话时间概览:横向为时间,拖选一段区间可聚焦下方记录;滚轮缩放,右键拖动平移",
|
|
380
|
+
onPointerDown,
|
|
381
|
+
onPointerMove,
|
|
382
|
+
onPointerUp,
|
|
383
|
+
onPointerCancel: () => {
|
|
384
|
+
dragRef.current = null;
|
|
385
|
+
panRef.current = null;
|
|
386
|
+
setDrag(null);
|
|
387
|
+
},
|
|
388
|
+
onPointerLeave: disarmHover,
|
|
389
|
+
onContextMenu: (event) => {
|
|
390
|
+
event.preventDefault();
|
|
391
|
+
if (suppressMenu.current) {
|
|
392
|
+
suppressMenu.current = false;
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
props.onSelect(null);
|
|
396
|
+
},
|
|
397
|
+
children: [
|
|
398
|
+
props.boundaries.map((boundary) => {
|
|
399
|
+
const spot = project(boundary.ts, null);
|
|
400
|
+
if (spot === null) return null;
|
|
401
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
402
|
+
"span",
|
|
403
|
+
{
|
|
404
|
+
className: "ttl-sep",
|
|
405
|
+
"data-trace-boundary": String(boundary.round),
|
|
406
|
+
style: { left: `${String(spot.left)}%` },
|
|
407
|
+
"data-tip": `第 ${String(boundary.round + 1)} 轮从这里开始`
|
|
408
|
+
},
|
|
409
|
+
`boundary-${String(boundary.round)}`
|
|
410
|
+
);
|
|
411
|
+
}),
|
|
412
|
+
props.marks.map((mark) => {
|
|
413
|
+
const spot = project(mark.start, mark.end);
|
|
414
|
+
if (spot === null) return null;
|
|
415
|
+
return mark.end === null ? (
|
|
416
|
+
// 没有耗时的步骤:只画起点刻度。宽度是 0,不是「很小」——不虚构。
|
|
417
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
418
|
+
"span",
|
|
419
|
+
{
|
|
420
|
+
className: `ttl-tick kind-${mark.kind}`,
|
|
421
|
+
"data-trace-mark": String(mark.id),
|
|
422
|
+
"data-kind": mark.kind,
|
|
423
|
+
style: { left: `${String(spot.left)}%` },
|
|
424
|
+
onPointerEnter: () => armHover(mark),
|
|
425
|
+
onPointerLeave: disarmHover
|
|
426
|
+
},
|
|
427
|
+
mark.id
|
|
428
|
+
)
|
|
429
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
430
|
+
"span",
|
|
431
|
+
{
|
|
432
|
+
className: `ttl-bar kind-${mark.kind}`,
|
|
433
|
+
"data-trace-mark": String(mark.id),
|
|
434
|
+
"data-kind": mark.kind,
|
|
435
|
+
"data-duration": String(mark.durationMs ?? ""),
|
|
436
|
+
style: { left: `${String(spot.left)}%`, width: `${String(spot.width)}%` },
|
|
437
|
+
onPointerEnter: () => armHover(mark),
|
|
438
|
+
onPointerLeave: disarmHover
|
|
439
|
+
},
|
|
440
|
+
mark.id
|
|
441
|
+
);
|
|
442
|
+
}),
|
|
443
|
+
range !== null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
444
|
+
"span",
|
|
445
|
+
{
|
|
446
|
+
className: "ttl-sel",
|
|
447
|
+
"data-trace-selection": "1",
|
|
448
|
+
style: {
|
|
449
|
+
left: `${String(Math.max(0, percent(range.start)))}%`,
|
|
450
|
+
width: `${String(Math.max(0.3, Math.min(100, percent(range.end)) - Math.max(0, percent(range.start))))}%`
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
),
|
|
454
|
+
hover !== null && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
455
|
+
"span",
|
|
456
|
+
{
|
|
457
|
+
className: "ttl-tip",
|
|
458
|
+
"data-trace-tip": "1",
|
|
459
|
+
style: {
|
|
460
|
+
left: `${String(Math.min(96, Math.max(4, percent((hover.start + (hover.end ?? hover.start)) / 2))))}%`
|
|
461
|
+
},
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: hover.name }),
|
|
464
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: uiPrimitives.formatClockSeconds(hover.ts ?? hover.start) ?? "时刻未记录" }),
|
|
465
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: hover.durationMs === null ? "耗时未记录" : `耗时 ${uiPrimitives.formatTraceDuration(hover.durationMs) ?? "未记录"}` })
|
|
466
|
+
]
|
|
467
|
+
}
|
|
468
|
+
)
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
)
|
|
472
|
+
] });
|
|
473
|
+
}
|
|
474
|
+
function TraceInspector(props) {
|
|
475
|
+
const { entry } = props;
|
|
476
|
+
const [zoom, setZoom] = react.useState(null);
|
|
477
|
+
react.useEffect(() => {
|
|
478
|
+
const onKey = (event) => {
|
|
479
|
+
if (event.key !== "Escape") return;
|
|
480
|
+
setZoom(null);
|
|
481
|
+
props.onClose();
|
|
482
|
+
};
|
|
483
|
+
window.addEventListener("keydown", onKey);
|
|
484
|
+
return () => {
|
|
485
|
+
window.removeEventListener("keydown", onKey);
|
|
486
|
+
};
|
|
487
|
+
}, [props]);
|
|
488
|
+
const usage = entryUsage(entry);
|
|
489
|
+
const usageTotal = usage === null ? null : usage.inputTokens + usage.outputTokens;
|
|
490
|
+
const title = entry.kind === "tool" ? `${entry.call.name}${props.round === null ? "" : ` · 第 ${String(props.round + 1)} 轮`}` : entry.kind === "user" && props.round !== null ? `第 ${String(props.round + 1)} 轮` : entry.kind === "plan" ? entry.plan.title : "";
|
|
491
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
492
|
+
"aside",
|
|
493
|
+
{
|
|
494
|
+
className: "trace-inspector",
|
|
495
|
+
"data-trace-inspector": String(entry.id),
|
|
496
|
+
"data-kind": entry.kind,
|
|
497
|
+
role: "dialog",
|
|
498
|
+
"aria-modal": "true",
|
|
499
|
+
"aria-label": "这一条记录的检查器",
|
|
500
|
+
children: [
|
|
501
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ti-head", children: [
|
|
502
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ti-kind", children: entry.kind === "text" ? "正文" : KIND_LABEL[entry.kind] }),
|
|
503
|
+
title !== "" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ti-title", children: title }),
|
|
504
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
505
|
+
"button",
|
|
506
|
+
{
|
|
507
|
+
type: "button",
|
|
508
|
+
className: "ti-close",
|
|
509
|
+
"data-trace-inspector-close": "1",
|
|
510
|
+
"data-tip": "关闭检查器(Esc)",
|
|
511
|
+
"aria-label": "关闭检查器",
|
|
512
|
+
onClick: props.onClose,
|
|
513
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconClose, { size: 14 })
|
|
514
|
+
}
|
|
515
|
+
)
|
|
516
|
+
] }),
|
|
517
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ti-body", children: [
|
|
518
|
+
entry.kind === "user" && /* @__PURE__ */ jsxRuntime.jsx(Section, { label: "消息原文", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "ti-code", "data-trace-code": "user-text", children: entry.text }) }),
|
|
519
|
+
entry.kind === "user" && /* @__PURE__ */ jsxRuntime.jsx(Section, { label: `附件${entry.images === void 0 ? "" : `(${String(entry.images.length)})`}`, children: entry.images === void 0 || entry.images.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ti-empty", children: "这条消息没有附件。" }) : /* @__PURE__ */ jsxRuntime.jsx(Attachments, { images: entry.images, onZoom: setZoom }) }),
|
|
520
|
+
entry.kind === "tool" && /* @__PURE__ */ jsxRuntime.jsx(ArgsSection, { argsText: entry.call.argsText }),
|
|
521
|
+
entry.kind === "tool" && /* @__PURE__ */ jsxRuntime.jsx(Section, { label: "输出", children: entry.call.resultText === void 0 || entry.call.resultText === "" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ti-empty", children: entry.call.status === "running" ? "这次调用还在跑,结果还没回来。" : entry.call.status === "preparing" ? "这次调用还在准备中(参数没到齐),结果还没回来。" : "这次调用没有输出。" }) : /* @__PURE__ */ jsxRuntime.jsx(Block, { text: entry.call.resultText, marker: "result" }) }),
|
|
522
|
+
entry.kind === "thinking" && /* @__PURE__ */ jsxRuntime.jsx(Section, { label: "思考全文", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "ti-code", "data-trace-code": "thinking", children: entry.text }) }),
|
|
523
|
+
entry.kind === "subagent" && /* @__PURE__ */ jsxRuntime.jsx(Section, { label: "子代理", children: /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "ti-facts", children: [
|
|
524
|
+
/* @__PURE__ */ jsxRuntime.jsx(Fact, { label: "任务", value: entry.sub.task }),
|
|
525
|
+
/* @__PURE__ */ jsxRuntime.jsx(Fact, { label: "名称", value: entry.sub.name }),
|
|
526
|
+
/* @__PURE__ */ jsxRuntime.jsx(Fact, { label: "状态", value: entry.sub.state }),
|
|
527
|
+
entry.sub.model !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(Fact, { label: "模型", value: entry.sub.model }),
|
|
528
|
+
/* @__PURE__ */ jsxRuntime.jsx(Fact, { label: "轮数", value: String(entry.sub.rounds) }),
|
|
529
|
+
/* @__PURE__ */ jsxRuntime.jsx(Fact, { label: "工具调用", value: String(entry.sub.toolCalls) }),
|
|
530
|
+
entry.sub.tokens !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(Fact, { label: "Token", value: String(entry.sub.tokens) })
|
|
531
|
+
] }) }),
|
|
532
|
+
entry.kind === "system" && /* @__PURE__ */ jsxRuntime.jsx(Section, { label: "通知原文", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "ti-code", "data-trace-code": "system", children: entry.text }) }),
|
|
533
|
+
entry.kind === "plan" && /* @__PURE__ */ jsxRuntime.jsx(Section, { label: "计划全文", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "ti-code", "data-trace-code": "plan", children: entry.plan.text }) }),
|
|
534
|
+
/* @__PURE__ */ jsxRuntime.jsx(Section, { label: "计时", children: /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "ti-facts", children: [
|
|
535
|
+
entry.kind === "tool" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
536
|
+
Fact,
|
|
537
|
+
{
|
|
538
|
+
label: "发起时刻",
|
|
539
|
+
value: uiPrimitives.formatClockSeconds(entry.call.startedAt ?? null) ?? "未记录",
|
|
540
|
+
title: "宿主收到 tool/call 那一刻;老会话没有这个字段"
|
|
541
|
+
}
|
|
542
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
543
|
+
Fact,
|
|
544
|
+
{
|
|
545
|
+
label: "记录时刻",
|
|
546
|
+
value: uiPrimitives.formatClockSeconds(entry.ts === void 0 ? null : entry.ts) ?? "未记录",
|
|
547
|
+
title: "这条条目最后一次写入的时刻(HH:mm:ss)"
|
|
548
|
+
}
|
|
549
|
+
),
|
|
550
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
551
|
+
Fact,
|
|
552
|
+
{
|
|
553
|
+
label: "耗时",
|
|
554
|
+
value: entry.kind === "tool" ? uiPrimitives.formatTraceDuration(entry.call.durationMs ?? null) ?? "未记录" : "未记录",
|
|
555
|
+
title: "工具调用耗时(结果到达 − 发起);未记录时显示「未记录」"
|
|
556
|
+
}
|
|
557
|
+
),
|
|
558
|
+
entry.kind === "tool" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
559
|
+
Fact,
|
|
560
|
+
{
|
|
561
|
+
label: "结果时刻",
|
|
562
|
+
value: uiPrimitives.formatClock(entry.ts === void 0 ? null : entry.ts) ?? "未记录",
|
|
563
|
+
title: "条目 ts:拿到结果那一刻刷新的最后写入时刻"
|
|
564
|
+
}
|
|
565
|
+
)
|
|
566
|
+
] }) }),
|
|
567
|
+
/* @__PURE__ */ jsxRuntime.jsx(Section, { label: "用量", children: usage === null ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ti-empty", children: "未记录(老会话或重放路径没有用量事件)。" }) : /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "ti-facts", children: [
|
|
568
|
+
/* @__PURE__ */ jsxRuntime.jsx(Fact, { label: "输入", value: `${uiPrimitives.formatTokens(usage.inputTokens)} tok` }),
|
|
569
|
+
/* @__PURE__ */ jsxRuntime.jsx(Fact, { label: "输出", value: `${uiPrimitives.formatTokens(usage.outputTokens)} tok` }),
|
|
570
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
571
|
+
Fact,
|
|
572
|
+
{
|
|
573
|
+
label: "合计",
|
|
574
|
+
value: `${uiPrimitives.formatTokens(usageTotal ?? 0)} tok`,
|
|
575
|
+
title: props.usageIsRoundTotal ? "本轮的整轮真值:这一轮所有模型请求的 prompt + completion 之和" : "这是本轮累计到这条为止的值,整轮真值落在本轮最后一条带用量的记录上"
|
|
576
|
+
}
|
|
577
|
+
)
|
|
578
|
+
] }) })
|
|
579
|
+
] }),
|
|
580
|
+
zoom !== null && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
581
|
+
"div",
|
|
582
|
+
{
|
|
583
|
+
className: "trace-lightbox",
|
|
584
|
+
"data-trace-lightbox": "1",
|
|
585
|
+
role: "dialog",
|
|
586
|
+
"aria-modal": "true",
|
|
587
|
+
"aria-label": "放大查看贴图",
|
|
588
|
+
onClick: () => setZoom(null),
|
|
589
|
+
children: [
|
|
590
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src: zoom, alt: "放大的贴图" }),
|
|
591
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
592
|
+
"button",
|
|
593
|
+
{
|
|
594
|
+
type: "button",
|
|
595
|
+
className: "ti-close lightbox-close",
|
|
596
|
+
"data-tip": "关闭放大视图",
|
|
597
|
+
"aria-label": "关闭放大视图",
|
|
598
|
+
onClick: (event) => {
|
|
599
|
+
event.stopPropagation();
|
|
600
|
+
setZoom(null);
|
|
601
|
+
},
|
|
602
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconClose, { size: 14 })
|
|
603
|
+
}
|
|
604
|
+
)
|
|
605
|
+
]
|
|
606
|
+
}
|
|
607
|
+
)
|
|
608
|
+
]
|
|
609
|
+
}
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
function Section({
|
|
613
|
+
label,
|
|
614
|
+
children,
|
|
615
|
+
extra
|
|
616
|
+
}) {
|
|
617
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "ti-sec", children: [
|
|
618
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ti-sec-head", children: [
|
|
619
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ti-label", children: label }),
|
|
620
|
+
extra
|
|
621
|
+
] }),
|
|
622
|
+
children
|
|
623
|
+
] });
|
|
624
|
+
}
|
|
625
|
+
function Fact({ label, value, title }) {
|
|
626
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ti-fact", title, "data-trace-fact": label, children: [
|
|
627
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: label }),
|
|
628
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: value })
|
|
629
|
+
] });
|
|
630
|
+
}
|
|
631
|
+
function ArgsSection({ argsText }) {
|
|
632
|
+
const pretty = prettyMaybeJson(argsText);
|
|
633
|
+
const [formatted, setFormatted] = react.useState(pretty.formatted);
|
|
634
|
+
const shown = formatted && pretty.formatted ? pretty.text : argsText;
|
|
635
|
+
const copy = () => {
|
|
636
|
+
void navigator.clipboard.writeText(argsText).then(
|
|
637
|
+
() => {
|
|
638
|
+
ui$1.toastOk("已复制参数原文");
|
|
639
|
+
},
|
|
640
|
+
() => {
|
|
641
|
+
ui$1.toastErr("复制失败:剪贴板不可用");
|
|
642
|
+
}
|
|
643
|
+
);
|
|
644
|
+
};
|
|
645
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
646
|
+
Section,
|
|
647
|
+
{
|
|
648
|
+
label: "输入",
|
|
649
|
+
extra: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ti-tools", children: [
|
|
650
|
+
pretty.formatted && /* @__PURE__ */ jsxRuntime.jsx(
|
|
651
|
+
"button",
|
|
652
|
+
{
|
|
653
|
+
type: "button",
|
|
654
|
+
className: "ti-btn",
|
|
655
|
+
"data-trace-format-toggle": "args",
|
|
656
|
+
"data-state": formatted ? "pretty" : "raw",
|
|
657
|
+
"data-tip": "在原文与缩进美化之间切换(原文才是模型真正发出的那串)",
|
|
658
|
+
onClick: () => {
|
|
659
|
+
setFormatted((current) => !current);
|
|
660
|
+
},
|
|
661
|
+
children: formatted ? "原文" : "格式化"
|
|
662
|
+
}
|
|
663
|
+
),
|
|
664
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
665
|
+
"button",
|
|
666
|
+
{
|
|
667
|
+
type: "button",
|
|
668
|
+
className: "ti-btn",
|
|
669
|
+
"data-trace-copy-args": "1",
|
|
670
|
+
"data-tip": "复制参数",
|
|
671
|
+
onClick: copy,
|
|
672
|
+
children: [
|
|
673
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCopy, { size: 12 }),
|
|
674
|
+
"复制参数"
|
|
675
|
+
]
|
|
676
|
+
}
|
|
677
|
+
)
|
|
678
|
+
] }),
|
|
679
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Block, { text: shown, marker: "args", formatted: formatted && pretty.formatted })
|
|
680
|
+
}
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
function Block({
|
|
684
|
+
text,
|
|
685
|
+
marker,
|
|
686
|
+
formatted = false
|
|
687
|
+
}) {
|
|
688
|
+
return /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "ti-code", "data-trace-code": marker, "data-formatted": formatted ? "1" : "0", children: text });
|
|
689
|
+
}
|
|
690
|
+
function Attachments({
|
|
691
|
+
images,
|
|
692
|
+
onZoom
|
|
693
|
+
}) {
|
|
694
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "entry-user-images ti-shots", "data-trace-attachments": String(images.length), children: images.map((url, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
695
|
+
"button",
|
|
696
|
+
{
|
|
697
|
+
type: "button",
|
|
698
|
+
className: "ti-shot",
|
|
699
|
+
"data-trace-shot": String(index),
|
|
700
|
+
"data-tip": "点开看原图",
|
|
701
|
+
onClick: () => onZoom(url),
|
|
702
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: `第 ${String(index + 1)} 张贴图` })
|
|
703
|
+
},
|
|
704
|
+
index
|
|
705
|
+
)) });
|
|
706
|
+
}
|
|
707
|
+
const REVIEW_NOTICE_BANNER = "【文件更改预览·尚未落盘】";
|
|
708
|
+
const REVIEW_ACTION_TEXT = {
|
|
709
|
+
create: "新建",
|
|
710
|
+
update: "修改"
|
|
711
|
+
};
|
|
712
|
+
function escapeRegExp(text) {
|
|
713
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
714
|
+
}
|
|
715
|
+
const HEAD_PATTERN = new RegExp(`^${escapeRegExp(REVIEW_NOTICE_BANNER)}(新建|修改) (.+)(([^()]*))$`);
|
|
716
|
+
function parseCounts(text) {
|
|
717
|
+
const match = /^\+(\d+) 行 \/ -(\d+) 行$/.exec(text);
|
|
718
|
+
if (match === null) return null;
|
|
719
|
+
const added = Number(match[1]);
|
|
720
|
+
const removed = Number(match[2]);
|
|
721
|
+
return Number.isFinite(added) && Number.isFinite(removed) ? { added, removed } : null;
|
|
722
|
+
}
|
|
723
|
+
function parseAction(verb) {
|
|
724
|
+
if (verb === "新建") return "create";
|
|
725
|
+
if (verb === "修改") return "update";
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
728
|
+
function reviewLineKindOf(line) {
|
|
729
|
+
if (line.startsWith("@@")) return "hunk";
|
|
730
|
+
if (line.startsWith("+")) return "add";
|
|
731
|
+
if (line.startsWith("-")) return "remove";
|
|
732
|
+
if (line.startsWith(" ")) return "context";
|
|
733
|
+
if (line.startsWith("(") || line.startsWith("…")) return "note";
|
|
734
|
+
return line === "" ? "context" : "note";
|
|
735
|
+
}
|
|
736
|
+
function isReviewNotice(text) {
|
|
737
|
+
return text.startsWith(REVIEW_NOTICE_BANNER);
|
|
738
|
+
}
|
|
739
|
+
function parseReviewNotice(text) {
|
|
740
|
+
if (!isReviewNotice(text)) return null;
|
|
741
|
+
const at = text.indexOf("\n");
|
|
742
|
+
const head = at === -1 ? text : text.slice(0, at);
|
|
743
|
+
const rest = at === -1 ? "" : text.slice(at + 1);
|
|
744
|
+
const lines = (rest === "" ? [] : rest.split("\n")).map((line) => ({
|
|
745
|
+
kind: reviewLineKindOf(line),
|
|
746
|
+
text: line
|
|
747
|
+
}));
|
|
748
|
+
const match = HEAD_PATTERN.exec(head);
|
|
749
|
+
if (match === null) {
|
|
750
|
+
return { head, action: null, path: null, counts: null, countsText: null, lines };
|
|
751
|
+
}
|
|
752
|
+
const countsText = match[3] ?? "";
|
|
753
|
+
return {
|
|
754
|
+
head,
|
|
755
|
+
action: parseAction(match[1] ?? ""),
|
|
756
|
+
// 路径**不 trim**:它原样进 title 与展示,动一个字符就可能是另一个文件
|
|
757
|
+
path: match[2] ?? "",
|
|
758
|
+
counts: parseCounts(countsText),
|
|
759
|
+
countsText,
|
|
760
|
+
lines
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
function ReviewNoticeCard({ notice, cwd }) {
|
|
764
|
+
const path = notice.path;
|
|
765
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "entry-review", "data-review-notice": "", "data-action": notice.action ?? void 0, children: [
|
|
766
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "entry-review-head", children: [
|
|
767
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.FileIcon, { name: path ?? "", size: 14, className: "entry-review-icon" }),
|
|
768
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "entry-review-path", title: path ?? notice.head, children: path === null ? notice.head : uiPrimitives.displayPathOf(path, cwd) }),
|
|
769
|
+
notice.action !== null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: notice.action === "create" ? "diff-badge" : "entry-review-badge", children: REVIEW_ACTION_TEXT[notice.action] }) : null,
|
|
770
|
+
notice.counts !== null ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "changes-counts", children: [
|
|
771
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "changes-added", children: `+${String(notice.counts.added)} 行` }),
|
|
772
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "changes-removed", children: `-${String(notice.counts.removed)} 行` })
|
|
773
|
+
] }) : notice.countsText === null || notice.countsText === "" ? null : (
|
|
774
|
+
// 算不出逐行 diff 时宿主写「逐行 diff 未给出」——中性一行,不装成计数。
|
|
775
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "entry-review-counts", children: notice.countsText })
|
|
776
|
+
)
|
|
777
|
+
] }),
|
|
778
|
+
notice.lines.length === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "entry-review-diff", children: notice.lines.map((line, at) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "entry-review-line", "data-kind": line.kind, children: line.text }, String(at))) })
|
|
779
|
+
] });
|
|
780
|
+
}
|
|
781
|
+
const THINK_PREVIEW_LIMIT = 90;
|
|
782
|
+
const TRACE_PAUSE_EPS = 120;
|
|
783
|
+
const AT_BOTTOM_EPS = 32;
|
|
784
|
+
const FLASH_MS = 1600;
|
|
785
|
+
function summarize(text) {
|
|
786
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
787
|
+
return flat.length > THINK_PREVIEW_LIMIT ? `${flat.slice(0, THINK_PREVIEW_LIMIT)}…` : flat;
|
|
788
|
+
}
|
|
789
|
+
const ui = ui$1.defineUiPlugin({
|
|
790
|
+
name: "执行轨迹",
|
|
791
|
+
apply(ui2) {
|
|
792
|
+
ui2.slots.register(ui$1.SLOT.thread, { id: "trace.view", order: 1 }, TraceView);
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
function TraceView(props) {
|
|
796
|
+
const entries = ui$1.useHostSelector(readEntries);
|
|
797
|
+
const live = ui$1.useHostSelector(readLive);
|
|
798
|
+
const sessionPath = ui$1.useHostSelector(readSessionPath);
|
|
799
|
+
const usage = ui$1.useHostSelector(readUsage);
|
|
800
|
+
const all = react.useMemo(() => [...entries, ...live], [entries, live]);
|
|
801
|
+
const model = react.useMemo(() => buildTraceModel(all), [all]);
|
|
802
|
+
const rounds = model.rounds;
|
|
803
|
+
const toolCount = all.filter((entry) => entry.kind === "tool").length;
|
|
804
|
+
const scroller = react.useRef(null);
|
|
805
|
+
const [expanded, setExpanded] = react.useState(() => /* @__PURE__ */ new Set());
|
|
806
|
+
const [inspectId, setInspectId] = react.useState(null);
|
|
807
|
+
const [selected, setSelected] = react.useState(null);
|
|
808
|
+
const [query, setQuery] = react.useState("");
|
|
809
|
+
const [flashId, setFlashId] = react.useState(null);
|
|
810
|
+
const followRef = react.useRef(true);
|
|
811
|
+
const autoTopRef = react.useRef(-1);
|
|
812
|
+
const appliedSelection = react.useRef(null);
|
|
813
|
+
const [focusId, setFocusId] = react.useState(null);
|
|
814
|
+
const roundOfEntry = react.useMemo(() => {
|
|
815
|
+
const map = /* @__PURE__ */ new Map();
|
|
816
|
+
for (const round of rounds) {
|
|
817
|
+
if (round.user !== null) map.set(round.user.id, round.index);
|
|
818
|
+
for (const step of round.steps) map.set(step.id, round.index);
|
|
819
|
+
}
|
|
820
|
+
return map;
|
|
821
|
+
}, [rounds]);
|
|
822
|
+
const roundUsage = react.useMemo(() => {
|
|
823
|
+
const map = /* @__PURE__ */ new Map();
|
|
824
|
+
for (const round of rounds) {
|
|
825
|
+
for (const step of round.steps) {
|
|
826
|
+
const own = entryUsage(step);
|
|
827
|
+
if (own !== null) map.set(round.index, { entryId: step.id, total: own.inputTokens + own.outputTokens });
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
return map;
|
|
831
|
+
}, [rounds]);
|
|
832
|
+
const hitIds = react.useMemo(() => {
|
|
833
|
+
const hits = /* @__PURE__ */ new Set();
|
|
834
|
+
if (selected === null) return hits;
|
|
835
|
+
for (const mark of model.marks) if (rangeHits(mark, selected)) hits.add(mark.id);
|
|
836
|
+
return hits;
|
|
837
|
+
}, [model.marks, selected]);
|
|
838
|
+
const search = react.useMemo(() => {
|
|
839
|
+
const needle = query.trim();
|
|
840
|
+
if (needle === "") return null;
|
|
841
|
+
const steps = /* @__PURE__ */ new Set();
|
|
842
|
+
const roundsHit = /* @__PURE__ */ new Set();
|
|
843
|
+
for (const round of rounds) {
|
|
844
|
+
for (const step of round.steps) {
|
|
845
|
+
if (!stepMatches(step, needle)) continue;
|
|
846
|
+
steps.add(step.id);
|
|
847
|
+
roundsHit.add(round.index);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return { steps, rounds: roundsHit, count: steps.size };
|
|
851
|
+
}, [query, rounds]);
|
|
852
|
+
const inspectEntry = react.useMemo(
|
|
853
|
+
() => inspectId === null ? null : all.find((entry) => entry.id === inspectId) ?? null,
|
|
854
|
+
[inspectId, all]
|
|
855
|
+
);
|
|
856
|
+
react.useEffect(() => {
|
|
857
|
+
if (rounds.length === 0) return;
|
|
858
|
+
setExpanded((current) => {
|
|
859
|
+
const last = rounds.length - 1;
|
|
860
|
+
if (current.has(last)) return current;
|
|
861
|
+
return new Set(current).add(last);
|
|
862
|
+
});
|
|
863
|
+
}, [rounds.length]);
|
|
864
|
+
react.useEffect(() => {
|
|
865
|
+
const element = scroller.current;
|
|
866
|
+
if (element === null || !followRef.current) return;
|
|
867
|
+
element.scrollTop = element.scrollHeight;
|
|
868
|
+
autoTopRef.current = element.scrollTop;
|
|
869
|
+
}, [all]);
|
|
870
|
+
react.useEffect(() => {
|
|
871
|
+
const element = scroller.current;
|
|
872
|
+
if (element === null) return void 0;
|
|
873
|
+
const onScroll = () => {
|
|
874
|
+
if (Math.abs(element.scrollTop - autoTopRef.current) <= 1) return;
|
|
875
|
+
const limit = element.scrollHeight - element.clientHeight;
|
|
876
|
+
if (limit <= 0) {
|
|
877
|
+
followRef.current = true;
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
const away = limit - element.scrollTop;
|
|
881
|
+
if (away <= AT_BOTTOM_EPS) followRef.current = true;
|
|
882
|
+
else if (away > TRACE_PAUSE_EPS) followRef.current = false;
|
|
883
|
+
};
|
|
884
|
+
element.addEventListener("scroll", onScroll, { passive: true });
|
|
885
|
+
return () => {
|
|
886
|
+
element.removeEventListener("scroll", onScroll);
|
|
887
|
+
};
|
|
888
|
+
}, []);
|
|
889
|
+
const focus = ui$1.useTraceFocus();
|
|
890
|
+
react.useEffect(() => {
|
|
891
|
+
if (focus === null) return;
|
|
892
|
+
const round = roundOfEntry.get(focus);
|
|
893
|
+
if (round !== void 0) {
|
|
894
|
+
setExpanded((current) => current.has(round) ? current : new Set(current).add(round));
|
|
895
|
+
}
|
|
896
|
+
setFocusId(focus);
|
|
897
|
+
setFlashId(focus);
|
|
898
|
+
ui$1.clearTraceFocus();
|
|
899
|
+
}, [focus, roundOfEntry]);
|
|
900
|
+
react.useEffect(() => {
|
|
901
|
+
if (flashId === null) return void 0;
|
|
902
|
+
const timer = window.setTimeout(() => {
|
|
903
|
+
setFlashId(null);
|
|
904
|
+
}, FLASH_MS);
|
|
905
|
+
return () => {
|
|
906
|
+
window.clearTimeout(timer);
|
|
907
|
+
};
|
|
908
|
+
}, [flashId]);
|
|
909
|
+
const openFromRow = (event, step) => {
|
|
910
|
+
const target = event.target;
|
|
911
|
+
if (target instanceof HTMLElement && // `.entry-review`(写前预览卡)与 `.tool-body` 同理:里面的 diff 要能划选复制,
|
|
912
|
+
// 划选松手算一次 click,不该顺手把检查器打开。
|
|
913
|
+
target.closest("button, a, summary, .tool-head, .tool-body, .entry-review, [data-trace-open]") !== null) {
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
setInspectId(step.id);
|
|
917
|
+
};
|
|
918
|
+
react.useCallback(() => setSelected(null), []);
|
|
919
|
+
const closeInspector = react.useCallback(() => setInspectId(null), []);
|
|
920
|
+
react.useEffect(() => {
|
|
921
|
+
if (selected === null) {
|
|
922
|
+
appliedSelection.current = null;
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
if (appliedSelection.current === selected) return;
|
|
926
|
+
appliedSelection.current = selected;
|
|
927
|
+
const hits = model.marks.filter((mark) => rangeHits(mark, selected));
|
|
928
|
+
if (hits.length === 0) return;
|
|
929
|
+
setExpanded((current) => {
|
|
930
|
+
const next = new Set(current);
|
|
931
|
+
for (const hit of hits) next.add(hit.round);
|
|
932
|
+
return next;
|
|
933
|
+
});
|
|
934
|
+
setFocusId(hits[0]?.id ?? null);
|
|
935
|
+
}, [selected, model.marks]);
|
|
936
|
+
react.useEffect(() => {
|
|
937
|
+
if (focusId === null) return;
|
|
938
|
+
const element = scroller.current;
|
|
939
|
+
const target = element?.querySelector(`[data-trace-step="${String(focusId)}"]`);
|
|
940
|
+
if (element === null || !(target instanceof HTMLElement)) return;
|
|
941
|
+
target.scrollIntoView({ block: "center" });
|
|
942
|
+
autoTopRef.current = element.scrollTop;
|
|
943
|
+
followRef.current = false;
|
|
944
|
+
setFocusId(null);
|
|
945
|
+
}, [focusId, expanded, model.marks]);
|
|
946
|
+
if (model.segments.length === 0) {
|
|
947
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "trace-page", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "chat", ref: scroller, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "chat-inner trace", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "trace-empty", children: "本会话还没有执行轨迹。发送消息或使用工具后,这里会显示执行过程。" }) }) }) });
|
|
948
|
+
}
|
|
949
|
+
const allOpen = expanded.size >= rounds.length;
|
|
950
|
+
const toggleAll = () => {
|
|
951
|
+
setExpanded(allOpen ? /* @__PURE__ */ new Set() : new Set(rounds.map((_, index) => index)));
|
|
952
|
+
};
|
|
953
|
+
const toggleRound = (index) => {
|
|
954
|
+
setExpanded((current) => {
|
|
955
|
+
const next = new Set(current);
|
|
956
|
+
if (next.has(index)) next.delete(index);
|
|
957
|
+
else next.add(index);
|
|
958
|
+
return next;
|
|
959
|
+
});
|
|
960
|
+
};
|
|
961
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "trace-page", children: [
|
|
962
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "chat", ref: scroller, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "chat-inner trace", children: [
|
|
963
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
964
|
+
TraceTimeline,
|
|
965
|
+
{
|
|
966
|
+
marks: model.marks,
|
|
967
|
+
boundaries: model.boundaries,
|
|
968
|
+
spanStart: model.spanStart,
|
|
969
|
+
spanEnd: model.spanEnd,
|
|
970
|
+
selected,
|
|
971
|
+
selectedCount: hitIds.size,
|
|
972
|
+
resetKey: sessionPath ?? "",
|
|
973
|
+
onSelect: setSelected
|
|
974
|
+
}
|
|
975
|
+
),
|
|
976
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "trace-stats", "data-trace-query": search === null ? void 0 : "1", children: [
|
|
977
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
978
|
+
rounds.length,
|
|
979
|
+
" 轮"
|
|
980
|
+
] }),
|
|
981
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
982
|
+
toolCount,
|
|
983
|
+
" 次工具调用"
|
|
984
|
+
] }),
|
|
985
|
+
usage !== null && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
986
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCoins, { size: 12 }),
|
|
987
|
+
" ",
|
|
988
|
+
uiPrimitives.formatTokens(usage),
|
|
989
|
+
" tok"
|
|
990
|
+
] }),
|
|
991
|
+
selected !== null && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "trace-focus-chip", "data-trace-focus": "1", children: [
|
|
992
|
+
"已聚焦区间内 ",
|
|
993
|
+
hitIds.size,
|
|
994
|
+
" 步"
|
|
995
|
+
] }),
|
|
996
|
+
search !== null && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "trace-focus-chip", "data-trace-search-count": "1", children: [
|
|
997
|
+
"搜索命中 ",
|
|
998
|
+
search.count,
|
|
999
|
+
" 步"
|
|
1000
|
+
] }),
|
|
1001
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "text-btn trace-toggle-all", onClick: toggleAll, children: allOpen ? "全部折叠" : "全部展开" }),
|
|
1002
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "trace-search", children: [
|
|
1003
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSearch, { size: 12 }),
|
|
1004
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1005
|
+
"input",
|
|
1006
|
+
{
|
|
1007
|
+
type: "search",
|
|
1008
|
+
className: "trace-search-input",
|
|
1009
|
+
"data-trace-search": "1",
|
|
1010
|
+
placeholder: "搜索步骤(工具名、参数、输出…)",
|
|
1011
|
+
"aria-label": "搜索轨迹里的步骤",
|
|
1012
|
+
value: query,
|
|
1013
|
+
onChange: (event) => {
|
|
1014
|
+
setQuery(event.currentTarget.value);
|
|
1015
|
+
},
|
|
1016
|
+
onKeyDown: (event) => {
|
|
1017
|
+
if (event.key !== "Escape") return;
|
|
1018
|
+
event.stopPropagation();
|
|
1019
|
+
setQuery("");
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
),
|
|
1023
|
+
query === "" ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1024
|
+
"button",
|
|
1025
|
+
{
|
|
1026
|
+
type: "button",
|
|
1027
|
+
className: "trace-search-clear",
|
|
1028
|
+
"data-trace-search-clear": "1",
|
|
1029
|
+
"data-tip": "清空搜索(Esc 也行)",
|
|
1030
|
+
"aria-label": "清空搜索",
|
|
1031
|
+
onClick: () => {
|
|
1032
|
+
setQuery("");
|
|
1033
|
+
},
|
|
1034
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconClose, { size: 10 })
|
|
1035
|
+
}
|
|
1036
|
+
)
|
|
1037
|
+
] })
|
|
1038
|
+
] }),
|
|
1039
|
+
search !== null && search.count === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "trace-empty", "data-trace-search-empty": "1", children: [
|
|
1040
|
+
"没有匹配「",
|
|
1041
|
+
query.trim(),
|
|
1042
|
+
"」的步骤。"
|
|
1043
|
+
] }) : null,
|
|
1044
|
+
model.segments.map((segment) => {
|
|
1045
|
+
if (segment.type === "compaction") {
|
|
1046
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1047
|
+
"div",
|
|
1048
|
+
{
|
|
1049
|
+
className: "trace-compact",
|
|
1050
|
+
"data-trace-compaction": String(segment.count),
|
|
1051
|
+
"data-tip": "从这一刻起,模型看到的历史已经是压缩后的摘要",
|
|
1052
|
+
children: [
|
|
1053
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "trace-compact-rule" }),
|
|
1054
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "trace-compact-tag", children: [
|
|
1055
|
+
"已压缩历史 · 第 ",
|
|
1056
|
+
segment.count,
|
|
1057
|
+
" 次"
|
|
1058
|
+
] }),
|
|
1059
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "trace-compact-rule" })
|
|
1060
|
+
]
|
|
1061
|
+
},
|
|
1062
|
+
`compact-${String(segment.entry.id)}`
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
const round = segment.round;
|
|
1066
|
+
const searching = search !== null;
|
|
1067
|
+
const hitRound = searching && search.rounds.has(round.index);
|
|
1068
|
+
if (searching && !hitRound) return null;
|
|
1069
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1070
|
+
RoundBlock,
|
|
1071
|
+
{
|
|
1072
|
+
round,
|
|
1073
|
+
open: expanded.has(round.index) || hitRound,
|
|
1074
|
+
onToggle: () => toggleRound(round.index),
|
|
1075
|
+
usage: roundUsage.get(round.index) ?? null,
|
|
1076
|
+
hitIds,
|
|
1077
|
+
searchHits: search?.steps ?? null,
|
|
1078
|
+
dimmed: selected !== null,
|
|
1079
|
+
inspectingId: inspectId,
|
|
1080
|
+
flashId,
|
|
1081
|
+
onOpenInspector: setInspectId,
|
|
1082
|
+
onRowClick: openFromRow,
|
|
1083
|
+
renderFactorySlot: props.renderFactorySlot
|
|
1084
|
+
},
|
|
1085
|
+
`round-${String(round.index)}`
|
|
1086
|
+
);
|
|
1087
|
+
})
|
|
1088
|
+
] }) }),
|
|
1089
|
+
inspectEntry !== null && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1090
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "trace-scrim", "data-trace-scrim": "1", onClick: closeInspector }),
|
|
1091
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1092
|
+
TraceInspector,
|
|
1093
|
+
{
|
|
1094
|
+
entry: inspectEntry,
|
|
1095
|
+
round: roundOfEntry.get(inspectEntry.id) ?? null,
|
|
1096
|
+
usageIsRoundTotal: inspectEntry.kind === "text" || inspectEntry.kind === "tool" ? roundUsage.get(roundOfEntry.get(inspectEntry.id) ?? -1)?.entryId === inspectEntry.id : false,
|
|
1097
|
+
onClose: closeInspector
|
|
1098
|
+
}
|
|
1099
|
+
)
|
|
1100
|
+
] })
|
|
1101
|
+
] });
|
|
1102
|
+
}
|
|
1103
|
+
function RoundBlock({
|
|
1104
|
+
round,
|
|
1105
|
+
open,
|
|
1106
|
+
onToggle,
|
|
1107
|
+
usage,
|
|
1108
|
+
hitIds,
|
|
1109
|
+
searchHits,
|
|
1110
|
+
dimmed,
|
|
1111
|
+
inspectingId,
|
|
1112
|
+
flashId,
|
|
1113
|
+
onOpenInspector,
|
|
1114
|
+
onRowClick,
|
|
1115
|
+
renderFactorySlot
|
|
1116
|
+
}) {
|
|
1117
|
+
const tools = round.steps.filter((step) => step.kind === "tool").length;
|
|
1118
|
+
const user = round.user;
|
|
1119
|
+
const images = user?.images?.length ?? 0;
|
|
1120
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `trace-round${open ? " open" : ""}`, "data-trace-round": String(round.index), children: [
|
|
1121
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "round-line", children: [
|
|
1122
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1123
|
+
"button",
|
|
1124
|
+
{
|
|
1125
|
+
className: "round-head",
|
|
1126
|
+
"data-round-index": String(round.index),
|
|
1127
|
+
"aria-expanded": open,
|
|
1128
|
+
"data-tip": open ? "折叠这一轮" : "展开这一轮的执行步骤",
|
|
1129
|
+
onClick: onToggle,
|
|
1130
|
+
children: [
|
|
1131
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "round-caret", children: open ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 13 }) : /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronRight, { size: 13 }) }),
|
|
1132
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "round-no", children: [
|
|
1133
|
+
"第 ",
|
|
1134
|
+
round.index + 1,
|
|
1135
|
+
" 轮"
|
|
1136
|
+
] }),
|
|
1137
|
+
user !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "round-user", children: user.text }),
|
|
1138
|
+
images > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "round-attach", children: [
|
|
1139
|
+
images,
|
|
1140
|
+
" 张附件"
|
|
1141
|
+
] }),
|
|
1142
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "round-meta", children: round.steps.length === 0 ? "无步骤" : `${round.steps.length} 步 · ${tools} 次工具` }),
|
|
1143
|
+
usage !== null && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1144
|
+
"span",
|
|
1145
|
+
{
|
|
1146
|
+
className: "round-tok",
|
|
1147
|
+
"data-tip": "这一轮所有模型请求的 prompt + completion 之和(宿主上报的真值)",
|
|
1148
|
+
children: [
|
|
1149
|
+
uiPrimitives.formatTokens(usage.total),
|
|
1150
|
+
" tok"
|
|
1151
|
+
]
|
|
1152
|
+
}
|
|
1153
|
+
)
|
|
1154
|
+
]
|
|
1155
|
+
}
|
|
1156
|
+
),
|
|
1157
|
+
user !== null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1158
|
+
"button",
|
|
1159
|
+
{
|
|
1160
|
+
type: "button",
|
|
1161
|
+
className: "round-open",
|
|
1162
|
+
"data-trace-open": String(user.id),
|
|
1163
|
+
"data-tip": "查看这条用户消息与附件",
|
|
1164
|
+
"aria-label": "查看这条用户消息与附件",
|
|
1165
|
+
onClick: () => onOpenInspector(user.id),
|
|
1166
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronRight, { size: 12 })
|
|
1167
|
+
}
|
|
1168
|
+
)
|
|
1169
|
+
] }),
|
|
1170
|
+
open && (round.steps.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "round-none", children: "无工具调用与系统事件" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "round-steps", children: round.steps.map((step) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1171
|
+
StepRow,
|
|
1172
|
+
{
|
|
1173
|
+
step,
|
|
1174
|
+
round: round.index,
|
|
1175
|
+
hit: hitIds.has(step.id),
|
|
1176
|
+
searchHit: searchHits === null ? false : searchHits.has(step.id),
|
|
1177
|
+
dim: dimmed && !hitIds.has(step.id),
|
|
1178
|
+
flash: flashId === step.id,
|
|
1179
|
+
inspecting: inspectingId === step.id,
|
|
1180
|
+
usageTotal: roundUsageOwnTotal(step, usage),
|
|
1181
|
+
onOpenInspector,
|
|
1182
|
+
onRowClick,
|
|
1183
|
+
renderFactorySlot
|
|
1184
|
+
},
|
|
1185
|
+
step.id
|
|
1186
|
+
)) }))
|
|
1187
|
+
] });
|
|
1188
|
+
}
|
|
1189
|
+
function roundUsageOwnTotal(step, usage) {
|
|
1190
|
+
if (usage === null || usage.entryId !== step.id) return null;
|
|
1191
|
+
return usage.total;
|
|
1192
|
+
}
|
|
1193
|
+
function StepRow({
|
|
1194
|
+
step,
|
|
1195
|
+
round,
|
|
1196
|
+
hit,
|
|
1197
|
+
searchHit,
|
|
1198
|
+
dim,
|
|
1199
|
+
flash,
|
|
1200
|
+
inspecting,
|
|
1201
|
+
usageTotal,
|
|
1202
|
+
onOpenInspector,
|
|
1203
|
+
onRowClick,
|
|
1204
|
+
renderFactorySlot
|
|
1205
|
+
}) {
|
|
1206
|
+
const clock = uiPrimitives.formatClock(step.ts ?? null);
|
|
1207
|
+
const duration = step.kind === "tool" ? uiPrimitives.formatTraceDuration(step.call.durationMs ?? null) : null;
|
|
1208
|
+
const status = step.kind === "tool" ? step.call.status : null;
|
|
1209
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1210
|
+
"div",
|
|
1211
|
+
{
|
|
1212
|
+
className: `step trace-step${hit ? " is-hit" : ""}${dim ? " is-dim" : ""}${inspecting ? " is-inspecting" : ""}${flash ? " is-flash" : ""}${searchHit ? " is-search-hit" : ""}`,
|
|
1213
|
+
"data-trace-step": String(step.id),
|
|
1214
|
+
"data-round": String(round),
|
|
1215
|
+
"data-kind": step.kind,
|
|
1216
|
+
"data-status": status ?? void 0,
|
|
1217
|
+
"data-hit": hit ? "1" : void 0,
|
|
1218
|
+
"data-search-hit": searchHit ? "1" : void 0,
|
|
1219
|
+
onClick: (event) => onRowClick(event, step),
|
|
1220
|
+
children: [
|
|
1221
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "trace-step-body", children: [
|
|
1222
|
+
step.kind === "tool" && renderFactorySlot(
|
|
1223
|
+
"transcript.tool-card",
|
|
1224
|
+
{ entry: step, variant: "trace" },
|
|
1225
|
+
{
|
|
1226
|
+
// 轨迹页只选「耗时口径」这一件局部组件;摘要 / 额外块 / 尾部动作都用定义
|
|
1227
|
+
// fallback(summary 一行;没有 intended、没有「在轨迹中查看」)。
|
|
1228
|
+
slots: { statusDetail: TraceStatus },
|
|
1229
|
+
// 定义没注册时(transcript 缺席/正在重载)落回自家工具行——D2 的保险丝。
|
|
1230
|
+
fallback: /* @__PURE__ */ jsxRuntime.jsx(TraceToolRow, { entry: step })
|
|
1231
|
+
}
|
|
1232
|
+
),
|
|
1233
|
+
step.kind === "thinking" && /* @__PURE__ */ jsxRuntime.jsxs("details", { className: "trace-think", children: [
|
|
1234
|
+
/* @__PURE__ */ jsxRuntime.jsxs("summary", { "data-tip": "展开思考全文", children: [
|
|
1235
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "th-label", children: "思考" }),
|
|
1236
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "th-preview", children: summarize(step.text) }),
|
|
1237
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 13, className: "th-chevron" })
|
|
1238
|
+
] }),
|
|
1239
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "body", children: step.text })
|
|
1240
|
+
] }),
|
|
1241
|
+
step.kind === "system" && /* @__PURE__ */ jsxRuntime.jsx(TraceSystemStep, { text: step.text }),
|
|
1242
|
+
step.kind === "plan" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "trace-plan", "data-tip": step.plan.text, children: [
|
|
1243
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "th-label", children: "计划" }),
|
|
1244
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "plan-title", children: step.plan.title }),
|
|
1245
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "plan-file", children: step.plan.file })
|
|
1246
|
+
] }),
|
|
1247
|
+
step.kind === "subagent" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "trace-sys trace-event", "data-tip": step.sub.task, children: [
|
|
1248
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "th-label", children: "子代理" }),
|
|
1249
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "event-text", children: step.sub.name }),
|
|
1250
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "event-state", children: step.sub.state })
|
|
1251
|
+
] }),
|
|
1252
|
+
step.kind === "turn-end" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "trace-sys trace-event", "data-tip": "这一轮没有正常结束", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "th-label", children: step.reason === "aborted" ? "已停止" : "过程失败" }) }),
|
|
1253
|
+
step.kind === "turn-max-tokens" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "trace-sys trace-event", "data-tip": "这次输出撞上了长度上限", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "th-label", children: "达到长度上限" }) }),
|
|
1254
|
+
step.kind === "model-retry" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "trace-sys trace-event", "data-tip": "同一个请求重试了", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "th-label", children: `模型重试(第 ${String(step.attempt)} 次)` }) })
|
|
1255
|
+
] }),
|
|
1256
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "trace-meta", children: [
|
|
1257
|
+
clock !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tmeta-clock", "data-tip": "这条记录最后写入的时刻(本机时区)", children: clock }),
|
|
1258
|
+
duration !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tmeta-dur", "data-tip": "这次工具调用从发起到结果回来的耗时", children: duration }),
|
|
1259
|
+
usageTotal !== null && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "tmeta-tok", "data-tip": "这一轮所有模型请求的 prompt + completion 之和", children: [
|
|
1260
|
+
uiPrimitives.formatTokens(usageTotal),
|
|
1261
|
+
" tok"
|
|
1262
|
+
] }),
|
|
1263
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1264
|
+
"button",
|
|
1265
|
+
{
|
|
1266
|
+
type: "button",
|
|
1267
|
+
className: "tmeta-open",
|
|
1268
|
+
"data-trace-open": String(step.id),
|
|
1269
|
+
"data-tip": "打开检查器:输入、输出、思考全文、计时与用量",
|
|
1270
|
+
"aria-label": "打开检查器",
|
|
1271
|
+
onClick: () => onOpenInspector(step.id),
|
|
1272
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronRight, { size: 12 })
|
|
1273
|
+
}
|
|
1274
|
+
)
|
|
1275
|
+
] })
|
|
1276
|
+
]
|
|
1277
|
+
}
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
function TraceSystemStep({ text }) {
|
|
1281
|
+
const notice = parseReviewNotice(text);
|
|
1282
|
+
if (notice === null) {
|
|
1283
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "trace-sys", "data-tip": text, children: text });
|
|
1284
|
+
}
|
|
1285
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "trace-review", children: /* @__PURE__ */ jsxRuntime.jsx(ReviewNoticeCard, { notice, cwd: "" }) });
|
|
1286
|
+
}
|
|
1287
|
+
function TraceStatus(props) {
|
|
1288
|
+
const call = props.call;
|
|
1289
|
+
const duration = uiPrimitives.formatTraceDuration(call.durationMs ?? null);
|
|
1290
|
+
const statusText = uiPrimitives.TOOL_STATUS_TEXT[call.status] ?? call.status;
|
|
1291
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "status", children: [
|
|
1292
|
+
call.status === "running" ? /* @__PURE__ */ jsxRuntime.jsx("i", { className: "tc-spin", "aria-hidden": "true" }) : null,
|
|
1293
|
+
call.status === "done" ? "" : statusText,
|
|
1294
|
+
call.status === "done" ? duration ?? "" : duration === null ? "" : ` · 用时 ${duration}`
|
|
1295
|
+
] });
|
|
1296
|
+
}
|
|
1297
|
+
function TraceToolRow({ entry }) {
|
|
1298
|
+
const call = entry.call;
|
|
1299
|
+
const [open, setOpen] = react.useState(false);
|
|
1300
|
+
const expandable = call.status !== "preparing";
|
|
1301
|
+
const bodyOpen = open && expandable;
|
|
1302
|
+
const match = uiPrimitives.matchTool(call.name);
|
|
1303
|
+
const Icon = match.Icon;
|
|
1304
|
+
const summary = uiPrimitives.toolSummary(call.name, call.argsText);
|
|
1305
|
+
const duration = uiPrimitives.formatTraceDuration(call.durationMs ?? null);
|
|
1306
|
+
const statusText = uiPrimitives.TOOL_STATUS_TEXT[call.status] ?? call.status;
|
|
1307
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `entry tool-card status-${call.status}${bodyOpen ? " open" : ""}`, children: [
|
|
1308
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1309
|
+
"div",
|
|
1310
|
+
{
|
|
1311
|
+
className: "tool-head",
|
|
1312
|
+
role: "button",
|
|
1313
|
+
tabIndex: expandable ? 0 : -1,
|
|
1314
|
+
...expandable ? { "aria-expanded": bodyOpen } : {},
|
|
1315
|
+
"data-tip": expandable ? bodyOpen ? "收起参数与结果" : "展开参数与结果" : "正在准备参数",
|
|
1316
|
+
onClick: () => {
|
|
1317
|
+
if (expandable) setOpen(!open);
|
|
1318
|
+
},
|
|
1319
|
+
onKeyDown: (event) => {
|
|
1320
|
+
if (!expandable || event.key !== "Enter" && event.key !== " ") return;
|
|
1321
|
+
event.preventDefault();
|
|
1322
|
+
setOpen(!open);
|
|
1323
|
+
},
|
|
1324
|
+
children: [
|
|
1325
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tool-dot", "aria-hidden": "true" }),
|
|
1326
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 14, className: "tool-icon" }),
|
|
1327
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "verb", children: uiPrimitives.toolVerb(match.base, call.status) }),
|
|
1328
|
+
match.known ? null : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: call.name }),
|
|
1329
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "preview", children: summary }),
|
|
1330
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "status", children: [
|
|
1331
|
+
call.status === "running" ? /* @__PURE__ */ jsxRuntime.jsx("i", { className: "tc-spin", "aria-hidden": "true" }) : null,
|
|
1332
|
+
call.status === "done" ? "" : statusText,
|
|
1333
|
+
call.status === "done" ? duration === null ? "" : duration : duration === null ? "" : ` · 用时 ${duration}`
|
|
1334
|
+
] }),
|
|
1335
|
+
expandable ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 11, className: "tc-chevron" }) : null
|
|
1336
|
+
]
|
|
1337
|
+
}
|
|
1338
|
+
),
|
|
1339
|
+
bodyOpen ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tool-body", children: [
|
|
1340
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "label", children: "参数" }),
|
|
1341
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "args", children: uiPrimitives.prettyJson(call.argsText) }),
|
|
1342
|
+
call.resultText === void 0 || call.resultText === "" ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1343
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "label", children: "结果" }),
|
|
1344
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "result", children: call.resultText })
|
|
1345
|
+
] })
|
|
1346
|
+
] }) : null
|
|
1347
|
+
] });
|
|
1348
|
+
}
|
|
1349
|
+
const NO_ENTRIES = Object.freeze([]);
|
|
1350
|
+
function readEntries(snapshot) {
|
|
1351
|
+
const value = snapshot?.entries;
|
|
1352
|
+
return Array.isArray(value) ? value : NO_ENTRIES;
|
|
1353
|
+
}
|
|
1354
|
+
function readLive(snapshot) {
|
|
1355
|
+
const value = snapshot?.liveEntries;
|
|
1356
|
+
return Array.isArray(value) ? value : NO_ENTRIES;
|
|
1357
|
+
}
|
|
1358
|
+
function readSessionPath(snapshot) {
|
|
1359
|
+
const status = snapshot?.["status"];
|
|
1360
|
+
if (typeof status !== "object" || status === null) return null;
|
|
1361
|
+
const value = status["sessionPath"];
|
|
1362
|
+
return typeof value === "string" ? value : null;
|
|
1363
|
+
}
|
|
1364
|
+
function readUsage(snapshot) {
|
|
1365
|
+
const status = snapshot?.["status"];
|
|
1366
|
+
if (typeof status !== "object" || status === null) return null;
|
|
1367
|
+
const usage = status["usage"];
|
|
1368
|
+
if (typeof usage !== "object" || usage === null) return null;
|
|
1369
|
+
const input = usage["inputTokens"];
|
|
1370
|
+
const output = usage["outputTokens"];
|
|
1371
|
+
if (typeof input !== "number" || typeof output !== "number") return null;
|
|
1372
|
+
const total = input + output;
|
|
1373
|
+
return Number.isFinite(total) ? total : null;
|
|
1374
|
+
}
|
|
1375
|
+
exports.default = ui;
|
|
1376
|
+
};
|