@tea-agent/loop-agent 0.1.0-fe-test.3 → 0.1.0-fe-test.4
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/AGENTS.md +6 -3
- package/CHANGELOG.md +605 -93
- package/README.md +11 -5
- package/bin/loop-agent.js +7 -3
- package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
- package/dist/adapters/context-transfer/pi-session.js +61 -0
- package/dist/application/dag/generate-task-dag.js +90 -21
- package/dist/application/dag/run-dag.js +41 -0
- package/dist/application/task-lifecycle/advance.js +40 -5
- package/dist/application/task-lifecycle/observe.js +171 -17
- package/dist/application/task-lifecycle/plan-transitions.js +42 -7
- package/dist/application/task-lifecycle/recommendations.js +13 -2
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +44 -10
- package/dist/cli/program.js +82 -6
- package/dist/cli/update/notifier.js +2 -2
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/cli.js +2 -1
- package/dist/commands/client-recovery.js +11 -36
- package/dist/commands/dag-artifact.js +284 -0
- package/dist/commands/dag-context.js +184 -0
- package/dist/commands/dag-follow-up.js +138 -0
- package/dist/commands/dag-rerun-task.js +2 -0
- package/dist/commands/dag-rerun.js +261 -2
- package/dist/commands/init-model-catalog.js +486 -0
- package/dist/commands/init-upgrade.js +265 -97
- package/dist/commands/init.js +455 -28
- package/dist/commands/inspect-next.js +8 -0
- package/dist/commands/task-advance.js +73 -1
- package/dist/commands/task-source-prepare.js +5 -0
- package/dist/commands/task-status.js +1 -0
- package/dist/executors/dag-pi-executor.js +4321 -231
- package/dist/executors/pi-event-serializer.js +42 -1
- package/dist/executors/pi-executor.js +70 -6
- package/dist/executors/pi-extension-resolver.js +245 -0
- package/dist/executors/pi-playwright-cli-tool.js +74 -28
- package/dist/executors/pi-read-budget-policy.js +239 -0
- package/dist/executors/pi-sdk-executor.js +263 -59
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +1411 -240
- package/dist/executors/shell-write-guard.js +14 -0
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/governance/checks.js +1 -0
- package/dist/{worker → infrastructure}/console/app-data.js +4 -0
- package/dist/infrastructure/console/artifact-revision-store.js +430 -0
- package/dist/infrastructure/console/context-export-store.js +160 -0
- package/dist/infrastructure/console/dir-lock.js +132 -0
- package/dist/infrastructure/console/operation-store.js +417 -0
- package/dist/infrastructure/harness/artifact-store.js +10 -1
- package/dist/infrastructure/harness/atomic-write.js +35 -2
- package/dist/shared/context-transfer/artifact-revision.js +172 -0
- package/dist/shared/context-transfer.js +418 -0
- package/dist/shared/dag-failure-category.js +150 -0
- package/dist/shared/dag-prompt-override.js +27 -0
- package/dist/shared/openspec-spec.js +70 -4
- package/dist/shared/operator/capabilities.js +65 -4
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/pi-context-pressure/checkpoint.js +116 -0
- package/dist/shared/pi-context-pressure/compaction-policy.js +151 -0
- package/dist/shared/pi-context-pressure/env.js +58 -0
- package/dist/shared/pi-context-pressure/extension.js +100 -0
- package/dist/shared/pi-context-pressure/index.js +7 -0
- package/dist/shared/pi-context-pressure/overflow.js +252 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +386 -0
- package/dist/shared/pi-context-pressure/telemetry.js +51 -0
- package/dist/shared/playwright-cli-command-policy.js +15 -0
- package/dist/shared/preview.js +28 -4
- package/dist/shared/update/console-notifier.js +100 -0
- package/dist/{cli → shared}/update/npm-client.js +70 -15
- package/dist/{cli → shared}/update/state.js +41 -13
- package/dist/task/config-types.js +125 -6
- package/dist/task/contract/adopt.js +4 -0
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +3 -0
- package/dist/task/contract/diff.js +26 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/import-revision.js +4 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +23 -1
- package/dist/task/contract/schema.js +9 -1
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/frontend-project-capability.js +203 -20
- package/dist/task/runtime.js +5 -2
- package/dist/task/source-prepare/build-draft.js +18 -3
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +513 -0
- package/dist/task/source-prepare/index.js +3 -0
- package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
- package/dist/task/source-prepare/ledger-review.js +214 -0
- package/dist/task/source-prepare/ledger.js +545 -0
- package/dist/task/source-prepare/parse-intent.js +24 -4
- package/dist/task/source-prepare/prepare.js +368 -2
- package/dist/task/source-prepare/semantic-intake.js +25 -5
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/task/source-references.js +22 -1
- package/dist/task/task-demand-routing.js +3 -0
- package/dist/worker/cli.js +18 -2
- package/dist/worker/console/chat/assistant-content.js +7 -0
- package/dist/worker/console/chat/chat-event-store.js +159 -18
- package/dist/worker/console/chat/chat-ui-policy.js +4 -2
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +103 -0
- package/dist/worker/console/chat/goal-round-driver.js +72 -0
- package/dist/worker/console/chat/goals.js +300 -0
- package/dist/worker/console/chat/model-resolver.js +7 -4
- package/dist/worker/console/chat/operation-card.js +8 -1
- package/dist/worker/console/chat/pi-console-config.js +81 -10
- package/dist/worker/console/chat/pi-runtime.js +868 -30
- package/dist/worker/console/chat/provider-error.js +99 -0
- package/dist/worker/console/chat/repo-browser.js +101 -12
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +1451 -145
- package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
- package/dist/worker/console/chat/semantic-activity.js +25 -24
- package/dist/worker/console/chat/session-catalog.js +50 -0
- package/dist/worker/console/chat/session-stats.js +275 -0
- package/dist/worker/console/chat/session-store.js +348 -76
- package/dist/worker/console/chat/shortcuts.js +26 -3
- package/dist/worker/console/chat/sift-bridge.js +1 -0
- package/dist/worker/console/chat/todos.js +115 -0
- package/dist/worker/console/chat/tool-preview.js +42 -0
- package/dist/worker/console/chat/turn-process.js +185 -112
- package/dist/worker/console/chat/user-questions.js +266 -0
- package/dist/worker/console/chat/workspace-landing.js +79 -0
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- package/dist/worker/console/context-transfer-diagnostics.js +198 -0
- package/dist/worker/console/dag-confirmation.js +1 -1
- package/dist/worker/console/dag-execution-receipt.js +54 -3
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +50 -1
- package/dist/worker/console/frontend-human-decision-adapter.js +19 -0
- package/dist/worker/console/frontend-split-operation-adapter.js +20 -0
- package/dist/worker/console/human-gate-token.js +1 -1
- package/dist/worker/console/index.js +6 -3
- package/dist/worker/console/inspect-split.js +18 -0
- package/dist/worker/console/interview/assessment.js +1 -1
- package/dist/worker/console/interview/session.js +1 -1
- package/dist/worker/console/native-directory-picker.js +13 -0
- package/dist/worker/console/operation-run-facts.js +19 -3
- package/dist/worker/console/operation-runner.js +45 -4
- package/dist/worker/console/operation-sse.js +1 -1
- package/dist/worker/console/operation-wait.js +1 -1
- package/dist/worker/console/operator-actions.js +534 -15
- package/dist/worker/console/operator-selection.js +6 -2
- package/dist/worker/console/operator-surface-health.js +2 -1
- package/dist/worker/console/operator-user-error.js +171 -2
- package/dist/worker/console/pi-plugins.catalog.json +73658 -0
- package/dist/worker/console/pi-plugins.js +238 -0
- package/dist/worker/console/pi-readiness.js +7 -6
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/recovery-cta.js +4 -4
- package/dist/worker/console/recovery-error-copy.js +4 -4
- package/dist/worker/console/routes.js +1231 -10
- package/dist/worker/console/security.js +102 -13
- package/dist/worker/console/server.js +762 -159
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BmOEx0gA.js → abnfDiagram-N423BO3Z-BZogYNl1.js} +1 -1
- package/dist/worker/console/static/assets/{arc-BGiVVe8b.js → arc-DcJTLe2v.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-nDdu4rgJ.js → architectureDiagram-T3A2C74G-B39EQQ9n.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bb5u0BWf.js → blockDiagram-VBNYF7ZC-CitCGV56.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BlhC0j94.js → c4Diagram-5PPSVZJV-rvWuOHLG.js} +1 -1
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-Ai8_qQXI.js → chunk-2GRJ4B5K-DGXplIJs.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B9gyCjqX.js → chunk-2Q5K7J3B-ur9OqjPn.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Bzbj3zGH.js → chunk-5RXB4S5H-D1KqU_Vi.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BT415PvT.js → chunk-5VM5RSS4-BlVZrbtM.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D_A5_5QL.js → chunk-6Q2QTUOP-BAzz3nQy.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-srJkaP3f.js → chunk-GF5L2VYU-CP_nYuCV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-UYGvEP4l.js → chunk-JWPE2WC7-CWvKQ80X.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B8luBrrz.js → chunk-KBJHAD2P-CyUki8wp.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DN7wXZSq.js → chunk-RYQCIY6F-5NYzNKfY.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DXKyMuKS.js → chunk-XXDRQBXY-DHdUgjS-.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-dqvoynXj.js → cose-bilkent-JH36ORCC-ANQ5g_t6.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2--PcyL34A.js → cynefin-VYW2F7L2-CruT_4-0.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DvWs_hTY.js → cynefinDiagram-MW4NZA55-rbFo77ID.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-DxeIxbyO.js → dagre-VZM6K2ZE-asstxBQs.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DPCG61Of.js → diagram-7IWD3JNH-DzTyBZwI.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CmuU50-U.js → diagram-B4RE2ZJO-gw8ccH3B.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B61XLD_v.js → diagram-LBJQPF4R-B8RpZzOf.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BB7HTRRY.js → diagram-Q27KOJAE-B1zJkCS9.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-DvkboAIp.js → diagram-UB23O5K3-B6JLWZmO.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BdJ_y1fL.js → ebnfDiagram-BXEA7PRR-q2iZP-Ps.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-9bUBZTRi.js → erDiagram-JOGREHBK-B3dbbktQ.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dw4L4RBa.js → flowDiagram-UKHOOZJN-C-zc6-kB.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Jr82N_QP.js → ganttDiagram-PKOTCBZU-BSolnot9.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-DAz9wFLr.js → gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js} +1 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
- package/dist/worker/console/static/assets/index-DhfjOafu.js +449 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-CBB5Np7y.js → infoDiagram-6WML65LV-DQaZqJOH.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-D8IOp94y.js → ishikawaDiagram-WSZJBQD7-DsdX1WnE.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dgd3AHGG.js → journeyDiagram-NVQOT4AX-CP5EYDZL.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BmYOxLE9.js → kanban-definition-27J2QSJJ-DAm14Dr8.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DfYTEF6J.js → linear-gZECoLc5.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BjuFPRqa.js → mermaid.core-BRJNIM6p.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CLyUViGd.js → mindmap-definition-FAOFIHXS-Cja3kLkR.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BvX2Di4-.js → pegDiagram-VL7TDLO6-22ZGFisL.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BFj0_OLv.js → pieDiagram-7S7Q4E2Y-BXin0Y1o.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BIUrD_hx.js → quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-CHBB48fj.js → railroadDiagram-AXF67PYL-C1-gTieN.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-sJrYw2Sf.js → requirementDiagram-LRYGKXZP--H5N2iI1.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BzHH6fPR.js → sankeyDiagram-W5VNT64P-CgWAPeRz.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-7QCnelCt.js → sequenceDiagram-SI44F4Z6-CrKqzGvt.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-sDYSxn72.js → sizeCapture-X5ZJPWSS-BB3wG06K.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-XpiUdwzm.js → stateDiagram-OKZ733FA-DjsGgdgY.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DvqgNPzD.js → swimlanes-SLNWSIFB-DYKEbvAR.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-2TyOYNx0.js → timeline-definition-Z64GVDOM-eQOb5k9Y.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B-nM6wM2.js → vennDiagram-T6HMQDX7-B2-l9FIu.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-B86wPdbr.js → wardleyDiagram-T6FBY63Y-BX2Cda3l.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Dr1C4AQz.js → xychartDiagram-ELKLHX3M-D9S892ph.js} +1 -1
- package/dist/worker/console/static/index.html +7 -2
- package/dist/worker/console/static-src/active-run-badge.js +17 -0
- package/dist/worker/console/static-src/app/console-types.js +68 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +43 -7
- package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
- package/dist/worker/console/static-src/app/useRunProgress.js +54 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +74 -2
- package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
- package/dist/worker/console/static-src/operator-chat/cards/failure-category-advice.js +25 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +264 -13
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +113 -0
- package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
- package/dist/worker/console/static-src/operator-chat/input-history.js +78 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +338 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
- package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +33 -1
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +55 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +448 -109
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +344 -27
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +323 -11
- package/dist/worker/console/static-src/operator-chat/useComposer.js +45 -4
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +97 -13
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +57 -9
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
- package/dist/worker/console/static-src/operator-chat/workspace-reorder.js +18 -0
- package/dist/worker/console/static-src/pages/tasks/run-id-resolution.js +79 -0
- package/dist/worker/console/static-src/pages/tasks/run-ownership-verify.js +23 -0
- package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +216 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
- package/dist/worker/console/static-src/shell/useWorkspaces.js +415 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +356 -0
- package/dist/worker/console/workspace-context.js +399 -0
- package/dist/worker/console/workspace-registry.js +487 -0
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/loop-agent/loop-agent-client.js +7 -3
- package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
- package/dist/worker/materialize/harness-task-lineage.js +5 -2
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observability/read-model.js +26 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-input.js +160 -3
- package/dist/worker/observe/node-process.js +377 -0
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +278 -3
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/shell-handler-keys.js +34 -0
- package/dist/worker/observe/static/api.js +154 -4
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/constants.js +26 -19
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +139 -0
- package/dist/worker/observe/static/dag-helpers.js +4 -2
- package/dist/worker/observe/static/dag-history-labels.js +5 -0
- package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +208 -0
- package/dist/worker/observe/static/format.js +60 -0
- package/dist/worker/observe/static/index.html +10 -5
- package/dist/worker/observe/static/inspect-bootstrap.d.ts +8 -0
- package/dist/worker/observe/static/inspect-bootstrap.js +57 -0
- package/dist/worker/observe/static/inspect-workspace.js +374 -0
- package/dist/worker/observe/static/kpi.js +2 -2
- package/dist/worker/observe/static/markdown-render.js +20 -1
- package/dist/worker/observe/static/operator-chrome.css +168 -24
- package/dist/worker/observe/static/operator-chrome.d.ts +30 -5
- package/dist/worker/observe/static/operator-chrome.js +354 -101
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +38 -0
- package/dist/worker/observe/static/relations.js +7 -7
- package/dist/worker/observe/static/router.d.ts +57 -0
- package/dist/worker/observe/static/router.js +67 -1
- package/dist/worker/observe/static/run-processing.js +4 -2
- package/dist/worker/observe/static/shell-chrome.js +2 -2
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +191 -1
- package/dist/worker/observe/static/styles.css +1720 -86
- package/dist/worker/observe/static/views/dag-graph.js +5 -3
- package/dist/worker/observe/static/views/dag-inspector.js +2601 -188
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +39 -18
- package/dist/worker/observe/static/views/dags.js +10 -6
- package/dist/worker/observe/static/views/dashboard.js +18 -8
- package/dist/worker/observe/static/views/failures.js +5 -2
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +8 -2
- package/dist/worker/observe/static/views/run.js +15 -4
- package/dist/worker/observe/static/views/session-timeline.js +386 -25
- package/dist/worker/observe/static/views/task.js +63 -3
- package/dist/worker/outcomes/adapters.js +19 -0
- package/dist/worker/outcomes/types.js +1 -0
- package/dist/worker/pool/attempt-lease.js +97 -66
- package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
- package/dist/worker/pool/reconcile.js +46 -1
- package/dist/worker/pool/run-store.js +2 -0
- package/dist/worker/pool/state-projection.js +2 -0
- package/dist/worker/task-spec/workflow-routing.js +8 -3
- package/dist/workflows/dag/artifact-bindings.js +149 -0
- package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +470 -31
- package/dist/workflows/dag/backend-test-markdown-workflow.js +189 -2
- package/dist/workflows/dag/backend-test-plan-protocol.js +210 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +168 -16
- package/dist/workflows/dag/backend-test-result-contract.js +5 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +506 -73
- package/dist/workflows/dag/backend-test-scenario-partitions.js +135 -2
- package/dist/workflows/dag/backend-test-writer-completeness.js +131 -28
- package/dist/workflows/dag/budget-enforcement.js +10 -0
- package/dist/workflows/dag/context-receipt.js +305 -0
- package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
- package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
- package/dist/workflows/dag/context-transfer/renderers.js +93 -0
- package/dist/workflows/dag/contract-output-registry.js +15 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- package/dist/workflows/dag/convergence/controller.js +141 -0
- package/dist/workflows/dag/dag-retry-schema.js +138 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +1 -1
- package/dist/workflows/dag/dynamic-runtime/map.js +2 -1
- package/dist/workflows/dag/failure-category.js +7 -116
- package/dist/workflows/dag/frontend-closeout.js +221 -0
- package/dist/workflows/dag/frontend-design-policy.js +400 -0
- package/dist/workflows/dag/frontend-human-decision.js +182 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1377 -141
- package/dist/workflows/dag/frontend-plan-render.js +26 -1
- package/dist/workflows/dag/frontend-prewrite-gate.js +376 -318
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +159 -0
- package/dist/workflows/dag/frontend-recovery-capsule.js +455 -0
- package/dist/workflows/dag/frontend-recovery-controller.js +226 -0
- package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +21 -10
- package/dist/workflows/dag/frontend-recovery-run.js +166 -34
- package/dist/workflows/dag/frontend-repair.js +7 -424
- package/dist/workflows/dag/frontend-review-context.js +348 -20
- package/dist/workflows/dag/frontend-review-findings.js +270 -0
- package/dist/workflows/dag/frontend-risk.js +15 -2
- package/dist/workflows/dag/frontend-shadow-dual-write.js +941 -0
- package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
- package/dist/workflows/dag/frontend-shape-facts.js +419 -0
- package/dist/workflows/dag/frontend-shape.js +435 -0
- package/dist/workflows/dag/frontend-source-fidelity-ledger.js +108 -0
- package/dist/workflows/dag/frontend-split-application-service.js +203 -0
- package/dist/workflows/dag/frontend-split-orchestrator.js +899 -0
- package/dist/workflows/dag/frontend-test-case-checklist.js +30 -4
- package/dist/workflows/dag/frontend-test-case-manifest.js +11 -4
- package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
- package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
- package/dist/workflows/dag/frontend-test-html-report.js +3 -1
- package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
- package/dist/workflows/dag/frontend-test-layout.js +159 -0
- package/dist/workflows/dag/frontend-test-markdown.js +61 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +188 -42
- package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -0
- package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
- package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
- package/dist/workflows/dag/frontend-verification-trace.js +281 -29
- package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
- package/dist/workflows/dag/frontend-writer-admission.js +319 -0
- package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
- package/dist/workflows/dag/frontend-writer-status.js +256 -0
- package/dist/workflows/dag/init-hybrid.js +1670 -706
- package/dist/workflows/dag/interrupt-request.js +10 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +1141 -32
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +158 -7
- package/dist/workflows/dag/recovery-lease.js +170 -0
- package/dist/workflows/dag/report.js +37 -1
- package/dist/workflows/dag/rerun-feedback.js +526 -0
- package/dist/workflows/dag/rerun-plan.js +790 -28
- package/dist/workflows/dag/rerun-run.js +700 -21
- package/dist/workflows/dag/rerun-task.js +311 -14
- package/dist/workflows/dag/retry-policy.js +336 -101
- package/dist/workflows/dag/runner.js +596 -121
- package/dist/workflows/dag/scheduler.js +133 -20
- package/dist/workflows/dag/skill-snapshot.js +17 -0
- package/dist/workflows/dag/structured-output-repair.js +712 -0
- package/dist/workflows/dag/types.js +579 -31
- package/dist/workflows/dag/validate.js +92 -32
- package/docs/README.md +2 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/architecture/runtime-boundaries.md +8 -7
- package/docs/architecture/worker-and-feature.md +1 -1
- package/docs/examples/README.md +5 -0
- package/docs/init-surface.manifest.json +36 -12
- package/docs/operations/README.md +1 -1
- package/docs/operations/local-development-environment.md +22 -5
- package/docs/skills/vetted-skill-registry.md +16 -0
- package/docs/templates/README.md +4 -2
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +95 -1
- package/docs/templates/backend-test-dag.json +278 -244
- package/docs/templates/frontend-implementation-contract.schema.json +684 -24
- package/docs/templates/frontend-implementation-dag.json +89 -0
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-dag.json +8 -10
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
- package/docs/templates/init-managed-agents.md +13 -3
- package/docs/templates/product-line/task.yaml +1 -1
- package/docs/templates/spec-registry.schema.json +45 -0
- package/harness.json +2 -2
- package/package.json +19 -5
- package/scripts/next-info.mjs +356 -0
- package/scripts/next-publish-gate.mjs +238 -0
- package/scripts/release-source-binding.mjs +251 -0
- package/skills/analyze-product-requirements/SKILL.md +8 -5
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
- package/skills/analyze-product-requirements/references/example.md +50 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
- package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
- package/skills/codebase-scout/SKILL.md +1 -1
- package/skills/fe-test-ui-scout/SKILL.md +65 -0
- package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
- package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
- package/skills/frontend-bounded-implement/SKILL.md +15 -14
- package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
- package/skills/frontend-contract/SKILL.md +23 -0
- package/skills/frontend-contract/references/contract-protocol.md +34 -0
- package/skills/frontend-design-review/SKILL.md +22 -41
- package/skills/frontend-plan/SKILL.md +26 -0
- package/skills/frontend-plan/references/decision-contract.md +37 -0
- package/skills/frontend-plan/references/design-decisions.md +17 -0
- package/skills/frontend-review/SKILL.md +20 -15
- package/skills/frontend-review/references/review-findings.md +6 -7
- package/skills/frontend-scout/SKILL.md +25 -0
- package/skills/frontend-scout/references/design-evidence.md +16 -0
- package/skills/frontend-scout/references/scout-evidence.md +23 -0
- package/skills/frontend-verification/SKILL.md +1 -1
- package/skills/improve-codebase-architecture/SKILL.md +81 -0
- package/skills/improve-codebase-architecture/deepening.md +37 -0
- package/skills/improve-codebase-architecture/html-report.md +123 -0
- package/skills/improve-codebase-architecture/interface-design.md +44 -0
- package/skills/improve-codebase-architecture/language.md +53 -0
- package/skills/loop-agent/references/command-reference.md +32 -4
- package/skills/loop-agent/references/hybrid-dag.md +9 -2
- package/skills/playwright-cli/SKILL.md +23 -1
- package/skills/playwright-cli-case-generator/SKILL.md +50 -13
- package/dist/worker/console/operation-store.js +0 -169
- package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
- package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
- package/skills/frontend-implementation/SKILL.md +0 -52
- package/skills/frontend-implementation/references/code-standards.md +0 -33
- package/skills/frontend-implementation/references/design-spec.md +0 -56
- package/skills/frontend-implementation/references/node-contracts.md +0 -31
- /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
|
@@ -11,14 +11,47 @@ import {
|
|
|
11
11
|
} from "../constants.js";
|
|
12
12
|
import { clearNode, el } from "../dom.js";
|
|
13
13
|
import { attemptFailureLabel } from "../dag-history-labels.js";
|
|
14
|
-
import { fetchJson, fetchSpecEvidenceFile, fetchDagNodeInput } from "../api.js";
|
|
15
|
-
import { badge, formatMs } from "../format.js";
|
|
16
|
-
import { renderMarkdown } from "../markdown-render.js";
|
|
17
14
|
import {
|
|
15
|
+
contextTransferReasonLabel,
|
|
16
|
+
describeTransferError,
|
|
17
|
+
formatContextTransferReasonList,
|
|
18
|
+
} from "../dag-context-reason-labels.js";
|
|
19
|
+
import {
|
|
20
|
+
describeInspectorMeta,
|
|
21
|
+
inspectorFieldLabel,
|
|
22
|
+
inspectorListValueLabel,
|
|
23
|
+
inspectorValueLabel,
|
|
24
|
+
} from "../dag-inspector-humanize.js";
|
|
25
|
+
import {
|
|
26
|
+
fetchJson,
|
|
27
|
+
fetchSpecEvidenceFile,
|
|
28
|
+
fetchDagNodeInput,
|
|
29
|
+
fetchDagNodeContext,
|
|
30
|
+
fetchDagNodeArtifacts,
|
|
31
|
+
fetchDagNodeArtifactPreview,
|
|
32
|
+
fetchDagRunLineage,
|
|
33
|
+
fetchDagNodeProcess,
|
|
34
|
+
postOperatorAction,
|
|
35
|
+
fetchOperatorOperation,
|
|
36
|
+
downloadContextExport,
|
|
37
|
+
} from "../api.js";
|
|
38
|
+
import {
|
|
39
|
+
badge,
|
|
40
|
+
formatMs,
|
|
41
|
+
prettyJsonBlock,
|
|
42
|
+
} from "../format.js";
|
|
43
|
+
import { renderMarkdown, renderInspectorDocument } from "../markdown-render.js";
|
|
44
|
+
import { describeDagNodePurpose } from "../dag-node-purpose.js";
|
|
45
|
+
import { buildPromptRestartCandidateOptions } from "../prompt-restart-candidates.js";
|
|
46
|
+
import { copyText } from "../copy.js";
|
|
47
|
+
import { navigate } from "../router.js";
|
|
48
|
+
import {
|
|
49
|
+
fetchWithWorkspaceScope,
|
|
18
50
|
uiState,
|
|
19
51
|
makeSessionEventIdentity,
|
|
20
52
|
makeDagNodeInputIdentity,
|
|
21
53
|
makeDagNodeExecutionOutputIdentity,
|
|
54
|
+
makeDagNodeProcessIdentity,
|
|
22
55
|
getDagNodeExecutionOutputCache,
|
|
23
56
|
setDagNodeExecutionOutputCache,
|
|
24
57
|
clearDagNodeExecutionOutputCache,
|
|
@@ -35,6 +68,8 @@ import {
|
|
|
35
68
|
import {
|
|
36
69
|
formatSessionEventTime,
|
|
37
70
|
renderSessionTimeline,
|
|
71
|
+
buildPageStyledDoc,
|
|
72
|
+
fetchPageStylesheetText,
|
|
38
73
|
} from "./session-timeline.js";
|
|
39
74
|
import { createCustomSelect } from "../custom-select.js";
|
|
40
75
|
|
|
@@ -42,7 +77,403 @@ import { createCustomSelect } from "../custom-select.js";
|
|
|
42
77
|
// reused inspector shell never keeps stale node closures: every render writes
|
|
43
78
|
// the latest {dagRunId, node} here and tab clicks re-render from the same
|
|
44
79
|
// reference, always resolving the currently selected node identity.
|
|
45
|
-
const inspectorSelection = { dagRunId: null, node: null };
|
|
80
|
+
const inspectorSelection = { dagRunId: null, node: null, run: null };
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 失败状态行统一入口:错误信息中嵌入的已知 reason code 先给中文语义
|
|
84
|
+
* (原码与原始信息保留),未知内容原样展示,不做成功方向的猜测。
|
|
85
|
+
*/
|
|
86
|
+
function transferErrorStatusText(error, fallback) {
|
|
87
|
+
const raw = error instanceof Error ? error.message : String(error ?? "");
|
|
88
|
+
return describeTransferError(raw) ?? (raw || fallback);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const DAG_INSPECTOR_READ_ONLY_TABS = Object.freeze([
|
|
92
|
+
["overview", "节点概览", "ri-dashboard-line"],
|
|
93
|
+
["input", "执行设置", "ri-login-box-line"],
|
|
94
|
+
["context", "实际上下文", "ri-stack-line"],
|
|
95
|
+
["timeline", "执行记录", "ri-route-line"],
|
|
96
|
+
["spec-evidence", "规范证据", "ri-book-open-line"],
|
|
97
|
+
["output", "产出", "ri-file-text-line"],
|
|
98
|
+
["lineage", "来源与影响", "ri-git-branch-line"],
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
export const DAG_INSPECTOR_MUTATION_TAB = Object.freeze([
|
|
102
|
+
"prompt-restart",
|
|
103
|
+
"导出与重跑",
|
|
104
|
+
"ri-share-forward-line",
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
export const DAG_ACTION_SECTION_ORDER = Object.freeze([
|
|
108
|
+
"artifact-revision",
|
|
109
|
+
"prompt-restart",
|
|
110
|
+
"context-export",
|
|
111
|
+
]);
|
|
112
|
+
|
|
113
|
+
export const ARTIFACT_FILE_PREVIEW_SURFACES = Object.freeze({
|
|
114
|
+
produced: "produced-artifact-preview",
|
|
115
|
+
consumed: "consumed-artifact-preview",
|
|
116
|
+
revisionSelection: "artifact-revision-current-preview",
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const INSPECTOR_PAGE_GUIDANCE = Object.freeze({
|
|
120
|
+
overview: {
|
|
121
|
+
eyebrow: "先看结论",
|
|
122
|
+
title: "这个节点做了什么",
|
|
123
|
+
body: "先看当前状态、执行方式和结果来源;需要追细节时,再进入后面的页面。",
|
|
124
|
+
},
|
|
125
|
+
input: {
|
|
126
|
+
eyebrow: "运行前",
|
|
127
|
+
title: "系统原本准备怎么做",
|
|
128
|
+
body: "这里是开始执行前保存的任务说明、依赖关系和读写范围,不代表这些内容后来一定被实际使用。",
|
|
129
|
+
},
|
|
130
|
+
context: {
|
|
131
|
+
eyebrow: "执行时",
|
|
132
|
+
title: "AI 实际拿到了哪些资料",
|
|
133
|
+
body: "这一页只展示系统在下发任务时真正记录到的内容;没有记录时会明确说明,不会用运行前设置代替。",
|
|
134
|
+
},
|
|
135
|
+
timeline: {
|
|
136
|
+
eyebrow: "执行过程",
|
|
137
|
+
title: "这一步实际发生了什么",
|
|
138
|
+
body: "按顺序查看 AI 的回复、工具调用或命令结果;失败时优先看标红步骤和错误输出。",
|
|
139
|
+
},
|
|
140
|
+
"spec-evidence": {
|
|
141
|
+
eyebrow: "需求依据",
|
|
142
|
+
title: "它有没有真的读过需求",
|
|
143
|
+
body: "只有成功读取文件或查询知识库的记录才算证据;模型自己提到文件名不算。",
|
|
144
|
+
},
|
|
145
|
+
output: {
|
|
146
|
+
eyebrow: "执行结果",
|
|
147
|
+
title: "它产出了什么,谁会用",
|
|
148
|
+
body: "先确认文件是否真实生成、能否替换以及后续谁会使用,再查看具体输出内容。",
|
|
149
|
+
},
|
|
150
|
+
lineage: {
|
|
151
|
+
eyebrow: "来源与影响",
|
|
152
|
+
title: "这一步从哪里来,会影响哪里",
|
|
153
|
+
body: "用于判断结果是本次生成还是沿用旧运行,以及替换或重跑会从哪个位置继续。",
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
function buildInspectorPageLead(tab) {
|
|
158
|
+
const copy = INSPECTOR_PAGE_GUIDANCE[tab];
|
|
159
|
+
if (!copy) return null;
|
|
160
|
+
const lead = el("section", "inspector-page-lead");
|
|
161
|
+
lead.dataset.page = tab;
|
|
162
|
+
lead.append(
|
|
163
|
+
el("span", "inspector-page-eyebrow", copy.eyebrow),
|
|
164
|
+
el("h4", null, copy.title),
|
|
165
|
+
el("p", null, copy.body),
|
|
166
|
+
);
|
|
167
|
+
return lead;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function ensureInspectorPageLead(content, tab) {
|
|
171
|
+
const existing = content.querySelector(
|
|
172
|
+
`.inspector-page-lead[data-page="${tab}"]`,
|
|
173
|
+
);
|
|
174
|
+
if (existing) return existing;
|
|
175
|
+
const lead = buildInspectorPageLead(tab);
|
|
176
|
+
if (lead) content.insertBefore(lead, content.firstChild);
|
|
177
|
+
return lead;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export const CONTEXT_EXPORT_TARGETS = Object.freeze([
|
|
181
|
+
{
|
|
182
|
+
value: "generic",
|
|
183
|
+
label: "通用 AI 交接包",
|
|
184
|
+
description: "适合交给其他 AI 工具继续处理",
|
|
185
|
+
icon: "ri-robot-2-line",
|
|
186
|
+
contents: "执行时记录 · 文件清单 · 交接说明",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
value: "pi-session",
|
|
190
|
+
label: "可在 Pi 中恢复的会话",
|
|
191
|
+
description: "如果记录兼容,会附带可直接恢复的会话文件",
|
|
192
|
+
icon: "ri-terminal-box-line",
|
|
193
|
+
contents: "执行时记录 · 文件清单 · 可恢复的 Pi 会话(兼容时)",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
value: "readable",
|
|
197
|
+
label: "可读执行记录",
|
|
198
|
+
description: "便于人工审阅,不承诺完整重现执行",
|
|
199
|
+
icon: "ri-file-list-3-line",
|
|
200
|
+
contents: "执行时记录 · 文件清单 · 可读对话记录",
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
value: "pi-handoff",
|
|
204
|
+
label: "Pi 专用交接包",
|
|
205
|
+
description: "用于把资料交给 Pi 的继续处理流程",
|
|
206
|
+
icon: "ri-share-forward-box-line",
|
|
207
|
+
contents: "执行时记录 · 文件清单 · Pi 交接说明",
|
|
208
|
+
},
|
|
209
|
+
]);
|
|
210
|
+
|
|
211
|
+
export const CONTEXT_EXPORT_PROFILES = Object.freeze([
|
|
212
|
+
{
|
|
213
|
+
value: "redacted",
|
|
214
|
+
label: "脱敏后导出",
|
|
215
|
+
description: "自动隐藏匹配到的疑似凭据",
|
|
216
|
+
badge: "推荐",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
value: "raw",
|
|
220
|
+
label: "保留原始内容",
|
|
221
|
+
description: "可能包含凭据、绝对路径和未脱敏文本",
|
|
222
|
+
badge: "高风险",
|
|
223
|
+
},
|
|
224
|
+
]);
|
|
225
|
+
|
|
226
|
+
function createPromptRestartCopyButton(readCandidate) {
|
|
227
|
+
const buildIcon = (kind) => {
|
|
228
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
229
|
+
svg.setAttribute(
|
|
230
|
+
"class",
|
|
231
|
+
`dags-copy-icon dags-copy-icon-${kind === "check" ? "check" : "rects"}`,
|
|
232
|
+
);
|
|
233
|
+
svg.setAttribute("viewBox", "0 0 16 16");
|
|
234
|
+
svg.setAttribute("width", "16");
|
|
235
|
+
svg.setAttribute("height", "16");
|
|
236
|
+
svg.setAttribute("aria-hidden", "true");
|
|
237
|
+
svg.setAttribute("focusable", "false");
|
|
238
|
+
if (kind === "check") {
|
|
239
|
+
const check = document.createElementNS(
|
|
240
|
+
"http://www.w3.org/2000/svg",
|
|
241
|
+
"path",
|
|
242
|
+
);
|
|
243
|
+
check.setAttribute("d", "M3.5 8.5 6.5 11.5 12.5 4.5");
|
|
244
|
+
check.setAttribute("fill", "none");
|
|
245
|
+
check.setAttribute("stroke", "currentColor");
|
|
246
|
+
check.setAttribute("stroke-width", "1.8");
|
|
247
|
+
check.setAttribute("stroke-linecap", "round");
|
|
248
|
+
check.setAttribute("stroke-linejoin", "round");
|
|
249
|
+
svg.appendChild(check);
|
|
250
|
+
return svg;
|
|
251
|
+
}
|
|
252
|
+
for (const [x, y] of [
|
|
253
|
+
[2, 2],
|
|
254
|
+
[5, 5],
|
|
255
|
+
]) {
|
|
256
|
+
const rect = document.createElementNS(
|
|
257
|
+
"http://www.w3.org/2000/svg",
|
|
258
|
+
"rect",
|
|
259
|
+
);
|
|
260
|
+
rect.setAttribute("x", String(x));
|
|
261
|
+
rect.setAttribute("y", String(y));
|
|
262
|
+
rect.setAttribute("width", "9");
|
|
263
|
+
rect.setAttribute("height", "9");
|
|
264
|
+
rect.setAttribute("rx", "1.5");
|
|
265
|
+
rect.setAttribute("fill", "none");
|
|
266
|
+
rect.setAttribute("stroke", "currentColor");
|
|
267
|
+
rect.setAttribute("stroke-width", "1.5");
|
|
268
|
+
svg.appendChild(rect);
|
|
269
|
+
}
|
|
270
|
+
return svg;
|
|
271
|
+
};
|
|
272
|
+
const button = el(
|
|
273
|
+
"button",
|
|
274
|
+
"dags-copy-btn prompt-restart-copy-button",
|
|
275
|
+
);
|
|
276
|
+
button.type = "button";
|
|
277
|
+
button.setAttribute("data-testid", "prompt-restart-copy");
|
|
278
|
+
button.setAttribute("aria-label", "复制当前提示词候选");
|
|
279
|
+
button.setAttribute("title", "复制当前提示词候选");
|
|
280
|
+
button.appendChild(buildIcon("copy"));
|
|
281
|
+
button.appendChild(buildIcon("check"));
|
|
282
|
+
const label = el("span", "prompt-restart-copy-label", "复制提示词");
|
|
283
|
+
button.appendChild(label);
|
|
284
|
+
button.addEventListener("click", (event) => {
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
event.stopPropagation();
|
|
287
|
+
const candidate = readCandidate();
|
|
288
|
+
void copyText(candidate?.prompt ?? "").then((ok) => {
|
|
289
|
+
const feedback = ok
|
|
290
|
+
? candidate?.truncated
|
|
291
|
+
? "已复制截断预览"
|
|
292
|
+
: "已复制"
|
|
293
|
+
: "复制失败";
|
|
294
|
+
button.classList.toggle("is-copied", ok);
|
|
295
|
+
button.setAttribute("aria-label", feedback);
|
|
296
|
+
button.setAttribute("title", feedback);
|
|
297
|
+
label.textContent = feedback;
|
|
298
|
+
setTimeout(() => {
|
|
299
|
+
button.classList.remove("is-copied");
|
|
300
|
+
button.setAttribute("aria-label", "复制当前提示词候选");
|
|
301
|
+
button.setAttribute("title", "复制当前提示词候选");
|
|
302
|
+
label.textContent = "复制提示词";
|
|
303
|
+
}, 1500);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
return button;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function formatPromptRestartMeta(text) {
|
|
310
|
+
const value = String(text ?? "");
|
|
311
|
+
const chars = [...value].length;
|
|
312
|
+
const lines = value.length === 0 ? 0 : value.split("\n").length;
|
|
313
|
+
return `${lines} 行 · ${chars.toLocaleString("zh-CN")} 字`;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function createPromptRestartBanner({ tone, kicker, title, body }) {
|
|
317
|
+
const banner = el("div", `prompt-restart-banner is-${tone}`);
|
|
318
|
+
banner.setAttribute("role", "status");
|
|
319
|
+
banner.appendChild(el("span", "prompt-restart-banner-kicker", kicker));
|
|
320
|
+
banner.appendChild(el("p", "prompt-restart-banner-title", title));
|
|
321
|
+
banner.appendChild(el("p", "prompt-restart-banner-body", body));
|
|
322
|
+
return banner;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function createPromptRestartCandidatePicker({
|
|
326
|
+
options,
|
|
327
|
+
value,
|
|
328
|
+
onChange,
|
|
329
|
+
label,
|
|
330
|
+
hint,
|
|
331
|
+
}) {
|
|
332
|
+
const field = el("div", "prompt-restart-field");
|
|
333
|
+
field.appendChild(el("span", "prompt-restart-label", label));
|
|
334
|
+
const select = createCustomSelect({
|
|
335
|
+
ariaLabel: label,
|
|
336
|
+
className: "prompt-restart-candidate-select",
|
|
337
|
+
value,
|
|
338
|
+
disabled: options.length < 2,
|
|
339
|
+
options: options.map((option) => ({
|
|
340
|
+
value: option.key,
|
|
341
|
+
label: option.label,
|
|
342
|
+
})),
|
|
343
|
+
onChange: (nextKey) => {
|
|
344
|
+
onChange(String(nextKey));
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
select.setAttribute("data-testid", "prompt-restart-candidate");
|
|
348
|
+
field.appendChild(select);
|
|
349
|
+
const hintEl = el("p", "prompt-restart-hint", hint ?? "");
|
|
350
|
+
if (!hint) hintEl.hidden = true;
|
|
351
|
+
field.appendChild(hintEl);
|
|
352
|
+
return { field, select, hintEl };
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function createPromptRestartModeSwitch({ value = "append", onChange }) {
|
|
356
|
+
const field = el("div", "prompt-restart-field prompt-restart-mode-field");
|
|
357
|
+
field.appendChild(el("span", "prompt-restart-label", "编辑模式"));
|
|
358
|
+
const group = el("div", "prompt-restart-mode-switch");
|
|
359
|
+
group.setAttribute("role", "radiogroup");
|
|
360
|
+
group.setAttribute("aria-label", "编辑模式");
|
|
361
|
+
group.setAttribute("data-testid", "prompt-restart-mode");
|
|
362
|
+
let current = value === "replace" ? "replace" : "append";
|
|
363
|
+
const buttons = [];
|
|
364
|
+
const sync = () => {
|
|
365
|
+
for (const btn of buttons) {
|
|
366
|
+
const selected = btn.dataset.mode === current;
|
|
367
|
+
btn.setAttribute("aria-checked", selected ? "true" : "false");
|
|
368
|
+
btn.classList.toggle("is-selected", selected);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
for (const mode of [
|
|
372
|
+
{ value: "append", label: "追加指令" },
|
|
373
|
+
{ value: "replace", label: "全文替换" },
|
|
374
|
+
]) {
|
|
375
|
+
const btn = document.createElement("button");
|
|
376
|
+
btn.type = "button";
|
|
377
|
+
btn.className = "prompt-restart-mode-option";
|
|
378
|
+
btn.dataset.mode = mode.value;
|
|
379
|
+
btn.setAttribute("role", "radio");
|
|
380
|
+
btn.setAttribute("aria-label", mode.label);
|
|
381
|
+
btn.textContent = mode.label;
|
|
382
|
+
btn.addEventListener("click", () => {
|
|
383
|
+
if (current === mode.value) return;
|
|
384
|
+
current = mode.value;
|
|
385
|
+
sync();
|
|
386
|
+
onChange?.(current);
|
|
387
|
+
});
|
|
388
|
+
buttons.push(btn);
|
|
389
|
+
group.appendChild(btn);
|
|
390
|
+
}
|
|
391
|
+
Object.defineProperty(group, "value", {
|
|
392
|
+
configurable: true,
|
|
393
|
+
enumerable: true,
|
|
394
|
+
get() {
|
|
395
|
+
return current;
|
|
396
|
+
},
|
|
397
|
+
set(next) {
|
|
398
|
+
current = next === "replace" ? "replace" : "append";
|
|
399
|
+
sync();
|
|
400
|
+
},
|
|
401
|
+
});
|
|
402
|
+
sync();
|
|
403
|
+
field.appendChild(group);
|
|
404
|
+
const hint = el(
|
|
405
|
+
"p",
|
|
406
|
+
"prompt-restart-hint",
|
|
407
|
+
"追加会保留原提示词;全文替换会改写整份底稿。",
|
|
408
|
+
);
|
|
409
|
+
field.appendChild(hint);
|
|
410
|
+
return { field, group, hint };
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function createPromptRestartPromptCard({
|
|
414
|
+
title,
|
|
415
|
+
badge,
|
|
416
|
+
readCandidate,
|
|
417
|
+
preTestId,
|
|
418
|
+
collapsible = false,
|
|
419
|
+
startCollapsed = false,
|
|
420
|
+
}) {
|
|
421
|
+
const card = el("div", "prompt-restart-prompt-card");
|
|
422
|
+
const head = el("div", "prompt-restart-prompt-head");
|
|
423
|
+
const titles = el("div", "prompt-restart-prompt-titles");
|
|
424
|
+
const titleEl = el("span", "prompt-restart-prompt-title", title);
|
|
425
|
+
titles.appendChild(titleEl);
|
|
426
|
+
if (badge) {
|
|
427
|
+
titles.appendChild(el("span", "prompt-restart-prompt-badge", badge));
|
|
428
|
+
}
|
|
429
|
+
const metaEl = el("span", "prompt-restart-prompt-meta", "");
|
|
430
|
+
titles.appendChild(metaEl);
|
|
431
|
+
head.appendChild(titles);
|
|
432
|
+
const headActions = el("div", "prompt-restart-prompt-actions");
|
|
433
|
+
let fold = null;
|
|
434
|
+
let collapsed = Boolean(collapsible && startCollapsed);
|
|
435
|
+
const syncFold = () => {
|
|
436
|
+
if (!fold) return;
|
|
437
|
+
card.classList.toggle("is-collapsed", collapsed);
|
|
438
|
+
fold.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
439
|
+
fold.textContent = collapsed ? "展开" : "收起";
|
|
440
|
+
};
|
|
441
|
+
if (collapsible) {
|
|
442
|
+
card.classList.add("is-collapsible");
|
|
443
|
+
fold = document.createElement("button");
|
|
444
|
+
fold.type = "button";
|
|
445
|
+
fold.className = "prompt-restart-prompt-fold";
|
|
446
|
+
fold.setAttribute("aria-controls", preTestId);
|
|
447
|
+
fold.addEventListener("click", (event) => {
|
|
448
|
+
event.preventDefault();
|
|
449
|
+
event.stopPropagation();
|
|
450
|
+
collapsed = !collapsed;
|
|
451
|
+
syncFold();
|
|
452
|
+
});
|
|
453
|
+
headActions.appendChild(fold);
|
|
454
|
+
}
|
|
455
|
+
headActions.appendChild(createPromptRestartCopyButton(readCandidate));
|
|
456
|
+
head.appendChild(headActions);
|
|
457
|
+
card.appendChild(head);
|
|
458
|
+
const pre = document.createElement("pre");
|
|
459
|
+
pre.className = "prompt-restart-readonly";
|
|
460
|
+
pre.setAttribute("data-testid", preTestId);
|
|
461
|
+
if (preTestId) pre.id = preTestId;
|
|
462
|
+
card.appendChild(pre);
|
|
463
|
+
const sync = (candidate) => {
|
|
464
|
+
const next = candidate ?? readCandidate?.();
|
|
465
|
+
titleEl.textContent =
|
|
466
|
+
next?.key === "frozen"
|
|
467
|
+
? "运行开始时的提示词"
|
|
468
|
+
: (next?.label ?? title);
|
|
469
|
+
pre.textContent = next?.prompt ?? "";
|
|
470
|
+
metaEl.textContent = formatPromptRestartMeta(next?.prompt ?? "");
|
|
471
|
+
if (next?.truncated) metaEl.textContent += " · 已截断";
|
|
472
|
+
};
|
|
473
|
+
sync(readCandidate?.());
|
|
474
|
+
syncFold();
|
|
475
|
+
return { card, pre, titleEl, metaEl, sync };
|
|
476
|
+
}
|
|
46
477
|
|
|
47
478
|
function renderDagInspectorForCurrent() {
|
|
48
479
|
if (!inspectorSelection.dagRunId || !inspectorSelection.node) return;
|
|
@@ -50,12 +481,17 @@ function renderDagInspectorForCurrent() {
|
|
|
50
481
|
inspectorSelection.dagRunId,
|
|
51
482
|
inspectorSelection.node,
|
|
52
483
|
false,
|
|
484
|
+
inspectorSelection.run,
|
|
53
485
|
);
|
|
54
486
|
}
|
|
55
487
|
|
|
56
488
|
function resetInspectorNodeSelection(dagRunId, nodeId) {
|
|
57
489
|
uiState.selectedDagNodeId = nodeId;
|
|
58
490
|
uiState.dagInspectorOpen = true;
|
|
491
|
+
// Each node opens in live-follow mode by default. The explicit floating
|
|
492
|
+
// control can pause it without losing the reader's current position.
|
|
493
|
+
uiState.dagTimelineAutoScrollEnabled = true;
|
|
494
|
+
uiState.dagTimelineViewportState = null;
|
|
59
495
|
// Reset the per-attempt selection so an old node's attempt cannot leak
|
|
60
496
|
// into the newly selected node (always defaults back to the latest).
|
|
61
497
|
uiState.dagInspectorAttempt = null;
|
|
@@ -68,6 +504,10 @@ function resetInspectorNodeSelection(dagRunId, nodeId) {
|
|
|
68
504
|
uiState.dagNodeInputData = null;
|
|
69
505
|
uiState.dagNodeInputError = null;
|
|
70
506
|
uiState.dagNodeInputLoading = false;
|
|
507
|
+
uiState.dagNodeProcessData = null;
|
|
508
|
+
uiState.dagNodeProcessError = null;
|
|
509
|
+
uiState.dagNodeProcessLoading = false;
|
|
510
|
+
uiState.dagNodeProcessIdentity = null;
|
|
71
511
|
// Drop execution-output cache/identity so node A's bodies never leak into B.
|
|
72
512
|
clearDagNodeExecutionOutputCache();
|
|
73
513
|
// Bump the session-event identity token so any in-flight response for the
|
|
@@ -225,18 +665,13 @@ export function createDagInspectorResizeHandle(panel) {
|
|
|
225
665
|
export function captureDagTimelineViewportState(panel) {
|
|
226
666
|
const scrollEl = panel.querySelector(".process-timeline-scroll");
|
|
227
667
|
if (scrollEl?.dataset.dagRunId && scrollEl.dataset.nodeId) {
|
|
228
|
-
const followLatest = computeFollowLatest(
|
|
229
|
-
scrollEl.scrollTop,
|
|
230
|
-
scrollEl.scrollHeight,
|
|
231
|
-
scrollEl.clientHeight,
|
|
232
|
-
);
|
|
233
668
|
uiState.dagTimelineViewportState = updateDagTimelineViewportState(
|
|
234
669
|
uiState.dagTimelineViewportState,
|
|
235
670
|
scrollEl.dataset.dagRunId,
|
|
236
671
|
scrollEl.dataset.nodeId,
|
|
237
672
|
scrollEl.scrollLeft,
|
|
238
673
|
scrollEl.scrollTop,
|
|
239
|
-
|
|
674
|
+
uiState.dagTimelineAutoScrollEnabled !== false,
|
|
240
675
|
);
|
|
241
676
|
}
|
|
242
677
|
}
|
|
@@ -260,6 +695,7 @@ async function renderSpecEvidence(content, dagRunId, nodeId, cachedEvidence) {
|
|
|
260
695
|
restoreInspectorContentScroll(content, dagRunId, nodeId, "spec-evidence");
|
|
261
696
|
return;
|
|
262
697
|
}
|
|
698
|
+
ensureInspectorPageLead(content, "spec-evidence");
|
|
263
699
|
if (!evidence) {
|
|
264
700
|
content.appendChild(el("p", "empty", "无法加载规范证据。"));
|
|
265
701
|
restoreInspectorContentScroll(content, dagRunId, nodeId, "spec-evidence");
|
|
@@ -270,8 +706,8 @@ async function renderSpecEvidence(content, dagRunId, nodeId, cachedEvidence) {
|
|
|
270
706
|
const statusLabels = {
|
|
271
707
|
"spec-read": "已读取规范",
|
|
272
708
|
"source-bound": "已绑定任务源",
|
|
273
|
-
"spec-injected": "
|
|
274
|
-
"search-only": "
|
|
709
|
+
"spec-injected": "已提供阅读能力,但没有读取记录",
|
|
710
|
+
"search-only": "只搜索过,没有读取内容",
|
|
275
711
|
"kb-queried": "已观察知识库查询",
|
|
276
712
|
"no-evidence": "未观察到读取",
|
|
277
713
|
};
|
|
@@ -312,7 +748,7 @@ async function renderSpecEvidence(content, dagRunId, nodeId, cachedEvidence) {
|
|
|
312
748
|
};
|
|
313
749
|
|
|
314
750
|
appendListSection(
|
|
315
|
-
"
|
|
751
|
+
"提供给节点的技能",
|
|
316
752
|
evidence.skillInjection?.skills,
|
|
317
753
|
(skill) => {
|
|
318
754
|
const item = el("li", null);
|
|
@@ -337,9 +773,9 @@ async function renderSpecEvidence(content, dagRunId, nodeId, cachedEvidence) {
|
|
|
337
773
|
icon.setAttribute("aria-hidden", "true");
|
|
338
774
|
button.append(
|
|
339
775
|
icon,
|
|
340
|
-
document.createTextNode(` ${source.kind}: `),
|
|
776
|
+
document.createTextNode(` ${inspectorListValueLabel(source.kind)}: `),
|
|
341
777
|
el("code", null, source.path),
|
|
342
|
-
document.createTextNode(` ·
|
|
778
|
+
document.createTextNode(` · 内容校验码 ${source.sha256.slice(0, 12)}…`),
|
|
343
779
|
);
|
|
344
780
|
button.addEventListener("click", () =>
|
|
345
781
|
onSpecEvidenceFileClick(
|
|
@@ -399,7 +835,7 @@ async function renderSpecEvidence(content, dagRunId, nodeId, cachedEvidence) {
|
|
|
399
835
|
item.appendChild(button);
|
|
400
836
|
return item;
|
|
401
837
|
},
|
|
402
|
-
"
|
|
838
|
+
"没有记录到节点读取规范文件。",
|
|
403
839
|
);
|
|
404
840
|
appendListSection(
|
|
405
841
|
`规范检索(${evidence.specSearches?.length ?? 0})`,
|
|
@@ -414,7 +850,7 @@ async function renderSpecEvidence(content, dagRunId, nodeId, cachedEvidence) {
|
|
|
414
850
|
);
|
|
415
851
|
return item;
|
|
416
852
|
},
|
|
417
|
-
"
|
|
853
|
+
"没有记录到节点检索规范。",
|
|
418
854
|
);
|
|
419
855
|
appendListSection(
|
|
420
856
|
`知识库查询(${evidence.knowledgeBaseQueries?.length ?? 0})`,
|
|
@@ -426,7 +862,7 @@ async function renderSpecEvidence(content, dagRunId, nodeId, cachedEvidence) {
|
|
|
426
862
|
item.append(icon, document.createTextNode(` ${query.connector}`));
|
|
427
863
|
return item;
|
|
428
864
|
},
|
|
429
|
-
"
|
|
865
|
+
"没有记录到知识库查询;可能未配置知识库连接,或节点没有使用它。",
|
|
430
866
|
);
|
|
431
867
|
|
|
432
868
|
if (
|
|
@@ -441,10 +877,10 @@ async function renderSpecEvidence(content, dagRunId, nodeId, cachedEvidence) {
|
|
|
441
877
|
icon,
|
|
442
878
|
document.createTextNode(
|
|
443
879
|
evidence.status === "source-bound"
|
|
444
|
-
? "
|
|
880
|
+
? "系统已确认任务来源和文件版本,但没有记录到节点成功读取完整文件。仅绑定文件不能证明节点真的读过内容。"
|
|
445
881
|
: evidence.status === "no-evidence"
|
|
446
|
-
? "
|
|
447
|
-
: "
|
|
882
|
+
? "没有记录到节点读取规范。模型总结里提到文件名,不等于节点真正读取了文件。"
|
|
883
|
+
: "已把规范阅读能力提供给节点,但没有记录到它读取规范或查询知识库;只搜索到文件名不等于读过文件内容。",
|
|
448
884
|
),
|
|
449
885
|
);
|
|
450
886
|
content.appendChild(warning);
|
|
@@ -555,7 +991,7 @@ function renderSpecEvidenceDetail(content, dagRunId, nodeId) {
|
|
|
555
991
|
el(
|
|
556
992
|
"span",
|
|
557
993
|
"spec-evidence-detail-hash",
|
|
558
|
-
|
|
994
|
+
`登记的内容校验码 ${String(detail.data.sha256 ?? "").slice(0, 12)}… · 当前文件${detail.data.hashMatch ? "一致" : "不一致"}`,
|
|
559
995
|
),
|
|
560
996
|
);
|
|
561
997
|
} else if (detail.source === "read" && detail.data?.readAt) {
|
|
@@ -601,15 +1037,29 @@ function renderSpecEvidenceDetail(content, dagRunId, nodeId) {
|
|
|
601
1037
|
|
|
602
1038
|
function sourceLabel(source) {
|
|
603
1039
|
if (source === "defaults") return "继承默认值";
|
|
604
|
-
if (source === "schema-default") return "
|
|
605
|
-
if (source === "merged") return "
|
|
1040
|
+
if (source === "schema-default") return "系统默认值";
|
|
1041
|
+
if (source === "merged") return "合并后的值";
|
|
606
1042
|
return null;
|
|
607
1043
|
}
|
|
608
1044
|
|
|
609
1045
|
function appendMetaRow(dl, label, value, source) {
|
|
610
1046
|
if (value == null || value === "") return;
|
|
611
|
-
const
|
|
612
|
-
const
|
|
1047
|
+
const copy = describeInspectorMeta(label, value);
|
|
1048
|
+
const dt = el("dt", null, copy.label);
|
|
1049
|
+
const dd = el("dd", null, copy.value);
|
|
1050
|
+
const labelHelp = [
|
|
1051
|
+
copy.help ? `含义:${copy.help}` : null,
|
|
1052
|
+
copy.rawLabel ? `技术字段:${copy.rawLabel}` : null,
|
|
1053
|
+
].filter(Boolean);
|
|
1054
|
+
if (labelHelp.length > 0) {
|
|
1055
|
+
const tooltipText = labelHelp.join("\n");
|
|
1056
|
+
const help = el("span", "node-input-summary-help", "?");
|
|
1057
|
+
help.tabIndex = 0;
|
|
1058
|
+
help.setAttribute("data-tooltip", tooltipText);
|
|
1059
|
+
help.setAttribute("aria-label", tooltipText);
|
|
1060
|
+
dt.appendChild(help);
|
|
1061
|
+
}
|
|
1062
|
+
if (copy.rawValue) dd.setAttribute("title", `原始值:${copy.rawValue}`);
|
|
613
1063
|
const inherited = sourceLabel(source);
|
|
614
1064
|
if (inherited) {
|
|
615
1065
|
dd.appendChild(document.createTextNode(" "));
|
|
@@ -622,12 +1072,20 @@ function appendMetaRow(dl, label, value, source) {
|
|
|
622
1072
|
function appendCodeList(parent, title, values) {
|
|
623
1073
|
if (!values || values.length === 0) return;
|
|
624
1074
|
const section = el("section", "node-input-section");
|
|
625
|
-
|
|
1075
|
+
const heading = el("h4", null, inspectorFieldLabel(title));
|
|
1076
|
+
if (inspectorFieldLabel(title) !== title) {
|
|
1077
|
+
heading.setAttribute("title", `技术字段:${title}`);
|
|
1078
|
+
}
|
|
1079
|
+
section.appendChild(heading);
|
|
626
1080
|
const list = el("ul", "node-input-code-list");
|
|
627
1081
|
for (const value of values) {
|
|
628
1082
|
const item = document.createElement("li");
|
|
629
1083
|
const code = document.createElement("code");
|
|
630
|
-
|
|
1084
|
+
const rawValue = String(value);
|
|
1085
|
+
code.textContent = inspectorListValueLabel(rawValue);
|
|
1086
|
+
if (code.textContent !== rawValue) {
|
|
1087
|
+
code.setAttribute("title", `原始值:${rawValue}`);
|
|
1088
|
+
}
|
|
631
1089
|
item.appendChild(code);
|
|
632
1090
|
list.appendChild(item);
|
|
633
1091
|
}
|
|
@@ -695,9 +1153,9 @@ function renderDagNodeInputDetail(content, data) {
|
|
|
695
1153
|
section.appendChild(el("h4", null, "任务正文"));
|
|
696
1154
|
if (data.prompt.source?.path) {
|
|
697
1155
|
const meta = el("p", "muted");
|
|
698
|
-
meta.textContent =
|
|
1156
|
+
meta.textContent = `任务说明来源:${data.prompt.source.path}${
|
|
699
1157
|
data.prompt.source.sha256Prefix
|
|
700
|
-
?
|
|
1158
|
+
? `(内容校验码 ${data.prompt.source.sha256Prefix}…)`
|
|
701
1159
|
: ""
|
|
702
1160
|
}`;
|
|
703
1161
|
section.appendChild(meta);
|
|
@@ -717,7 +1175,7 @@ function renderDagNodeInputDetail(content, data) {
|
|
|
717
1175
|
|
|
718
1176
|
if (data.executorInput) {
|
|
719
1177
|
const section = el("section", "node-input-section");
|
|
720
|
-
section.appendChild(el("h4", null, "
|
|
1178
|
+
section.appendChild(el("h4", null, "将如何执行"));
|
|
721
1179
|
const dl = el("dl", "node-input-summary");
|
|
722
1180
|
appendMetaRow(dl, "kind", data.executorInput.kind, null);
|
|
723
1181
|
if (data.executorInput.modelHint) {
|
|
@@ -725,6 +1183,11 @@ function renderDagNodeInputDetail(content, data) {
|
|
|
725
1183
|
}
|
|
726
1184
|
section.appendChild(dl);
|
|
727
1185
|
appendCodeList(section, "skills", data.executorInput.skills);
|
|
1186
|
+
appendCodeList(
|
|
1187
|
+
section,
|
|
1188
|
+
"piExtensions(声明)",
|
|
1189
|
+
data.executorInput.piExtensions,
|
|
1190
|
+
);
|
|
728
1191
|
if (data.executorInput.shell) {
|
|
729
1192
|
const shell = data.executorInput.shell;
|
|
730
1193
|
const shellDl = el("dl", "node-input-summary");
|
|
@@ -743,6 +1206,12 @@ function renderDagNodeInputDetail(content, data) {
|
|
|
743
1206
|
(shell.gates ?? []).join(", ") || "(none)",
|
|
744
1207
|
null,
|
|
745
1208
|
);
|
|
1209
|
+
appendMetaRow(
|
|
1210
|
+
shellDl,
|
|
1211
|
+
"handlers",
|
|
1212
|
+
(shell.handlers ?? []).join(", ") || "(none)",
|
|
1213
|
+
null,
|
|
1214
|
+
);
|
|
746
1215
|
section.appendChild(shellDl);
|
|
747
1216
|
if ((shell.commands ?? []).length > 0) {
|
|
748
1217
|
const list = el("ol", "node-input-command-list");
|
|
@@ -779,7 +1248,7 @@ function renderDagNodeInputDetail(content, data) {
|
|
|
779
1248
|
|
|
780
1249
|
if (data.boundaries) {
|
|
781
1250
|
const section = el("section", "node-input-section");
|
|
782
|
-
section.appendChild(el("h4", null, "
|
|
1251
|
+
section.appendChild(el("h4", null, "读写范围与输出要求"));
|
|
783
1252
|
const dl = el("dl", "node-input-summary");
|
|
784
1253
|
appendMetaRow(dl, "outputMode", data.boundaries.outputMode, null);
|
|
785
1254
|
appendMetaRow(
|
|
@@ -790,7 +1259,7 @@ function renderDagNodeInputDetail(content, data) {
|
|
|
790
1259
|
);
|
|
791
1260
|
section.appendChild(dl);
|
|
792
1261
|
if (data.boundaries.outputContract) {
|
|
793
|
-
section.appendChild(el("h5", null, "
|
|
1262
|
+
section.appendChild(el("h5", null, "输出内容要求"));
|
|
794
1263
|
section.appendChild(renderMarkdown(data.boundaries.outputContract));
|
|
795
1264
|
}
|
|
796
1265
|
appendCodeList(section, "allowedPaths", data.boundaries.allowedPaths);
|
|
@@ -799,9 +1268,51 @@ function renderDagNodeInputDetail(content, data) {
|
|
|
799
1268
|
wrap.appendChild(section);
|
|
800
1269
|
}
|
|
801
1270
|
|
|
1271
|
+
if (data.piExtensionRunFacts) {
|
|
1272
|
+
const facts = data.piExtensionRunFacts;
|
|
1273
|
+
const section = el("section", "node-input-section");
|
|
1274
|
+
section.appendChild(el("h4", null, "AI 扩展加载结果"));
|
|
1275
|
+
if (!facts.exists) {
|
|
1276
|
+
section.appendChild(
|
|
1277
|
+
el(
|
|
1278
|
+
"p",
|
|
1279
|
+
"muted",
|
|
1280
|
+
facts.parseError
|
|
1281
|
+
? `产物 ${facts.artifact} 读取失败(${facts.parseError})。`
|
|
1282
|
+
: `产物 ${facts.artifact} 尚未生成(节点未执行或缺失)。`,
|
|
1283
|
+
),
|
|
1284
|
+
);
|
|
1285
|
+
} else {
|
|
1286
|
+
const dl = el("dl", "node-input-summary");
|
|
1287
|
+
appendMetaRow(
|
|
1288
|
+
dl,
|
|
1289
|
+
"resolved",
|
|
1290
|
+
facts.resolved
|
|
1291
|
+
.map((entry) => `${entry.id} → ${entry.packageName}@${entry.version}`)
|
|
1292
|
+
.join(", ") || "(none)",
|
|
1293
|
+
null,
|
|
1294
|
+
);
|
|
1295
|
+
section.appendChild(dl);
|
|
1296
|
+
appendCodeList(section, "requested", facts.requested);
|
|
1297
|
+
for (const missingEntry of facts.missing ?? []) {
|
|
1298
|
+
section.appendChild(
|
|
1299
|
+
el(
|
|
1300
|
+
"p",
|
|
1301
|
+
"node-input-warning",
|
|
1302
|
+
`降级:${missingEntry.id} 未加载(${missingEntry.reason || "unknown"})`,
|
|
1303
|
+
),
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
if ((facts.missing ?? []).length === 0) {
|
|
1307
|
+
section.appendChild(el("p", "muted", "全部声明扩展均已解析加载。"));
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
wrap.appendChild(section);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
802
1313
|
if (data.promptFingerprint?.exists) {
|
|
803
1314
|
const section = el("section", "node-input-section");
|
|
804
|
-
section.appendChild(el("h4", null, "
|
|
1315
|
+
section.appendChild(el("h4", null, "最终提示内容校验信息"));
|
|
805
1316
|
const dl = el("dl", "node-input-summary");
|
|
806
1317
|
appendMetaRow(
|
|
807
1318
|
dl,
|
|
@@ -853,6 +1364,7 @@ async function renderDagNodeInput(content, dagRunId, node) {
|
|
|
853
1364
|
preserveIntent: true,
|
|
854
1365
|
});
|
|
855
1366
|
clearNode(content);
|
|
1367
|
+
ensureInspectorPageLead(content, "input");
|
|
856
1368
|
const loading = el("p", "muted", UI_TEXT.inputLoading);
|
|
857
1369
|
loading.setAttribute("role", "status");
|
|
858
1370
|
loading.setAttribute("aria-live", "polite");
|
|
@@ -872,6 +1384,7 @@ async function renderDagNodeInput(content, dagRunId, node) {
|
|
|
872
1384
|
}
|
|
873
1385
|
|
|
874
1386
|
clearNode(content);
|
|
1387
|
+
ensureInspectorPageLead(content, "input");
|
|
875
1388
|
const finishInputRender = () => {
|
|
876
1389
|
restoreInspectorContentScroll(content, dagRunId, nodeId, "input");
|
|
877
1390
|
uiState.dagNodeInputLoading = false;
|
|
@@ -914,157 +1427,1736 @@ async function renderDagNodeInput(content, dagRunId, node) {
|
|
|
914
1427
|
|
|
915
1428
|
renderDagNodeInputDetail(content, data);
|
|
916
1429
|
finishInputRender();
|
|
1430
|
+
// Frontend prewrite 门禁 / source fidelity ledger 展示(AC-009):只读安全摘要,
|
|
1431
|
+
// 从 run 产物(frontend-prewrite-result.json)与 /api/tasks/:id/ledger 拉取;
|
|
1432
|
+
// 接口失败进入安全降级,不泄漏敏感内容。
|
|
1433
|
+
if (/prewrite/.test(nodeId)) {
|
|
1434
|
+
void renderFrontendGateLedger(content, dagRunId);
|
|
1435
|
+
}
|
|
917
1436
|
}
|
|
918
1437
|
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
);
|
|
950
|
-
} else if (
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
content.scrollHeight,
|
|
954
|
-
content.clientHeight,
|
|
1438
|
+
/**
|
|
1439
|
+
* Frontend prewrite 门禁 + ledger 摘要行(AC-BLOCK-005):纯函数,测试直接断言。
|
|
1440
|
+
* prewriteResult = {ok:true, body}|{ok:false, status}|null(网络失败);ledgerBody 为
|
|
1441
|
+
* /api/tasks/:id/ledger 响应或 null。绝不把 envelope/预览原文塞入 <pre>(删除
|
|
1442
|
+
* 旧 lines.push(previewText) 路径),缺失/拒绝显示明确 fail-closed 文案。
|
|
1443
|
+
*/
|
|
1444
|
+
export function frontendGateLedgerLines(input) {
|
|
1445
|
+
const { prewriteResult, ledgerBody, taskId } = input;
|
|
1446
|
+
const lines = [];
|
|
1447
|
+
if (prewriteResult?.ok && prewriteResult.body) {
|
|
1448
|
+
const parsed = prewriteResult.body;
|
|
1449
|
+
if (parsed?.classification) {
|
|
1450
|
+
const classifications = {
|
|
1451
|
+
accepted: "通过,可以进入写入阶段",
|
|
1452
|
+
blocked: "未通过,已阻止写入",
|
|
1453
|
+
warning: "有提醒,需要留意",
|
|
1454
|
+
};
|
|
1455
|
+
lines.push(
|
|
1456
|
+
`写入前检查:${classifications[parsed.classification] ?? String(parsed.classification)}`,
|
|
1457
|
+
);
|
|
1458
|
+
if (parsed.failureCode) {
|
|
1459
|
+
lines.push(`问题编号:${String(parsed.failureCode)}`);
|
|
1460
|
+
}
|
|
1461
|
+
if (parsed.failureReason) {
|
|
1462
|
+
lines.push(`原因:${String(parsed.failureReason)}`);
|
|
1463
|
+
}
|
|
1464
|
+
} else {
|
|
1465
|
+
lines.push("写入前检查结果无法解析,请查看运行记录。");
|
|
1466
|
+
}
|
|
1467
|
+
} else if (prewriteResult && prewriteResult.status === 404) {
|
|
1468
|
+
lines.push("写入前检查尚未执行,或没有留下检查结果。");
|
|
1469
|
+
} else if (prewriteResult) {
|
|
1470
|
+
lines.push(
|
|
1471
|
+
"暂时无法读取写入前检查结果;为安全起见,不把它当成已通过。",
|
|
955
1472
|
);
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1473
|
+
} else {
|
|
1474
|
+
lines.push("写入前检查尚未执行,或没有留下检查结果。");
|
|
1475
|
+
}
|
|
1476
|
+
if (ledgerBody && ledgerBody.present === true) {
|
|
1477
|
+
const value = (candidate) =>
|
|
1478
|
+
typeof candidate === "number" ? candidate : "未知";
|
|
1479
|
+
lines.push(
|
|
1480
|
+
`需求覆盖记录:原始片段 ${value(ledgerBody.fragmentCount)} 个;整理后的需求 ${value(ledgerBody.canonicalRequirementCount)} 条;待处理 ${value(ledgerBody.unresolvedCount)} 条;冲突 ${value(ledgerBody.conflictCount)} 条。`,
|
|
962
1481
|
);
|
|
963
|
-
|
|
964
|
-
|
|
1482
|
+
if (ledgerBody.stale === true) {
|
|
1483
|
+
lines.push("提醒:任务来源后来发生过变化,这份需求覆盖记录可能已经过时。");
|
|
1484
|
+
}
|
|
1485
|
+
} else if (ledgerBody) {
|
|
1486
|
+
lines.push("没有需求覆盖记录;可能是任务没有引用资料,或记录尚未生成。不会猜测数量。");
|
|
1487
|
+
} else if (taskId) {
|
|
1488
|
+
lines.push("需求覆盖记录暂时无法查看;不会把读取失败当成没有问题。");
|
|
965
1489
|
}
|
|
966
|
-
return
|
|
1490
|
+
return lines;
|
|
967
1491
|
}
|
|
968
1492
|
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
}
|
|
981
|
-
if (tab === "output") {
|
|
982
|
-
const saved = uiState.dagNodeOutputViewportState;
|
|
983
|
-
if (saved?.regionKey === regionKey && saved.followLatest) {
|
|
984
|
-
content.scrollTop = content.scrollHeight;
|
|
985
|
-
content.scrollLeft = saved.scrollLeft ?? 0;
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
const saved =
|
|
990
|
-
getDagInspectorViewportState(regionKey) ??
|
|
991
|
-
(tab === "input" &&
|
|
992
|
-
uiState.dagNodeInputViewportState?.regionKey === regionKey
|
|
993
|
-
? uiState.dagNodeInputViewportState
|
|
994
|
-
: null) ??
|
|
995
|
-
(tab === "output" &&
|
|
996
|
-
uiState.dagNodeOutputViewportState?.regionKey === regionKey
|
|
997
|
-
? uiState.dagNodeOutputViewportState
|
|
998
|
-
: null) ??
|
|
999
|
-
(tab === "spec-evidence" &&
|
|
1000
|
-
uiState.dagNodeSpecEvidenceViewportState?.regionKey === regionKey
|
|
1001
|
-
? uiState.dagNodeSpecEvidenceViewportState
|
|
1002
|
-
: null);
|
|
1003
|
-
content.scrollLeft = saved?.scrollLeft ?? 0;
|
|
1004
|
-
content.scrollTop = saved?.scrollTop ?? 0;
|
|
1005
|
-
};
|
|
1006
|
-
apply();
|
|
1007
|
-
if (typeof requestAnimationFrame === "function") {
|
|
1008
|
-
requestAnimationFrame(apply);
|
|
1493
|
+
/** DAG run 专属 prewrite-result 只读拉取(内联 fetch,不新增 api.js 依赖)。 */
|
|
1494
|
+
async function fetchPrewriteResultJson(dagRunId) {
|
|
1495
|
+
try {
|
|
1496
|
+
const res = await fetchWithWorkspaceScope(
|
|
1497
|
+
`/api/dag-runs/${encodeURIComponent(dagRunId)}/prewrite-result`,
|
|
1498
|
+
{ credentials: "same-origin" },
|
|
1499
|
+
);
|
|
1500
|
+
if (!res.ok) return { ok: false, status: res.status };
|
|
1501
|
+
return { ok: true, body: await res.json() };
|
|
1502
|
+
} catch {
|
|
1503
|
+
return null; // 网络失败
|
|
1009
1504
|
}
|
|
1010
1505
|
}
|
|
1011
1506
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
});
|
|
1029
|
-
},
|
|
1030
|
-
{ passive: true },
|
|
1031
|
-
);
|
|
1032
|
-
// Touch current context so callers always have a key even before first scroll.
|
|
1033
|
-
saveInspectorContentScroll(content, dagRunId, nodeId, tab, {
|
|
1034
|
-
preserveIntent: true,
|
|
1035
|
-
});
|
|
1507
|
+
/**
|
|
1508
|
+
* Resolve the DAG-owned task identity, prewrite result, and safe ledger summary.
|
|
1509
|
+
* Exported so the real browser request sequence can be regression-tested without
|
|
1510
|
+
* relying on source-string assertions.
|
|
1511
|
+
*/
|
|
1512
|
+
export async function fetchFrontendGateLedgerData(dagRunId) {
|
|
1513
|
+
const run = await fetchJson(`/api/dag-runs/${encodeURIComponent(dagRunId)}`);
|
|
1514
|
+
const taskId = typeof run?.taskId === "string" ? run.taskId : "";
|
|
1515
|
+
const prewriteResult = await fetchPrewriteResultJson(dagRunId);
|
|
1516
|
+
let ledgerBody = null;
|
|
1517
|
+
if (taskId) {
|
|
1518
|
+
ledgerBody = await fetchJson(
|
|
1519
|
+
`/api/tasks/${encodeURIComponent(taskId)}/ledger`,
|
|
1520
|
+
);
|
|
1521
|
+
}
|
|
1522
|
+
return { taskId, prewriteResult, ledgerBody };
|
|
1036
1523
|
}
|
|
1037
1524
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1525
|
+
/**
|
|
1526
|
+
* Inspect 节点面板:frontend prewrite 门禁分类/稳定 failure code + ledger 安全摘要。
|
|
1527
|
+
* 数据全部来自只读接口与确定性产物(AC-BLOCK-005):task identity 从 DAG run
|
|
1528
|
+
* GET /api/dag-runs/:dagRunId 读取,prewrite 门禁调 DAG run 专属
|
|
1529
|
+
* GET /api/dag-runs/:dagRunId/prewrite-result;任何失败仅显示安全降级文案,
|
|
1530
|
+
* 绝不 push envelope。
|
|
1531
|
+
*/
|
|
1532
|
+
async function renderFrontendGateLedger(content, dagRunId) {
|
|
1533
|
+
const section = el("section", "node-input-section");
|
|
1534
|
+
section.appendChild(
|
|
1535
|
+
el("h4", null, "前端写入前检查与需求覆盖记录"),
|
|
1536
|
+
);
|
|
1537
|
+
const status = el("p", "muted", "加载中…");
|
|
1538
|
+
status.setAttribute("role", "status");
|
|
1539
|
+
section.appendChild(status);
|
|
1540
|
+
content.appendChild(section);
|
|
1541
|
+
try {
|
|
1542
|
+
const { taskId, prewriteResult, ledgerBody } =
|
|
1543
|
+
await fetchFrontendGateLedgerData(dagRunId);
|
|
1544
|
+
const lines = frontendGateLedgerLines({
|
|
1545
|
+
prewriteResult,
|
|
1546
|
+
ledgerBody,
|
|
1547
|
+
taskId,
|
|
1548
|
+
});
|
|
1549
|
+
const pre = el("pre", "cmd", lines.join("\n"));
|
|
1550
|
+
pre.dataset.testid = "frontend-prewrite-ledger-summary";
|
|
1551
|
+
status.replaceWith(pre);
|
|
1552
|
+
} catch (error) {
|
|
1553
|
+
status.textContent = `加载失败:${
|
|
1554
|
+
error instanceof Error ? error.message : String(error)
|
|
1555
|
+
}(安全降级,不展示敏感内容)`;
|
|
1059
1556
|
}
|
|
1060
|
-
return null;
|
|
1061
1557
|
}
|
|
1062
1558
|
|
|
1063
1559
|
/**
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1560
|
+
* Experimental prompt-override rerun tab. Only reachable when the server
|
|
1561
|
+
* injected the mutation token (switch on). Every node shows its frozen
|
|
1562
|
+
* subtask_prompt here; only FAILED (ERROR) nodes additionally get the editor +
|
|
1563
|
+
* restart flow: preflight (dagRerunPlan) binds the edit into planHash, dagRerun
|
|
1564
|
+
* executes it as a Console operation, and on success we jump to the new run.
|
|
1565
|
+
*/
|
|
1566
|
+
function buildContextExportSection(dagRunId, node) {
|
|
1567
|
+
const zone = el("section", "dag-action-export-zone");
|
|
1568
|
+
zone.dataset.actionSection = "context-export";
|
|
1569
|
+
const divider = el("div", "dag-action-export-divider");
|
|
1570
|
+
divider.append(
|
|
1571
|
+
el("span", null, "不需要重跑?"),
|
|
1572
|
+
el("p", null, "你也可以只把这个节点的上下文打包带走。"),
|
|
1573
|
+
);
|
|
1574
|
+
zone.appendChild(divider);
|
|
1575
|
+
const section = el("div", "prompt-restart-box context-export-box");
|
|
1576
|
+
section.setAttribute("role", "region");
|
|
1577
|
+
section.setAttribute("aria-labelledby", "context-export-title");
|
|
1578
|
+
const heading = el("div", "context-export-heading");
|
|
1579
|
+
const headingCopy = el("div", null);
|
|
1580
|
+
headingCopy.appendChild(el("span", "context-export-eyebrow", "上下文交接包"));
|
|
1581
|
+
const title = el("h4", null, "把这个节点的资料交给另一个 AI");
|
|
1582
|
+
title.id = "context-export-title";
|
|
1583
|
+
headingCopy.appendChild(title);
|
|
1584
|
+
headingCopy.appendChild(
|
|
1585
|
+
el("p", null, "选择接收方式和是否脱敏,系统会生成一个带来源校验信息的 ZIP 交接包。"),
|
|
1586
|
+
);
|
|
1587
|
+
const invariant = el("div", "context-export-invariant");
|
|
1588
|
+
const lockIcon = el("i", "ri-lock-2-line");
|
|
1589
|
+
lockIcon.setAttribute("aria-hidden", "true");
|
|
1590
|
+
invariant.append(lockIcon, document.createTextNode(" 原运行保持不变"));
|
|
1591
|
+
heading.append(headingCopy, invariant);
|
|
1592
|
+
section.appendChild(heading);
|
|
1593
|
+
|
|
1594
|
+
const workspace = el("div", "context-export-workspace");
|
|
1595
|
+
const controls = el("div", "context-export-controls");
|
|
1596
|
+
const targetFieldset = document.createElement("fieldset");
|
|
1597
|
+
targetFieldset.className = "context-export-fieldset";
|
|
1598
|
+
targetFieldset.dataset.testid = "context-export-target";
|
|
1599
|
+
targetFieldset.appendChild(el("legend", null, "交给谁使用?"));
|
|
1600
|
+
const targetChoices = el("div", "context-export-target-grid");
|
|
1601
|
+
for (const [index, option] of CONTEXT_EXPORT_TARGETS.entries()) {
|
|
1602
|
+
const choice = el("label", "context-export-choice");
|
|
1603
|
+
const input = document.createElement("input");
|
|
1604
|
+
input.type = "radio";
|
|
1605
|
+
input.name = "context-export-target";
|
|
1606
|
+
input.value = option.value;
|
|
1607
|
+
input.checked = index === 0;
|
|
1608
|
+
const icon = el("i", option.icon);
|
|
1609
|
+
icon.setAttribute("aria-hidden", "true");
|
|
1610
|
+
const copy = el("span", "context-export-choice-copy");
|
|
1611
|
+
copy.append(
|
|
1612
|
+
el("strong", null, option.label),
|
|
1613
|
+
el("small", null, option.description),
|
|
1614
|
+
);
|
|
1615
|
+
choice.append(input, icon, copy);
|
|
1616
|
+
targetChoices.appendChild(choice);
|
|
1617
|
+
}
|
|
1618
|
+
targetFieldset.appendChild(targetChoices);
|
|
1619
|
+
controls.appendChild(targetFieldset);
|
|
1620
|
+
|
|
1621
|
+
const profileFieldset = document.createElement("fieldset");
|
|
1622
|
+
profileFieldset.className = "context-export-fieldset";
|
|
1623
|
+
profileFieldset.dataset.testid = "context-export-profile";
|
|
1624
|
+
profileFieldset.appendChild(el("legend", null, "如何保护内容?"));
|
|
1625
|
+
const profileChoices = el("div", "context-export-profile-grid");
|
|
1626
|
+
for (const [index, option] of CONTEXT_EXPORT_PROFILES.entries()) {
|
|
1627
|
+
const choice = el(
|
|
1628
|
+
"label",
|
|
1629
|
+
`context-export-profile-choice${option.value === "raw" ? " is-risk" : ""}`,
|
|
1630
|
+
);
|
|
1631
|
+
const input = document.createElement("input");
|
|
1632
|
+
input.type = "radio";
|
|
1633
|
+
input.name = "context-export-profile";
|
|
1634
|
+
input.value = option.value;
|
|
1635
|
+
input.checked = index === 0;
|
|
1636
|
+
const copy = el("span", "context-export-choice-copy");
|
|
1637
|
+
const titleRow = el("span", "context-export-profile-title");
|
|
1638
|
+
titleRow.append(
|
|
1639
|
+
el("strong", null, option.label),
|
|
1640
|
+
el("span", `context-export-profile-badge is-${option.value}`, option.badge),
|
|
1641
|
+
);
|
|
1642
|
+
copy.append(titleRow, el("small", null, option.description));
|
|
1643
|
+
choice.append(input, copy);
|
|
1644
|
+
profileChoices.appendChild(choice);
|
|
1645
|
+
}
|
|
1646
|
+
profileFieldset.appendChild(profileChoices);
|
|
1647
|
+
controls.appendChild(profileFieldset);
|
|
1648
|
+
|
|
1649
|
+
const rawAckLabel = el("label", "prompt-restart-field context-export-raw-ack");
|
|
1650
|
+
const rawAck = document.createElement("input");
|
|
1651
|
+
rawAck.type = "checkbox";
|
|
1652
|
+
rawAck.dataset.testid = "context-export-raw-ack";
|
|
1653
|
+
rawAckLabel.appendChild(rawAck);
|
|
1654
|
+
const rawAckCopy = el("span", null);
|
|
1655
|
+
rawAckCopy.append(
|
|
1656
|
+
el("strong", null, "确认导出未脱敏内容"),
|
|
1657
|
+
el("small", null, "我理解文件可能包含凭据、绝对路径和执行原文。"),
|
|
1658
|
+
);
|
|
1659
|
+
rawAckLabel.appendChild(rawAckCopy);
|
|
1660
|
+
rawAckLabel.hidden = true;
|
|
1661
|
+
controls.appendChild(rawAckLabel);
|
|
1662
|
+
workspace.appendChild(controls);
|
|
1663
|
+
|
|
1664
|
+
const ticket = el("aside", "context-export-ticket");
|
|
1665
|
+
ticket.setAttribute("aria-label", "交接包预览");
|
|
1666
|
+
ticket.setAttribute("aria-live", "polite");
|
|
1667
|
+
const ticketTop = el("div", "context-export-ticket-top");
|
|
1668
|
+
ticketTop.append(
|
|
1669
|
+
el("span", "context-export-ticket-type", "交接资料 / ZIP"),
|
|
1670
|
+
el("span", "context-export-ticket-safety", "已脱敏"),
|
|
1671
|
+
);
|
|
1672
|
+
const ticketTitle = el("strong", "context-export-ticket-title", "通用 AI 交接包");
|
|
1673
|
+
const ticketRows = el("dl", "context-export-ticket-rows");
|
|
1674
|
+
const appendTicketRow = (label, value, className) => {
|
|
1675
|
+
const term = el("dt", null, label);
|
|
1676
|
+
const detail = el("dd", className ?? null, value);
|
|
1677
|
+
ticketRows.append(term, detail);
|
|
1678
|
+
return detail;
|
|
1679
|
+
};
|
|
1680
|
+
const recipientValue = appendTicketRow("用途", "适合交给其他 AI 工具继续处理");
|
|
1681
|
+
const contentsValue = appendTicketRow("包含", CONTEXT_EXPORT_TARGETS[0].contents, "is-mono");
|
|
1682
|
+
const protectionValue = appendTicketRow("保护", "自动隐藏匹配到的疑似凭据");
|
|
1683
|
+
const attemptValue = appendTicketRow(
|
|
1684
|
+
"来源",
|
|
1685
|
+
`${node.nodeId} · 第 ${selectedAttemptNumber(dagRunId, node) ?? 1} 次执行`,
|
|
1686
|
+
"is-mono",
|
|
1687
|
+
);
|
|
1688
|
+
ticket.append(
|
|
1689
|
+
ticketTop,
|
|
1690
|
+
el("span", "context-export-ticket-label", "即将生成"),
|
|
1691
|
+
ticketTitle,
|
|
1692
|
+
ticketRows,
|
|
1693
|
+
el("p", "context-export-ticket-foot", "附带文件清单和内容校验码,可以核对资料来源与完整性"),
|
|
1694
|
+
);
|
|
1695
|
+
workspace.appendChild(ticket);
|
|
1696
|
+
section.appendChild(workspace);
|
|
1697
|
+
|
|
1698
|
+
const selectedValue = (name) =>
|
|
1699
|
+
section.querySelector(`input[name="${name}"]:checked`)?.value ?? "";
|
|
1700
|
+
const updatePreview = () => {
|
|
1701
|
+
const targetValue = selectedValue("context-export-target");
|
|
1702
|
+
const profileValue = selectedValue("context-export-profile");
|
|
1703
|
+
const target =
|
|
1704
|
+
CONTEXT_EXPORT_TARGETS.find((option) => option.value === targetValue) ??
|
|
1705
|
+
CONTEXT_EXPORT_TARGETS[0];
|
|
1706
|
+
const profile =
|
|
1707
|
+
CONTEXT_EXPORT_PROFILES.find((option) => option.value === profileValue) ??
|
|
1708
|
+
CONTEXT_EXPORT_PROFILES[0];
|
|
1709
|
+
ticketTitle.textContent = target.label;
|
|
1710
|
+
recipientValue.textContent = target.description;
|
|
1711
|
+
contentsValue.textContent = target.contents;
|
|
1712
|
+
protectionValue.textContent = profile.description;
|
|
1713
|
+
attemptValue.textContent = `${node.nodeId} · 第 ${selectedAttemptNumber(dagRunId, node) ?? 1} 次执行`;
|
|
1714
|
+
const safety = ticket.querySelector(".context-export-ticket-safety");
|
|
1715
|
+
if (safety) {
|
|
1716
|
+
safety.textContent = profileValue === "raw" ? "原始内容" : "已脱敏";
|
|
1717
|
+
safety.classList.toggle("is-risk", profileValue === "raw");
|
|
1718
|
+
}
|
|
1719
|
+
rawAckLabel.hidden = profileValue !== "raw";
|
|
1720
|
+
if (profileValue !== "raw") rawAck.checked = false;
|
|
1721
|
+
};
|
|
1722
|
+
for (const input of section.querySelectorAll(
|
|
1723
|
+
'input[name="context-export-target"], input[name="context-export-profile"]',
|
|
1724
|
+
)) {
|
|
1725
|
+
input.addEventListener("change", updatePreview);
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
const actions = el("div", "prompt-restart-actions");
|
|
1729
|
+
const submit = document.createElement("button");
|
|
1730
|
+
submit.type = "button";
|
|
1731
|
+
submit.className = "prompt-restart-submit context-export-submit";
|
|
1732
|
+
submit.dataset.testid = "context-export-submit";
|
|
1733
|
+
const submitIcon = el("i", "ri-download-cloud-2-line");
|
|
1734
|
+
submitIcon.setAttribute("aria-hidden", "true");
|
|
1735
|
+
submit.append(submitIcon, document.createTextNode(" 生成交接包并下载"));
|
|
1736
|
+
actions.appendChild(submit);
|
|
1737
|
+
section.appendChild(actions);
|
|
1738
|
+
const status = el("p", "prompt-restart-status", "");
|
|
1739
|
+
status.setAttribute("role", "status");
|
|
1740
|
+
status.setAttribute("aria-live", "polite");
|
|
1741
|
+
section.appendChild(status);
|
|
1742
|
+
const setStatus = (message, error = false) => {
|
|
1743
|
+
status.textContent = message;
|
|
1744
|
+
status.classList.toggle("prompt-restart-error", error);
|
|
1745
|
+
};
|
|
1746
|
+
submit.addEventListener("click", () => {
|
|
1747
|
+
void (async () => {
|
|
1748
|
+
const targetValue = selectedValue("context-export-target");
|
|
1749
|
+
const profileValue = selectedValue("context-export-profile");
|
|
1750
|
+
if (profileValue === "raw" && !rawAck.checked) {
|
|
1751
|
+
setStatus("原始导出前必须勾选风险确认。", true);
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
submit.disabled = true;
|
|
1755
|
+
try {
|
|
1756
|
+
setStatus("正在生成带来源校验信息的交接包…");
|
|
1757
|
+
const clientRequestId = `inspect-context-export-${Date.now()}-${Math.random()
|
|
1758
|
+
.toString(36)
|
|
1759
|
+
.slice(2, 10)}`;
|
|
1760
|
+
const response = await postOperatorAction(
|
|
1761
|
+
"contextExport",
|
|
1762
|
+
{
|
|
1763
|
+
runId: dagRunId,
|
|
1764
|
+
nodeId: node.nodeId,
|
|
1765
|
+
attempt: selectedAttemptNumber(dagRunId, node) ?? 1,
|
|
1766
|
+
target: targetValue,
|
|
1767
|
+
profile: profileValue,
|
|
1768
|
+
rawAcknowledged: profileValue === "raw" && rawAck.checked,
|
|
1769
|
+
},
|
|
1770
|
+
clientRequestId,
|
|
1771
|
+
);
|
|
1772
|
+
const operationId = response.body?.operationId;
|
|
1773
|
+
if (!response.ok || !operationId) {
|
|
1774
|
+
throw new Error(response.body?.error?.message ?? "导出操作未被接受");
|
|
1775
|
+
}
|
|
1776
|
+
const operation = await pollOperationToTerminal(operationId, (message) =>
|
|
1777
|
+
setStatus(message.replace("续跑", "导出")),
|
|
1778
|
+
);
|
|
1779
|
+
if (operation?.state !== "succeeded" || !operation.result?.downloadUrl) {
|
|
1780
|
+
throw new Error(operation?.errorMessage ?? "导出未成功完成");
|
|
1781
|
+
}
|
|
1782
|
+
setStatus("交接包已生成,正在安全下载…");
|
|
1783
|
+
const downloaded = await downloadContextExport(operation.result.downloadUrl);
|
|
1784
|
+
const objectUrl = URL.createObjectURL(downloaded.blob);
|
|
1785
|
+
const link = document.createElement("a");
|
|
1786
|
+
link.href = objectUrl;
|
|
1787
|
+
link.download = downloaded.filename;
|
|
1788
|
+
document.body.appendChild(link);
|
|
1789
|
+
link.click();
|
|
1790
|
+
link.remove();
|
|
1791
|
+
URL.revokeObjectURL(objectUrl);
|
|
1792
|
+
setStatus(
|
|
1793
|
+
`下载完成 · ${operation.result.bundleId} · ${new Intl.NumberFormat("zh-CN").format(operation.result.bytes)} 字节\n内容校验码 ${operation.result.bundleSha256}`,
|
|
1794
|
+
);
|
|
1795
|
+
} catch (error) {
|
|
1796
|
+
setStatus(transferErrorStatusText(error, "导出未成功完成"), true);
|
|
1797
|
+
} finally {
|
|
1798
|
+
submit.disabled = false;
|
|
1799
|
+
}
|
|
1800
|
+
})();
|
|
1801
|
+
});
|
|
1802
|
+
updatePreview();
|
|
1803
|
+
zone.appendChild(section);
|
|
1804
|
+
return zone;
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
function createDagActionCard({ eyebrow, title, description, icon, className }) {
|
|
1808
|
+
const section = el("section", `dag-action-card ${className ?? ""}`.trim());
|
|
1809
|
+
const header = el("div", "dag-action-card-header");
|
|
1810
|
+
const iconBox = el("div", "dag-action-card-icon");
|
|
1811
|
+
const iconElement = el("i", icon);
|
|
1812
|
+
iconElement.setAttribute("aria-hidden", "true");
|
|
1813
|
+
iconBox.appendChild(iconElement);
|
|
1814
|
+
const copy = el("div", "dag-action-card-copy");
|
|
1815
|
+
copy.append(
|
|
1816
|
+
el("span", "dag-action-eyebrow", eyebrow),
|
|
1817
|
+
el("h4", null, title),
|
|
1818
|
+
el("p", null, description),
|
|
1819
|
+
);
|
|
1820
|
+
header.append(iconBox, copy);
|
|
1821
|
+
const body = el("div", "dag-action-card-body");
|
|
1822
|
+
section.append(header, body);
|
|
1823
|
+
return { section, body };
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
function buildDagActionAvailability({ title, description, reasonCode, tone = "neutral" }) {
|
|
1827
|
+
const panel = el("div", `dag-action-availability is-${tone}`);
|
|
1828
|
+
const icon = el(
|
|
1829
|
+
"i",
|
|
1830
|
+
tone === "blocked"
|
|
1831
|
+
? "ri-forbid-2-line"
|
|
1832
|
+
: tone === "ready"
|
|
1833
|
+
? "ri-checkbox-circle-line"
|
|
1834
|
+
: "ri-information-line",
|
|
1835
|
+
);
|
|
1836
|
+
icon.setAttribute("aria-hidden", "true");
|
|
1837
|
+
const copy = el("div", null);
|
|
1838
|
+
copy.append(el("strong", null, title), el("p", null, description));
|
|
1839
|
+
if (reasonCode) {
|
|
1840
|
+
const label = contextTransferReasonLabel(reasonCode);
|
|
1841
|
+
if (label) copy.appendChild(el("p", "dag-action-reason-copy", label));
|
|
1842
|
+
copy.appendChild(el("code", null, reasonCode));
|
|
1843
|
+
}
|
|
1844
|
+
panel.append(icon, copy);
|
|
1845
|
+
return panel;
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
function buildFullContentCta() {
|
|
1849
|
+
// Honest limitation note (review 2026-08-26): the context bundle exports
|
|
1850
|
+
// node *inputs*; it does not necessarily contain the full bytes of a
|
|
1851
|
+
// produced artifact or a revision candidate, so pointing the truncated
|
|
1852
|
+
// preview at the export flow would overpromise. State the bound plainly.
|
|
1853
|
+
return el(
|
|
1854
|
+
"p",
|
|
1855
|
+
"artifact-content-preview-full-cta",
|
|
1856
|
+
"预览有截断;当前版本暂不提供完整文件下载。",
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
function createArtifactContentPreview(
|
|
1861
|
+
dagRunId,
|
|
1862
|
+
nodeId,
|
|
1863
|
+
resolveArtifact,
|
|
1864
|
+
{ label = "查看文件内容", testId = "artifact-file-preview" } = {},
|
|
1865
|
+
) {
|
|
1866
|
+
const details = document.createElement("details");
|
|
1867
|
+
details.className = "artifact-content-preview";
|
|
1868
|
+
details.dataset.testid = testId;
|
|
1869
|
+
const summary = document.createElement("summary");
|
|
1870
|
+
const icon = el("i", "ri-eye-line");
|
|
1871
|
+
icon.setAttribute("aria-hidden", "true");
|
|
1872
|
+
const summaryText = el("span", null, label);
|
|
1873
|
+
summary.append(icon, summaryText);
|
|
1874
|
+
details.appendChild(summary);
|
|
1875
|
+
const host = el("div", "artifact-content-preview-body");
|
|
1876
|
+
details.appendChild(host);
|
|
1877
|
+
let loadedArtifactId = null;
|
|
1878
|
+
let requestVersion = 0;
|
|
1879
|
+
|
|
1880
|
+
const reset = () => {
|
|
1881
|
+
requestVersion += 1;
|
|
1882
|
+
loadedArtifactId = null;
|
|
1883
|
+
details.open = false;
|
|
1884
|
+
clearNode(host);
|
|
1885
|
+
};
|
|
1886
|
+
const renderStatus = (message, error = false) => {
|
|
1887
|
+
clearNode(host);
|
|
1888
|
+
const status = el(
|
|
1889
|
+
"p",
|
|
1890
|
+
error ? "artifact-content-preview-error" : "muted",
|
|
1891
|
+
message,
|
|
1892
|
+
);
|
|
1893
|
+
status.setAttribute("role", error ? "alert" : "status");
|
|
1894
|
+
status.setAttribute("aria-live", "polite");
|
|
1895
|
+
host.appendChild(status);
|
|
1896
|
+
};
|
|
1897
|
+
const load = async () => {
|
|
1898
|
+
const artifact = resolveArtifact();
|
|
1899
|
+
if (!artifact?.artifactId) {
|
|
1900
|
+
renderStatus("没有可预览的文件。", true);
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
if (loadedArtifactId === artifact.artifactId) return;
|
|
1904
|
+
const version = ++requestVersion;
|
|
1905
|
+
renderStatus("正在读取并核验文件内容…");
|
|
1906
|
+
const result = await fetchDagNodeArtifactPreview(
|
|
1907
|
+
dagRunId,
|
|
1908
|
+
nodeId,
|
|
1909
|
+
artifact.artifactId,
|
|
1910
|
+
);
|
|
1911
|
+
if (version !== requestVersion || !details.isConnected) return;
|
|
1912
|
+
if (!result.ok || !result.body) {
|
|
1913
|
+
renderStatus(result.body?.error || "文件内容暂时无法预览。", true);
|
|
1914
|
+
return;
|
|
1915
|
+
}
|
|
1916
|
+
loadedArtifactId = artifact.artifactId;
|
|
1917
|
+
const data = result.body;
|
|
1918
|
+
clearNode(host);
|
|
1919
|
+
const header = el("div", "artifact-content-preview-meta");
|
|
1920
|
+
const metaChildren = [
|
|
1921
|
+
el("code", null, data.path ?? artifact.path ?? artifact.artifactId),
|
|
1922
|
+
el(
|
|
1923
|
+
"span",
|
|
1924
|
+
null,
|
|
1925
|
+
`${data.mediaType ?? "未知类型"} · ${new Intl.NumberFormat("zh-CN").format(data.sourceBytes ?? 0)} 字节`,
|
|
1926
|
+
),
|
|
1927
|
+
];
|
|
1928
|
+
if (typeof data.sha256 === "string" && data.sha256.length >= 12) {
|
|
1929
|
+
const sha = el(
|
|
1930
|
+
"span",
|
|
1931
|
+
null,
|
|
1932
|
+
` · 内容校验码 ${data.sha256.slice(0, 12)}…`,
|
|
1933
|
+
);
|
|
1934
|
+
sha.title = data.sha256;
|
|
1935
|
+
metaChildren.push(sha);
|
|
1936
|
+
}
|
|
1937
|
+
header.append(...metaChildren);
|
|
1938
|
+
host.appendChild(header);
|
|
1939
|
+
if (data.previewKind !== "text" || typeof data.content !== "string") {
|
|
1940
|
+
host.appendChild(
|
|
1941
|
+
el(
|
|
1942
|
+
"p",
|
|
1943
|
+
"artifact-content-preview-unavailable",
|
|
1944
|
+
"该文件类型不适合直接在页面中显示;系统已经核对文件位置、大小和内容校验码。",
|
|
1945
|
+
),
|
|
1946
|
+
);
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
const normalizedMedia = String(data.mediaType ?? "").toLowerCase();
|
|
1950
|
+
if (normalizedMedia.includes("markdown")) {
|
|
1951
|
+
const documentPreview = el("div", "artifact-content-preview-document");
|
|
1952
|
+
documentPreview.appendChild(renderMarkdown(data.content));
|
|
1953
|
+
host.appendChild(documentPreview);
|
|
1954
|
+
} else {
|
|
1955
|
+
const pre = el("pre", "artifact-content-preview-code");
|
|
1956
|
+
pre.textContent = normalizedMedia.includes("json")
|
|
1957
|
+
? prettyJsonBlock(data.content) ?? data.content
|
|
1958
|
+
: data.content;
|
|
1959
|
+
host.appendChild(pre);
|
|
1960
|
+
}
|
|
1961
|
+
const notes = [];
|
|
1962
|
+
if (data.redacted) notes.push("疑似凭据已脱敏");
|
|
1963
|
+
if (data.truncated) {
|
|
1964
|
+
notes.push(
|
|
1965
|
+
`仅显示前 ${new Intl.NumberFormat("zh-CN").format(data.maxBytes ?? 0)} 字节`,
|
|
1966
|
+
);
|
|
1967
|
+
}
|
|
1968
|
+
if (notes.length > 0) {
|
|
1969
|
+
host.appendChild(el("p", "artifact-content-preview-note", notes.join(" · ")));
|
|
1970
|
+
}
|
|
1971
|
+
if (data.truncated) {
|
|
1972
|
+
host.appendChild(buildFullContentCta());
|
|
1973
|
+
}
|
|
1974
|
+
};
|
|
1975
|
+
details.addEventListener("toggle", () => {
|
|
1976
|
+
if (details.open) void load();
|
|
1977
|
+
});
|
|
1978
|
+
return { element: details, reset };
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
export function artifactRevisionRunEligibility(run) {
|
|
1982
|
+
// File-level eligibility only says that a file has a known replacement
|
|
1983
|
+
// contract. Creating a derived run has stricter, run-level safeguards.
|
|
1984
|
+
// Keep this check here so the UI does not invite an action the server will
|
|
1985
|
+
// necessarily reject later.
|
|
1986
|
+
if (!run) return { eligible: true };
|
|
1987
|
+
const lifecycle = String(run.lifecycle ?? "").toLowerCase();
|
|
1988
|
+
const status = String(run.status ?? "").toLowerCase();
|
|
1989
|
+
if (lifecycle !== "completed") {
|
|
1990
|
+
return {
|
|
1991
|
+
eligible: false,
|
|
1992
|
+
title: "这次运行还没有完整结束",
|
|
1993
|
+
description:
|
|
1994
|
+
"请等待运行收尾为“已完成”。进行中、暂停中,或尚未收尾的报错,都不能从替换产出继续。",
|
|
1995
|
+
};
|
|
1996
|
+
}
|
|
1997
|
+
if (!new Set(["failed", "partial_failed"]).has(status)) {
|
|
1998
|
+
return {
|
|
1999
|
+
eligible: false,
|
|
2000
|
+
title: "这次运行不支持替换产出后继续",
|
|
2001
|
+
description:
|
|
2002
|
+
"只有已完整结束且结果为“失败”或“部分失败”的运行,才能换文件后继续。当前运行已经成功完成;文件本身可替换,不代表可以创建后续运行。",
|
|
2003
|
+
};
|
|
2004
|
+
}
|
|
2005
|
+
return { eligible: true };
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
function buildArtifactRevisionSection(dagRunId, node, run) {
|
|
2009
|
+
const { section, body } = createDagActionCard({
|
|
2010
|
+
eyebrow: "替换已有文件",
|
|
2011
|
+
title: "换掉这个节点的产出后继续",
|
|
2012
|
+
description: "上传新文件后,系统会先检查格式并告诉你哪些后续节点需要重做;确认前不会改动原运行。",
|
|
2013
|
+
icon: "ri-file-transfer-line",
|
|
2014
|
+
className: "artifact-revision-box",
|
|
2015
|
+
});
|
|
2016
|
+
section.dataset.actionSection = "artifact-revision";
|
|
2017
|
+
const runEligibility = artifactRevisionRunEligibility(run);
|
|
2018
|
+
if (!runEligibility.eligible) {
|
|
2019
|
+
body.appendChild(
|
|
2020
|
+
buildDagActionAvailability({
|
|
2021
|
+
tone: "blocked",
|
|
2022
|
+
title: runEligibility.title,
|
|
2023
|
+
description: runEligibility.description,
|
|
2024
|
+
}),
|
|
2025
|
+
);
|
|
2026
|
+
return section;
|
|
2027
|
+
}
|
|
2028
|
+
body.appendChild(
|
|
2029
|
+
buildDagActionAvailability({
|
|
2030
|
+
title: "正在检查这个文件能不能安全替换",
|
|
2031
|
+
description: "系统正在读取运行开始前保存的文件关系和替换规则。",
|
|
2032
|
+
}),
|
|
2033
|
+
);
|
|
2034
|
+
void (async () => {
|
|
2035
|
+
const response = await fetchDagNodeArtifacts(dagRunId, node.nodeId);
|
|
2036
|
+
clearNode(body);
|
|
2037
|
+
if (!response.ok || response.body?.binding?.available !== true) {
|
|
2038
|
+
body.appendChild(
|
|
2039
|
+
buildDagActionAvailability({
|
|
2040
|
+
tone: "blocked",
|
|
2041
|
+
title: "这个运行暂时不能安全替换产出",
|
|
2042
|
+
description:
|
|
2043
|
+
"缺少结构化的产出关系,系统无法可靠判断哪些后续节点会受影响,也不会根据文件名或提示词猜测。",
|
|
2044
|
+
reasonCode:
|
|
2045
|
+
response.body?.reasonCode ??
|
|
2046
|
+
response.body?.binding?.reasonCode ??
|
|
2047
|
+
"ARTIFACT_BINDING_UNAVAILABLE",
|
|
2048
|
+
}),
|
|
2049
|
+
);
|
|
2050
|
+
return;
|
|
2051
|
+
}
|
|
2052
|
+
const eligible = (response.body.produces ?? []).filter(
|
|
2053
|
+
(artifact) => artifact.revision?.eligible === true,
|
|
2054
|
+
);
|
|
2055
|
+
if (eligible.length === 0) {
|
|
2056
|
+
body.appendChild(
|
|
2057
|
+
buildDagActionAvailability({
|
|
2058
|
+
title: "这个节点没有可替换的已生成文件",
|
|
2059
|
+
description:
|
|
2060
|
+
"当前节点没有同时满足“已经生成”和“允许替换”的产出。失败节点仍可在下方修改提示词后重跑。",
|
|
2061
|
+
}),
|
|
2062
|
+
);
|
|
2063
|
+
return;
|
|
2064
|
+
}
|
|
2065
|
+
body.appendChild(
|
|
2066
|
+
buildDagActionAvailability({
|
|
2067
|
+
tone: "ready",
|
|
2068
|
+
title: `可以替换 ${eligible.length} 个已生成文件`,
|
|
2069
|
+
description: "原运行不会被修改;确认后系统会另外创建一次新运行。",
|
|
2070
|
+
}),
|
|
2071
|
+
);
|
|
2072
|
+
const form = el("div", "dag-action-form artifact-revision-form");
|
|
2073
|
+
const artifactLabel = el("label", "prompt-restart-field");
|
|
2074
|
+
artifactLabel.appendChild(el("span", "dag-action-field-label", "选择要替换的产出"));
|
|
2075
|
+
const artifactSelect = document.createElement("select");
|
|
2076
|
+
artifactSelect.className = "prompt-restart-mode-select";
|
|
2077
|
+
artifactSelect.dataset.testid = "artifact-revision-artifact";
|
|
2078
|
+
for (const artifact of eligible) {
|
|
2079
|
+
const option = document.createElement("option");
|
|
2080
|
+
option.value = artifact.artifactId;
|
|
2081
|
+
option.textContent = `${artifact.artifactId} · ${artifact.path}`;
|
|
2082
|
+
artifactSelect.appendChild(option);
|
|
2083
|
+
}
|
|
2084
|
+
artifactLabel.appendChild(artifactSelect);
|
|
2085
|
+
form.appendChild(artifactLabel);
|
|
2086
|
+
const currentArtifactPreview = createArtifactContentPreview(
|
|
2087
|
+
dagRunId,
|
|
2088
|
+
node.nodeId,
|
|
2089
|
+
() => eligible.find((artifact) => artifact.artifactId === artifactSelect.value),
|
|
2090
|
+
{
|
|
2091
|
+
label: "查看当前文件",
|
|
2092
|
+
testId: ARTIFACT_FILE_PREVIEW_SURFACES.revisionSelection,
|
|
2093
|
+
},
|
|
2094
|
+
);
|
|
2095
|
+
form.appendChild(currentArtifactPreview.element);
|
|
2096
|
+
artifactSelect.addEventListener("change", currentArtifactPreview.reset);
|
|
2097
|
+
const fileLabel = el("label", "prompt-restart-field");
|
|
2098
|
+
fileLabel.appendChild(el("span", "dag-action-field-label", "选择新文件(最多 10 MB)"));
|
|
2099
|
+
const file = document.createElement("input");
|
|
2100
|
+
file.type = "file";
|
|
2101
|
+
file.className = "dag-action-file-input";
|
|
2102
|
+
file.dataset.testid = "artifact-revision-file";
|
|
2103
|
+
fileLabel.appendChild(file);
|
|
2104
|
+
form.appendChild(fileLabel);
|
|
2105
|
+
const reasonLabel = el("label", "prompt-restart-field");
|
|
2106
|
+
reasonLabel.appendChild(el("span", "dag-action-field-label", "为什么要替换?"));
|
|
2107
|
+
const reason = document.createElement("textarea");
|
|
2108
|
+
reason.className = "prompt-restart-textarea";
|
|
2109
|
+
reason.rows = 3;
|
|
2110
|
+
reason.placeholder = "例如:计划遗漏了一个验收条件,需要更正后继续";
|
|
2111
|
+
reason.dataset.testid = "artifact-revision-reason";
|
|
2112
|
+
reasonLabel.appendChild(reason);
|
|
2113
|
+
form.appendChild(reasonLabel);
|
|
2114
|
+
const actions = el("div", "prompt-restart-actions");
|
|
2115
|
+
const preview = document.createElement("button");
|
|
2116
|
+
preview.type = "button";
|
|
2117
|
+
preview.className = "prompt-restart-submit dag-action-primary";
|
|
2118
|
+
const previewIcon = el("i", "ri-radar-line");
|
|
2119
|
+
previewIcon.setAttribute("aria-hidden", "true");
|
|
2120
|
+
preview.append(previewIcon, document.createTextNode(" 校验文件并预览影响"));
|
|
2121
|
+
preview.dataset.testid = "artifact-revision-preview";
|
|
2122
|
+
actions.appendChild(preview);
|
|
2123
|
+
form.appendChild(actions);
|
|
2124
|
+
const status = el("p", "prompt-restart-status", "");
|
|
2125
|
+
status.setAttribute("role", "status");
|
|
2126
|
+
status.setAttribute("aria-live", "polite");
|
|
2127
|
+
form.appendChild(status);
|
|
2128
|
+
const planHost = el("div", "artifact-revision-plan");
|
|
2129
|
+
form.appendChild(planHost);
|
|
2130
|
+
body.appendChild(form);
|
|
2131
|
+
const setStatus = (message, error = false) => {
|
|
2132
|
+
status.textContent = message;
|
|
2133
|
+
status.classList.toggle("prompt-restart-error", error);
|
|
2134
|
+
};
|
|
2135
|
+
preview.addEventListener("click", () => {
|
|
2136
|
+
void (async () => {
|
|
2137
|
+
const selected = eligible.find((artifact) => artifact.artifactId === artifactSelect.value);
|
|
2138
|
+
const selectedFile = file.files?.[0];
|
|
2139
|
+
if (!selected || !selectedFile) {
|
|
2140
|
+
setStatus("请选择一个替换文件。", true);
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
if (selectedFile.size > 10 * 1024 * 1024) {
|
|
2144
|
+
setStatus("文件超过 10 MB 限制。", true);
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
if (!reason.value.trim()) {
|
|
2148
|
+
setStatus("需要填写派生运行原因。", true);
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
2151
|
+
preview.disabled = true;
|
|
2152
|
+
clearNode(planHost);
|
|
2153
|
+
try {
|
|
2154
|
+
const dataUrl = await new Promise((resolve, reject) => {
|
|
2155
|
+
const reader = new FileReader();
|
|
2156
|
+
reader.onerror = () => reject(reader.error ?? new Error("读取文件失败"));
|
|
2157
|
+
reader.onload = () => resolve(String(reader.result ?? ""));
|
|
2158
|
+
reader.readAsDataURL(selectedFile);
|
|
2159
|
+
});
|
|
2160
|
+
const candidateBase64 = String(dataUrl).split(",", 2)[1] ?? "";
|
|
2161
|
+
setStatus("正在检查新文件格式并对比差异…");
|
|
2162
|
+
const stageId = `artifact-stage-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2163
|
+
const staged = await postOperatorAction(
|
|
2164
|
+
"artifactRevisionStage",
|
|
2165
|
+
{
|
|
2166
|
+
runId: dagRunId,
|
|
2167
|
+
nodeId: node.nodeId,
|
|
2168
|
+
artifactId: selected.artifactId,
|
|
2169
|
+
mediaType: selected.mediaType,
|
|
2170
|
+
candidateBase64,
|
|
2171
|
+
},
|
|
2172
|
+
stageId,
|
|
2173
|
+
);
|
|
2174
|
+
if (!staged.ok || !staged.body?.operationId) throw new Error(staged.body?.error?.message ?? "修订 staging 失败");
|
|
2175
|
+
const stageOp = await pollOperationToTerminal(staged.body.operationId, (message) =>
|
|
2176
|
+
setStatus(message.replace("续跑", "修订校验")),
|
|
2177
|
+
);
|
|
2178
|
+
const revision = stageOp?.result?.revision;
|
|
2179
|
+
if (stageOp?.state !== "succeeded" || !revision?.revisionId) {
|
|
2180
|
+
throw new Error(stageOp?.errorMessage ?? "修订校验失败");
|
|
2181
|
+
}
|
|
2182
|
+
setStatus("文件检查通过,正在计算哪些后续节点需要重新执行…");
|
|
2183
|
+
const planId = `artifact-plan-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2184
|
+
const planned = await postOperatorAction(
|
|
2185
|
+
"artifactRevisionPlan",
|
|
2186
|
+
{ runId: dagRunId, artifactId: selected.artifactId, revisionId: revision.revisionId },
|
|
2187
|
+
planId,
|
|
2188
|
+
);
|
|
2189
|
+
if (!planned.ok || !planned.body?.operationId) throw new Error(planned.body?.error?.message ?? "影响预览失败");
|
|
2190
|
+
const planOp = await pollOperationToTerminal(planned.body.operationId, (message) =>
|
|
2191
|
+
setStatus(message.replace("续跑", "影响分析")),
|
|
2192
|
+
);
|
|
2193
|
+
const plan = planOp?.result?.plan;
|
|
2194
|
+
if (!plan) throw new Error(planOp?.errorMessage ?? "影响预览失败");
|
|
2195
|
+
planHost.appendChild(el("h5", null, "替换结果与影响范围"));
|
|
2196
|
+
planHost.appendChild(
|
|
2197
|
+
transparencyMetaList([
|
|
2198
|
+
["本次替换编号", revision.revisionId],
|
|
2199
|
+
["新文件校验码", revision.candidate?.sha256],
|
|
2200
|
+
[
|
|
2201
|
+
"文件内容类型",
|
|
2202
|
+
inspectorValueLabel("差异类型", revision.diff?.kind),
|
|
2203
|
+
],
|
|
2204
|
+
[
|
|
2205
|
+
"预计风险",
|
|
2206
|
+
inspectorValueLabel("风险级别", plan.risk),
|
|
2207
|
+
],
|
|
2208
|
+
["最先受影响的节点", plan.impact?.directConsumerNodeIds?.join(", ") || "无"],
|
|
2209
|
+
["会重新执行的节点", plan.impact?.affectedNodeIds?.join(", ") || "无"],
|
|
2210
|
+
["会沿用结果的节点", plan.impact?.importedNodeIds?.join(", ") || "无"],
|
|
2211
|
+
["本次计划校验码", plan.planHash],
|
|
2212
|
+
]),
|
|
2213
|
+
);
|
|
2214
|
+
if (revision.diff?.summary) {
|
|
2215
|
+
const diff = document.createElement("pre");
|
|
2216
|
+
diff.className = "prompt-restart-readonly";
|
|
2217
|
+
diff.textContent = revision.diff.summary;
|
|
2218
|
+
planHost.appendChild(diff);
|
|
2219
|
+
}
|
|
2220
|
+
if (plan.eligible !== true) {
|
|
2221
|
+
setStatus(
|
|
2222
|
+
`暂时不能创建新运行:${formatContextTransferReasonList(plan.blockedReasons) ?? "当前不满足继续运行的条件"}`,
|
|
2223
|
+
true,
|
|
2224
|
+
);
|
|
2225
|
+
return;
|
|
2226
|
+
}
|
|
2227
|
+
const execute = document.createElement("button");
|
|
2228
|
+
execute.type = "button";
|
|
2229
|
+
execute.className = "prompt-restart-submit dag-action-primary";
|
|
2230
|
+
execute.textContent = "确认并创建新运行";
|
|
2231
|
+
execute.dataset.testid = "artifact-revision-execute";
|
|
2232
|
+
planHost.appendChild(execute);
|
|
2233
|
+
execute.addEventListener("click", () => {
|
|
2234
|
+
void (async () => {
|
|
2235
|
+
execute.disabled = true;
|
|
2236
|
+
try {
|
|
2237
|
+
setStatus("正在创建新运行并重新执行受影响节点;原运行保持不变…");
|
|
2238
|
+
const executeId = `artifact-execute-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2239
|
+
const accepted = await postOperatorAction(
|
|
2240
|
+
"artifactRevisionExecute",
|
|
2241
|
+
{
|
|
2242
|
+
runId: dagRunId,
|
|
2243
|
+
artifactId: selected.artifactId,
|
|
2244
|
+
revisionId: revision.revisionId,
|
|
2245
|
+
planHash: plan.planHash,
|
|
2246
|
+
reason: reason.value.trim(),
|
|
2247
|
+
},
|
|
2248
|
+
executeId,
|
|
2249
|
+
);
|
|
2250
|
+
if (!accepted.ok || !accepted.body?.operationId) throw new Error(accepted.body?.error?.message ?? "新运行未被接受");
|
|
2251
|
+
const operation = await pollOperationToTerminal(accepted.body.operationId, setStatus);
|
|
2252
|
+
const childRunId = operation?.result?.newRunId;
|
|
2253
|
+
if (childRunId) {
|
|
2254
|
+
const open = document.createElement("button");
|
|
2255
|
+
open.type = "button";
|
|
2256
|
+
open.className =
|
|
2257
|
+
"prompt-restart-submit dag-action-secondary";
|
|
2258
|
+
open.textContent =
|
|
2259
|
+
operation?.state === "succeeded"
|
|
2260
|
+
? "打开新运行"
|
|
2261
|
+
: "打开失败的新运行";
|
|
2262
|
+
open.addEventListener("click", () => {
|
|
2263
|
+
navigate(`/dag/${encodeURIComponent(childRunId)}`);
|
|
2264
|
+
});
|
|
2265
|
+
planHost.appendChild(open);
|
|
2266
|
+
}
|
|
2267
|
+
if (operation?.state !== "succeeded" || !operation.result?.newRunId) {
|
|
2268
|
+
throw new Error(operation?.errorMessage ?? operation?.result?.message ?? "新运行失败");
|
|
2269
|
+
}
|
|
2270
|
+
setStatus(`新运行完成:${operation.result.newRunId}`);
|
|
2271
|
+
} catch (error) {
|
|
2272
|
+
setStatus(transferErrorStatusText(error, "新运行失败"), true);
|
|
2273
|
+
} finally {
|
|
2274
|
+
execute.disabled = false;
|
|
2275
|
+
}
|
|
2276
|
+
})();
|
|
2277
|
+
});
|
|
2278
|
+
setStatus("影响范围已经锁定;确认时系统会再次检查文件、运行和计划是否有变化。" );
|
|
2279
|
+
} catch (error) {
|
|
2280
|
+
setStatus(transferErrorStatusText(error, "影响预览失败"), true);
|
|
2281
|
+
} finally {
|
|
2282
|
+
preview.disabled = false;
|
|
2283
|
+
}
|
|
2284
|
+
})();
|
|
2285
|
+
});
|
|
2286
|
+
})();
|
|
2287
|
+
return section;
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
function buildDagActionIntro(node) {
|
|
2291
|
+
const intro = el("header", "dag-action-page-intro");
|
|
2292
|
+
const copy = el("div", null);
|
|
2293
|
+
copy.append(
|
|
2294
|
+
el("span", "dag-action-eyebrow", "节点操作"),
|
|
2295
|
+
el("h4", null, "选择下一步"),
|
|
2296
|
+
el(
|
|
2297
|
+
"p",
|
|
2298
|
+
null,
|
|
2299
|
+
"重跑会创建新的运行;当前运行及其已经保存的事实始终保持不变。",
|
|
2300
|
+
),
|
|
2301
|
+
);
|
|
2302
|
+
const rawState = node.status ?? "unknown";
|
|
2303
|
+
const state = el(
|
|
2304
|
+
"span",
|
|
2305
|
+
"dag-action-node-state",
|
|
2306
|
+
inspectorValueLabel("status", rawState),
|
|
2307
|
+
);
|
|
2308
|
+
if (state.textContent !== rawState) state.setAttribute("title", `原始值:${rawState}`);
|
|
2309
|
+
intro.append(copy, state);
|
|
2310
|
+
return intro;
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
async function renderPromptRestart(content, dagRunId, node, run) {
|
|
2314
|
+
const nodeId = node.nodeId;
|
|
2315
|
+
clearNode(content);
|
|
2316
|
+
const intro = buildDagActionIntro(node);
|
|
2317
|
+
const revisionSection = buildArtifactRevisionSection(dagRunId, node, run);
|
|
2318
|
+
const { section: promptSection, body: promptBody } = createDagActionCard({
|
|
2319
|
+
eyebrow: "提示词重跑",
|
|
2320
|
+
title: "修改失败提示后重新执行",
|
|
2321
|
+
description: "只有执行失败的节点可以修改提示词并从这里继续;其他节点只能查看运行开始前保存的提示词。",
|
|
2322
|
+
icon: "ri-restart-line",
|
|
2323
|
+
className: "prompt-rerun-action-box",
|
|
2324
|
+
});
|
|
2325
|
+
promptSection.dataset.actionSection = "prompt-restart";
|
|
2326
|
+
promptBody.appendChild(
|
|
2327
|
+
buildDagActionAvailability({
|
|
2328
|
+
title: "正在读取节点提示",
|
|
2329
|
+
description: "检查运行开始前保存的版本,以及每次失败时实际使用的版本。",
|
|
2330
|
+
}),
|
|
2331
|
+
);
|
|
2332
|
+
const exportSection = buildContextExportSection(dagRunId, node);
|
|
2333
|
+
const sections = new Map([
|
|
2334
|
+
["artifact-revision", revisionSection],
|
|
2335
|
+
["prompt-restart", promptSection],
|
|
2336
|
+
["context-export", exportSection],
|
|
2337
|
+
]);
|
|
2338
|
+
content.appendChild(intro);
|
|
2339
|
+
for (const sectionId of DAG_ACTION_SECTION_ORDER) {
|
|
2340
|
+
const section = sections.get(sectionId);
|
|
2341
|
+
if (section) content.appendChild(section);
|
|
2342
|
+
}
|
|
2343
|
+
const input = await fetchDagNodeInput(dagRunId, nodeId);
|
|
2344
|
+
if (
|
|
2345
|
+
!content.isConnected ||
|
|
2346
|
+
content.dataset.dagNodeId !== String(nodeId) ||
|
|
2347
|
+
content.dataset.dagRunId !== String(dagRunId) ||
|
|
2348
|
+
activeInspectorTab() !== "prompt-restart"
|
|
2349
|
+
) {
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2352
|
+
clearNode(promptBody);
|
|
2353
|
+
|
|
2354
|
+
if (!input.ok || !input.body?.available) {
|
|
2355
|
+
promptBody.appendChild(
|
|
2356
|
+
buildDagActionAvailability({
|
|
2357
|
+
tone: "blocked",
|
|
2358
|
+
title: "无法读取这个节点原先保存的提示词",
|
|
2359
|
+
description: "当前不能安全预览或修改提示词。可以继续使用最下方的上下文导出。",
|
|
2360
|
+
}),
|
|
2361
|
+
);
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
const frozenBasePrompt =
|
|
2365
|
+
typeof input.body.prompt?.text === "string" ? input.body.prompt.text : "";
|
|
2366
|
+
if (!frozenBasePrompt) {
|
|
2367
|
+
promptBody.appendChild(
|
|
2368
|
+
buildDagActionAvailability({
|
|
2369
|
+
title: "这个节点没有保存原始提示词",
|
|
2370
|
+
description: "因此不能从这里修改提示词重跑。",
|
|
2371
|
+
}),
|
|
2372
|
+
);
|
|
2373
|
+
return;
|
|
2374
|
+
}
|
|
2375
|
+
const promptCandidateOptions = buildPromptRestartCandidateOptions(
|
|
2376
|
+
frozenBasePrompt,
|
|
2377
|
+
input.body.promptCandidates,
|
|
2378
|
+
);
|
|
2379
|
+
let selectedCandidate = promptCandidateOptions[0];
|
|
2380
|
+
const historicalCandidatesMissing = Array.isArray(input.body.warnings)
|
|
2381
|
+
? input.body.warnings.some((warning) =>
|
|
2382
|
+
String(warning).startsWith(
|
|
2383
|
+
"Failed prompt candidate missing for attempt ",
|
|
2384
|
+
),
|
|
2385
|
+
)
|
|
2386
|
+
: false;
|
|
2387
|
+
|
|
2388
|
+
if (node.status !== "ERROR") {
|
|
2389
|
+
// Non-failed nodes still show their frozen prompt — read-only.
|
|
2390
|
+
const panel = el("div", "prompt-restart-panel is-readonly");
|
|
2391
|
+
panel.appendChild(
|
|
2392
|
+
createPromptRestartBanner({
|
|
2393
|
+
tone: "readonly",
|
|
2394
|
+
kicker: "只读",
|
|
2395
|
+
title: `当前节点:${inspectorValueLabel("status", node.status ?? "unknown")}`,
|
|
2396
|
+
body: "只有执行失败的节点支持编辑提示词并重启。下面可以查看原始提示词,以及历次失败时实际使用的提示词。",
|
|
2397
|
+
}),
|
|
2398
|
+
);
|
|
2399
|
+
const promptCard = createPromptRestartPromptCard({
|
|
2400
|
+
title: "运行开始前保存的提示词",
|
|
2401
|
+
badge: "只读",
|
|
2402
|
+
readCandidate: () => selectedCandidate,
|
|
2403
|
+
preTestId: "prompt-restart-readonly",
|
|
2404
|
+
});
|
|
2405
|
+
const picker = createPromptRestartCandidatePicker({
|
|
2406
|
+
options: promptCandidateOptions,
|
|
2407
|
+
value: selectedCandidate.key,
|
|
2408
|
+
label: "提示词版本(只读)",
|
|
2409
|
+
hint:
|
|
2410
|
+
promptCandidateOptions.length === 1
|
|
2411
|
+
? historicalCandidatesMissing
|
|
2412
|
+
? "这个较早的运行没有保存失败时实际使用的提示词;新运行会在这里列出。"
|
|
2413
|
+
: "该节点没有保存过失败时使用的提示词。"
|
|
2414
|
+
: "可以切换查看原始版本和历次失败时使用的版本。",
|
|
2415
|
+
onChange: (nextKey) => {
|
|
2416
|
+
selectedCandidate =
|
|
2417
|
+
promptCandidateOptions.find((option) => option.key === nextKey) ??
|
|
2418
|
+
promptCandidateOptions[0];
|
|
2419
|
+
promptCard.sync(selectedCandidate);
|
|
2420
|
+
},
|
|
2421
|
+
});
|
|
2422
|
+
panel.appendChild(picker.field);
|
|
2423
|
+
panel.appendChild(promptCard.card);
|
|
2424
|
+
promptBody.appendChild(panel);
|
|
2425
|
+
return;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
if (input.body.prompt?.truncated === true) {
|
|
2429
|
+
promptBody.appendChild(
|
|
2430
|
+
buildDagActionAvailability({
|
|
2431
|
+
tone: "blocked",
|
|
2432
|
+
title: "保存的提示词不完整,无法安全编辑",
|
|
2433
|
+
description:
|
|
2434
|
+
"为避免用截断文本覆盖完整提示,请改用 CLI:dag rerun --prompt-override。",
|
|
2435
|
+
}),
|
|
2436
|
+
);
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
const box = el("div", "prompt-restart-box prompt-restart-panel is-edit");
|
|
2441
|
+
box.appendChild(
|
|
2442
|
+
createPromptRestartBanner({
|
|
2443
|
+
tone: "edit",
|
|
2444
|
+
kicker: "可编辑",
|
|
2445
|
+
title: "从失败节点编辑提示词并重启",
|
|
2446
|
+
body: "原运行的设置和记录保持不变;系统会另建一次使用新提示词的运行。",
|
|
2447
|
+
}),
|
|
2448
|
+
);
|
|
2449
|
+
const promptCard = createPromptRestartPromptCard({
|
|
2450
|
+
title: `原始提示词(只读 · ${nodeId})`,
|
|
2451
|
+
badge: "底稿",
|
|
2452
|
+
readCandidate: () => selectedCandidate,
|
|
2453
|
+
preTestId: "prompt-restart-base",
|
|
2454
|
+
collapsible: true,
|
|
2455
|
+
startCollapsed: true,
|
|
2456
|
+
});
|
|
2457
|
+
const picker = createPromptRestartCandidatePicker({
|
|
2458
|
+
options: promptCandidateOptions,
|
|
2459
|
+
value: selectedCandidate.key,
|
|
2460
|
+
label: "提示词版本",
|
|
2461
|
+
hint:
|
|
2462
|
+
promptCandidateOptions.length > 1
|
|
2463
|
+
? "选择某次失败使用的版本后,会载入完整文本供你修改;原始提示词仍可选择只追加补充说明。"
|
|
2464
|
+
: historicalCandidatesMissing
|
|
2465
|
+
? "这个较早的运行没有保存失败时实际使用的提示词;新运行会在这里列出。"
|
|
2466
|
+
: "该节点没有保存过失败时使用的提示词;当前只有原始提示词。",
|
|
2467
|
+
onChange: (nextKey) => {
|
|
2468
|
+
selectedCandidate =
|
|
2469
|
+
promptCandidateOptions.find((option) => option.key === nextKey) ??
|
|
2470
|
+
promptCandidateOptions[0];
|
|
2471
|
+
promptCard.sync(selectedCandidate);
|
|
2472
|
+
replaceArea.value = selectedCandidate.prompt;
|
|
2473
|
+
if (selectedCandidate.key !== "frozen") {
|
|
2474
|
+
modeSelect.value = "replace";
|
|
2475
|
+
}
|
|
2476
|
+
picker.hintEl.hidden = false;
|
|
2477
|
+
picker.hintEl.textContent = selectedCandidate.truncated
|
|
2478
|
+
? "该候选已截断,仅供查看,不能直接提交重启。"
|
|
2479
|
+
: selectedCandidate.key === "frozen"
|
|
2480
|
+
? "原始提示词可以选择追加说明,也可以全文替换。"
|
|
2481
|
+
: "已载入这次失败时使用的提示词;修改完整文本后即可重启。";
|
|
2482
|
+
applyModeVisibility();
|
|
2483
|
+
},
|
|
2484
|
+
});
|
|
2485
|
+
const modeSwitch = createPromptRestartModeSwitch({
|
|
2486
|
+
value: "append",
|
|
2487
|
+
onChange: () => applyModeVisibility(),
|
|
2488
|
+
});
|
|
2489
|
+
const modeSelect = modeSwitch.group;
|
|
2490
|
+
const toolbar = el("div", "prompt-restart-toolbar");
|
|
2491
|
+
toolbar.appendChild(picker.field);
|
|
2492
|
+
toolbar.appendChild(modeSwitch.field);
|
|
2493
|
+
box.appendChild(toolbar);
|
|
2494
|
+
|
|
2495
|
+
const addendumLabel = el("label", "prompt-restart-field prompt-restart-work");
|
|
2496
|
+
addendumLabel.appendChild(
|
|
2497
|
+
el("span", "prompt-restart-label", "追加指令"),
|
|
2498
|
+
);
|
|
2499
|
+
addendumLabel.appendChild(
|
|
2500
|
+
el(
|
|
2501
|
+
"p",
|
|
2502
|
+
"prompt-restart-hint",
|
|
2503
|
+
"这段补充会加在原提示词末尾,不会改写原文(内部记录为 operator_addendum)。",
|
|
2504
|
+
),
|
|
2505
|
+
);
|
|
2506
|
+
const addendumArea = document.createElement("textarea");
|
|
2507
|
+
addendumArea.className = "prompt-restart-textarea prompt-restart-textarea-work";
|
|
2508
|
+
addendumArea.rows = 8;
|
|
2509
|
+
addendumArea.placeholder = "例如:重点检查 X 边界;输出前先自检 Y 约束…";
|
|
2510
|
+
addendumArea.setAttribute("data-testid", "prompt-restart-addendum");
|
|
2511
|
+
addendumLabel.appendChild(addendumArea);
|
|
2512
|
+
box.appendChild(addendumLabel);
|
|
2513
|
+
|
|
2514
|
+
const replaceLabel = el("label", "prompt-restart-field prompt-restart-work");
|
|
2515
|
+
replaceLabel.appendChild(
|
|
2516
|
+
el("span", "prompt-restart-label", `完整提示词(${nodeId})`),
|
|
2517
|
+
);
|
|
2518
|
+
const replaceArea = document.createElement("textarea");
|
|
2519
|
+
replaceArea.className = "prompt-restart-textarea prompt-restart-textarea-work";
|
|
2520
|
+
replaceArea.rows = 12;
|
|
2521
|
+
replaceArea.value = selectedCandidate.prompt;
|
|
2522
|
+
replaceArea.setAttribute("data-testid", "prompt-restart-textarea");
|
|
2523
|
+
replaceLabel.appendChild(replaceArea);
|
|
2524
|
+
box.appendChild(replaceLabel);
|
|
2525
|
+
|
|
2526
|
+
const baseLabel = promptCard.card;
|
|
2527
|
+
box.appendChild(baseLabel);
|
|
2528
|
+
|
|
2529
|
+
const applyModeVisibility = () => {
|
|
2530
|
+
const append = modeSelect.value === "append";
|
|
2531
|
+
baseLabel.classList.toggle("is-hidden", !append);
|
|
2532
|
+
addendumLabel.classList.toggle("is-hidden", !append);
|
|
2533
|
+
replaceLabel.classList.toggle("is-hidden", append);
|
|
2534
|
+
};
|
|
2535
|
+
applyModeVisibility();
|
|
2536
|
+
|
|
2537
|
+
const reasonLabel = el("label", "prompt-restart-field");
|
|
2538
|
+
reasonLabel.appendChild(el("span", "prompt-restart-label", "为什么要重启?"));
|
|
2539
|
+
reasonLabel.appendChild(
|
|
2540
|
+
el("p", "prompt-restart-hint", "这段说明会随新运行一起保存,方便以后追溯。"),
|
|
2541
|
+
);
|
|
2542
|
+
const reasonArea = document.createElement("textarea");
|
|
2543
|
+
reasonArea.className = "prompt-restart-textarea prompt-restart-textarea-compact";
|
|
2544
|
+
reasonArea.rows = 3;
|
|
2545
|
+
reasonArea.value = `修改失败节点 ${nodeId} 的提示词后重新运行(来源运行:${dagRunId})`;
|
|
2546
|
+
reasonArea.setAttribute("data-testid", "prompt-restart-reason");
|
|
2547
|
+
reasonLabel.appendChild(reasonArea);
|
|
2548
|
+
box.appendChild(reasonLabel);
|
|
2549
|
+
|
|
2550
|
+
const row = el("div", "prompt-restart-actions prompt-restart-footer");
|
|
2551
|
+
const status = el("p", "prompt-restart-status", "");
|
|
2552
|
+
status.setAttribute("role", "status");
|
|
2553
|
+
status.setAttribute("aria-live", "polite");
|
|
2554
|
+
const submit = document.createElement("button");
|
|
2555
|
+
submit.type = "button";
|
|
2556
|
+
submit.className = "prompt-restart-submit";
|
|
2557
|
+
submit.textContent = "检查是否可重跑并开始";
|
|
2558
|
+
submit.setAttribute("data-testid", "prompt-restart-submit");
|
|
2559
|
+
row.appendChild(status);
|
|
2560
|
+
row.appendChild(submit);
|
|
2561
|
+
box.appendChild(row);
|
|
2562
|
+
|
|
2563
|
+
promptBody.appendChild(box);
|
|
2564
|
+
|
|
2565
|
+
const setStatus = (text, isError = false) => {
|
|
2566
|
+
status.textContent = text ?? "";
|
|
2567
|
+
status.classList.toggle("prompt-restart-error", isError);
|
|
2568
|
+
};
|
|
2569
|
+
|
|
2570
|
+
submit.addEventListener("click", () => {
|
|
2571
|
+
void (async () => {
|
|
2572
|
+
if (selectedCandidate.truncated) {
|
|
2573
|
+
setStatus("所选失败提示词已截断,不能作为完整提示词重启。", true);
|
|
2574
|
+
return;
|
|
2575
|
+
}
|
|
2576
|
+
const mode = modeSelect.value === "replace" ? "replace" : "append";
|
|
2577
|
+
const prompt = mode === "append" ? addendumArea.value : replaceArea.value;
|
|
2578
|
+
const reason = reasonArea.value.trim();
|
|
2579
|
+
if (!prompt.trim()) {
|
|
2580
|
+
setStatus(
|
|
2581
|
+
mode === "append" ? "追加指令不能为空。" : "提示词不能为空。",
|
|
2582
|
+
true,
|
|
2583
|
+
);
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
2586
|
+
if (
|
|
2587
|
+
mode === "replace" &&
|
|
2588
|
+
selectedCandidate.key === "frozen" &&
|
|
2589
|
+
prompt === frozenBasePrompt
|
|
2590
|
+
) {
|
|
2591
|
+
setStatus("提示词未修改;如需按原提示词重跑请使用恢复工作台。", true);
|
|
2592
|
+
return;
|
|
2593
|
+
}
|
|
2594
|
+
if (!reason) {
|
|
2595
|
+
setStatus("需要填写重启原因。", true);
|
|
2596
|
+
return;
|
|
2597
|
+
}
|
|
2598
|
+
submit.disabled = true;
|
|
2599
|
+
try {
|
|
2600
|
+
setStatus("正在检查这次重跑是否安全可行…");
|
|
2601
|
+
const overrides = [{ nodeId, prompt, mode }];
|
|
2602
|
+
const planRes = await postOperatorAction("dagRerunPlan", {
|
|
2603
|
+
runId: dagRunId,
|
|
2604
|
+
fromNode: nodeId,
|
|
2605
|
+
promptOverrides: overrides,
|
|
2606
|
+
});
|
|
2607
|
+
const plan = planRes.body?.result ?? null;
|
|
2608
|
+
if (!planRes.ok || plan?.eligible !== true || !plan?.planHash) {
|
|
2609
|
+
setStatus(
|
|
2610
|
+
planRes.body?.error?.message ??
|
|
2611
|
+
formatContextTransferReasonList(plan?.blockedReasons) ??
|
|
2612
|
+
"资格预检未通过。",
|
|
2613
|
+
true,
|
|
2614
|
+
);
|
|
2615
|
+
return;
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
const est = plan.estimatedExecution;
|
|
2619
|
+
const estText = est
|
|
2620
|
+
? `(将执行 ${est.nodeCount ?? "?"} 个节点,其中 ${est.piCallCount ?? "?"} 个需要 AI 处理)`
|
|
2621
|
+
: "";
|
|
2622
|
+
setStatus(`检查通过${estText},正在创建新运行…`);
|
|
2623
|
+
const clientRequestId = `inspect-prompt-restart-${Date.now()}-${Math.random()
|
|
2624
|
+
.toString(36)
|
|
2625
|
+
.slice(2, 10)}`;
|
|
2626
|
+
const runRes = await postOperatorAction(
|
|
2627
|
+
"dagRerun",
|
|
2628
|
+
{
|
|
2629
|
+
runId: dagRunId,
|
|
2630
|
+
fromNode: nodeId,
|
|
2631
|
+
planHash: plan.planHash,
|
|
2632
|
+
reason,
|
|
2633
|
+
promptOverrides: overrides,
|
|
2634
|
+
},
|
|
2635
|
+
clientRequestId,
|
|
2636
|
+
);
|
|
2637
|
+
const operationId = runRes.body?.operationId;
|
|
2638
|
+
if (!runRes.ok || !operationId) {
|
|
2639
|
+
setStatus(runRes.body?.error?.message ?? "提交续跑失败。", true);
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
const op = await pollOperationToTerminal(operationId, (text) =>
|
|
2644
|
+
setStatus(text),
|
|
2645
|
+
);
|
|
2646
|
+
if (op?.state === "succeeded") {
|
|
2647
|
+
const newRunId =
|
|
2648
|
+
op.dagRunId ?? op.result?.newRunId ?? op.runSummary?.runId ?? null;
|
|
2649
|
+
if (newRunId) {
|
|
2650
|
+
setStatus(`重启完成,新运行:${newRunId}`);
|
|
2651
|
+
const open = document.createElement("button");
|
|
2652
|
+
open.type = "button";
|
|
2653
|
+
open.className = "prompt-restart-submit is-secondary";
|
|
2654
|
+
open.textContent = "打开新运行";
|
|
2655
|
+
open.addEventListener("click", () => {
|
|
2656
|
+
navigate(`/dag/${encodeURIComponent(String(newRunId))}`);
|
|
2657
|
+
});
|
|
2658
|
+
row.appendChild(open);
|
|
2659
|
+
} else {
|
|
2660
|
+
setStatus("重启完成(暂时无法取得新运行编号,请在 DAG 历史中查看)。");
|
|
2661
|
+
}
|
|
2662
|
+
} else if (op) {
|
|
2663
|
+
setStatus(
|
|
2664
|
+
`新运行最终状态:${inspectorValueLabel("status", op.state)}${op.errorMessage ? ` — ${op.errorMessage}` : ""}`,
|
|
2665
|
+
true,
|
|
2666
|
+
);
|
|
2667
|
+
} else {
|
|
2668
|
+
setStatus("等待超时:操作仍在运行,可在操作台查看进度。", true);
|
|
2669
|
+
}
|
|
2670
|
+
} catch (err) {
|
|
2671
|
+
setStatus(err instanceof Error ? err.message : String(err), true);
|
|
2672
|
+
} finally {
|
|
2673
|
+
submit.disabled = false;
|
|
2674
|
+
}
|
|
2675
|
+
})();
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
/** Poll a Console operation until a terminal state; null on poll budget end. */
|
|
2680
|
+
async function pollOperationToTerminal(operationId, onProgress) {
|
|
2681
|
+
const terminal = new Set([
|
|
2682
|
+
"succeeded",
|
|
2683
|
+
"failed",
|
|
2684
|
+
"timed-out",
|
|
2685
|
+
"needs-reconcile",
|
|
2686
|
+
]);
|
|
2687
|
+
for (let attempt = 0; attempt < 1200; attempt += 1) {
|
|
2688
|
+
const res = await fetchOperatorOperation(operationId);
|
|
2689
|
+
const op = res.body?.operation ?? res.body;
|
|
2690
|
+
const state = op?.state ?? "";
|
|
2691
|
+
if (res.ok && terminal.has(state)) {
|
|
2692
|
+
return op;
|
|
2693
|
+
}
|
|
2694
|
+
onProgress(`续跑执行中…(${state || "queued"})`);
|
|
2695
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
2696
|
+
}
|
|
2697
|
+
return null;
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
function transparencyMetaList(rows) {
|
|
2701
|
+
const dl = el("dl", "node-input-summary node-transparency-summary");
|
|
2702
|
+
for (const [label, value] of rows) {
|
|
2703
|
+
if (value == null || value === "") continue;
|
|
2704
|
+
appendMetaRow(dl, label, value, null);
|
|
2705
|
+
}
|
|
2706
|
+
return dl;
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
function renderNodeOverview(content, dagRunId, node) {
|
|
2710
|
+
const root = el("div", "node-transparency-root");
|
|
2711
|
+
root.appendChild(buildInspectorPageLead("overview"));
|
|
2712
|
+
root.appendChild(
|
|
2713
|
+
el("p", "node-input-semantics", "这里展示系统为当前运行保存的真实记录;字段已转换为易懂名称,悬停可查看原始技术字段。"),
|
|
2714
|
+
);
|
|
2715
|
+
const summary = el("section", "node-input-section");
|
|
2716
|
+
summary.appendChild(el("h4", null, "节点事实"));
|
|
2717
|
+
summary.appendChild(
|
|
2718
|
+
transparencyMetaList([
|
|
2719
|
+
["run", dagRunId],
|
|
2720
|
+
["node", node.nodeId],
|
|
2721
|
+
["status", node.status ?? "unknown"],
|
|
2722
|
+
["executor", node.executor ?? "unknown"],
|
|
2723
|
+
["model", node.model ?? null],
|
|
2724
|
+
["rank", node.rank ?? null],
|
|
2725
|
+
["origin", node.originKind ?? "unknown"],
|
|
2726
|
+
["duration", node.durationMs != null ? formatMs(node.durationMs) : null],
|
|
2727
|
+
]),
|
|
2728
|
+
);
|
|
2729
|
+
root.appendChild(summary);
|
|
2730
|
+
const semantics = el("section", "node-input-section");
|
|
2731
|
+
semantics.appendChild(el("h4", null, "这些信息分别在什么时候产生"));
|
|
2732
|
+
semantics.appendChild(
|
|
2733
|
+
el(
|
|
2734
|
+
"p",
|
|
2735
|
+
"muted",
|
|
2736
|
+
"“执行设置”是运行开始前保存的配置;“实际上下文”是下发任务时真正交给节点的内容;“产出”是执行结束后保存的文件。缺少哪个阶段会明确显示,预览内容不会被当成已经发生的事实。",
|
|
2737
|
+
),
|
|
2738
|
+
);
|
|
2739
|
+
root.appendChild(semantics);
|
|
2740
|
+
content.appendChild(root);
|
|
2741
|
+
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "overview");
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
function selectedAttemptNumber(dagRunId, node) {
|
|
2745
|
+
const key = effectiveExecutionKey(dagRunId, node);
|
|
2746
|
+
const match = /^attempt-(\d+)$/.exec(key ?? "");
|
|
2747
|
+
return match ? Number(match[1]) : undefined;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
async function renderEffectiveContext(content, dagRunId, node) {
|
|
2751
|
+
ensureInspectorPageLead(content, "context");
|
|
2752
|
+
content.appendChild(el("p", "muted", "正在加载有效上下文事实…"));
|
|
2753
|
+
const result = await fetchDagNodeContext(
|
|
2754
|
+
dagRunId,
|
|
2755
|
+
node.nodeId,
|
|
2756
|
+
selectedAttemptNumber(dagRunId, node),
|
|
2757
|
+
);
|
|
2758
|
+
if (
|
|
2759
|
+
!content.isConnected ||
|
|
2760
|
+
content.dataset.dagRunId !== String(dagRunId) ||
|
|
2761
|
+
content.dataset.dagNodeId !== String(node.nodeId) ||
|
|
2762
|
+
activeInspectorTab() !== "context"
|
|
2763
|
+
)
|
|
2764
|
+
return;
|
|
2765
|
+
clearNode(content);
|
|
2766
|
+
ensureInspectorPageLead(content, "context");
|
|
2767
|
+
if (!result.ok || !result.body) {
|
|
2768
|
+
const error = el(
|
|
2769
|
+
"p",
|
|
2770
|
+
"node-input-error",
|
|
2771
|
+
result.body?.error || "无法加载有效上下文事实。",
|
|
2772
|
+
);
|
|
2773
|
+
error.setAttribute("role", "alert");
|
|
2774
|
+
content.appendChild(error);
|
|
2775
|
+
return;
|
|
2776
|
+
}
|
|
2777
|
+
const data = result.body;
|
|
2778
|
+
const receipt = data.effectiveContext;
|
|
2779
|
+
const root = el("div", "node-transparency-root");
|
|
2780
|
+
root.appendChild(
|
|
2781
|
+
transparencyMetaList([
|
|
2782
|
+
["attempt", data.attempt],
|
|
2783
|
+
["declared", data.declared?.status],
|
|
2784
|
+
["dispatched", data.dispatched?.status],
|
|
2785
|
+
["node status", data.dispatched?.nodeStatus],
|
|
2786
|
+
]),
|
|
2787
|
+
);
|
|
2788
|
+
if (receipt?.status !== "captured") {
|
|
2789
|
+
const missing = el("div", "node-transparency-omission");
|
|
2790
|
+
const reasonCode = receipt?.reasonCode ?? "CONTEXT_RECEIPT_MISSING";
|
|
2791
|
+
const missingLabel = contextTransferReasonLabel(reasonCode);
|
|
2792
|
+
missing.appendChild(
|
|
2793
|
+
el(
|
|
2794
|
+
"h4",
|
|
2795
|
+
null,
|
|
2796
|
+
receipt?.status === "invalid" ? "执行时记录不可用" : "没有执行时记录",
|
|
2797
|
+
),
|
|
2798
|
+
);
|
|
2799
|
+
const reason = el("p", "muted", missingLabel ?? reasonCode);
|
|
2800
|
+
if (missingLabel) reason.setAttribute("title", `技术代码:${reasonCode}`);
|
|
2801
|
+
missing.appendChild(reason);
|
|
2802
|
+
missing.appendChild(
|
|
2803
|
+
el(
|
|
2804
|
+
"p",
|
|
2805
|
+
"muted",
|
|
2806
|
+
"当前只有运行前设置和提示内容校验码,无法证明执行时真正收到了哪些内容。较早的运行不会事后补写这份记录。",
|
|
2807
|
+
),
|
|
2808
|
+
);
|
|
2809
|
+
root.appendChild(missing);
|
|
2810
|
+
} else {
|
|
2811
|
+
const captured = el("section", "node-input-section");
|
|
2812
|
+
captured.appendChild(el("h4", null, "这次执行实际收到的内容"));
|
|
2813
|
+
captured.appendChild(
|
|
2814
|
+
transparencyMetaList([
|
|
2815
|
+
["context digest", receipt.contextDigest],
|
|
2816
|
+
["captured at", receipt.capturedAt],
|
|
2817
|
+
["components", receipt.componentCount],
|
|
2818
|
+
["truncations", receipt.truncationCount],
|
|
2819
|
+
["executor", receipt.runtime?.executor],
|
|
2820
|
+
["model", receipt.runtime?.model],
|
|
2821
|
+
["skills", receipt.runtime?.skillCount],
|
|
2822
|
+
["extensions", receipt.runtime?.extensionCount],
|
|
2823
|
+
["tools", receipt.runtime?.toolCount],
|
|
2824
|
+
]),
|
|
2825
|
+
);
|
|
2826
|
+
appendCodeList(
|
|
2827
|
+
captured,
|
|
2828
|
+
"组件类型",
|
|
2829
|
+
Object.entries(receipt.componentKinds ?? {}).map(
|
|
2830
|
+
([kind, count]) => `${kind}: ${count}`,
|
|
2831
|
+
),
|
|
2832
|
+
);
|
|
2833
|
+
appendCodeList(
|
|
2834
|
+
captured,
|
|
2835
|
+
"包含状态",
|
|
2836
|
+
Object.entries(receipt.inclusionCounts ?? {}).map(
|
|
2837
|
+
([kind, count]) => `${kind}: ${count}`,
|
|
2838
|
+
),
|
|
2839
|
+
);
|
|
2840
|
+
root.appendChild(captured);
|
|
2841
|
+
}
|
|
2842
|
+
content.appendChild(root);
|
|
2843
|
+
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "context");
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
function artifactInventorySection(data, dagRunId, nodeId) {
|
|
2847
|
+
const root = el("section", "node-input-section node-artifact-inventory");
|
|
2848
|
+
root.appendChild(el("h4", null, "本节点生成和使用的文件"));
|
|
2849
|
+
if (!data?.binding?.available) {
|
|
2850
|
+
const warning = el("div", "node-transparency-omission");
|
|
2851
|
+
const bindingCode =
|
|
2852
|
+
data?.binding?.reasonCode ?? "ARTIFACT_BINDING_UNAVAILABLE";
|
|
2853
|
+
const bindingLabel = contextTransferReasonLabel(bindingCode);
|
|
2854
|
+
const reason = el("p", "muted", bindingLabel ?? bindingCode);
|
|
2855
|
+
if (bindingLabel) reason.setAttribute("title", `技术代码:${bindingCode}`);
|
|
2856
|
+
warning.appendChild(reason);
|
|
2857
|
+
warning.appendChild(
|
|
2858
|
+
el(
|
|
2859
|
+
"p",
|
|
2860
|
+
"muted",
|
|
2861
|
+
"这个较早的运行没有保存明确的文件使用关系;系统不会根据提示词、输出要求或文件名猜测谁会使用它。",
|
|
2862
|
+
),
|
|
2863
|
+
);
|
|
2864
|
+
root.appendChild(warning);
|
|
2865
|
+
return root;
|
|
2866
|
+
}
|
|
2867
|
+
root.appendChild(
|
|
2868
|
+
transparencyMetaList([
|
|
2869
|
+
["origin", data.origin?.kind ?? "unknown"],
|
|
2870
|
+
["parent", data.origin?.parentRunId ?? null],
|
|
2871
|
+
["graph sha256", data.binding.artifactGraphSha256],
|
|
2872
|
+
]),
|
|
2873
|
+
);
|
|
2874
|
+
for (const artifact of data.produces ?? []) {
|
|
2875
|
+
const card = el("div", "node-artifact-card");
|
|
2876
|
+
card.appendChild(el("h5", null, artifact.artifactId));
|
|
2877
|
+
card.appendChild(
|
|
2878
|
+
transparencyMetaList([
|
|
2879
|
+
["path", artifact.path],
|
|
2880
|
+
["media", artifact.mediaType],
|
|
2881
|
+
["schema", artifact.schemaId ?? null],
|
|
2882
|
+
["materialization", artifact.materialization?.status],
|
|
2883
|
+
["bytes", artifact.materialization?.bytes],
|
|
2884
|
+
["origin", artifact.origin?.kind],
|
|
2885
|
+
["revision", artifact.origin?.revisionId],
|
|
2886
|
+
["supersedes", artifact.origin?.supersedes],
|
|
2887
|
+
[
|
|
2888
|
+
"revision",
|
|
2889
|
+
artifact.revision?.eligible
|
|
2890
|
+
? "eligible"
|
|
2891
|
+
: (contextTransferReasonLabel(artifact.revision?.reasonCode) ??
|
|
2892
|
+
artifact.revision?.reasonCode ??
|
|
2893
|
+
"blocked"),
|
|
2894
|
+
],
|
|
2895
|
+
]),
|
|
2896
|
+
);
|
|
2897
|
+
appendCodeList(
|
|
2898
|
+
card,
|
|
2899
|
+
"会直接使用此文件的节点",
|
|
2900
|
+
artifact.directConsumerNodeIds ?? [],
|
|
2901
|
+
);
|
|
2902
|
+
if (artifact.materialization?.status === "materialized") {
|
|
2903
|
+
card.appendChild(
|
|
2904
|
+
createArtifactContentPreview(dagRunId, nodeId, () => artifact, {
|
|
2905
|
+
testId: `${ARTIFACT_FILE_PREVIEW_SURFACES.produced}-${artifact.artifactId}`,
|
|
2906
|
+
}).element,
|
|
2907
|
+
);
|
|
2908
|
+
}
|
|
2909
|
+
root.appendChild(card);
|
|
2910
|
+
}
|
|
2911
|
+
for (const artifact of data.consumes ?? []) {
|
|
2912
|
+
const card = el("div", "node-artifact-card is-consumed");
|
|
2913
|
+
card.appendChild(el("h5", null, `使用 ${artifact.artifactId}`));
|
|
2914
|
+
card.appendChild(
|
|
2915
|
+
transparencyMetaList([
|
|
2916
|
+
["producer", artifact.producerNodeId],
|
|
2917
|
+
["path", artifact.path],
|
|
2918
|
+
["required", artifact.required ? "yes" : "no"],
|
|
2919
|
+
]),
|
|
2920
|
+
);
|
|
2921
|
+
card.appendChild(
|
|
2922
|
+
createArtifactContentPreview(dagRunId, nodeId, () => artifact, {
|
|
2923
|
+
testId: `${ARTIFACT_FILE_PREVIEW_SURFACES.consumed}-${artifact.artifactId}`,
|
|
2924
|
+
}).element,
|
|
2925
|
+
);
|
|
2926
|
+
root.appendChild(card);
|
|
2927
|
+
}
|
|
2928
|
+
if (
|
|
2929
|
+
(data.produces ?? []).length === 0 &&
|
|
2930
|
+
(data.consumes ?? []).length === 0
|
|
2931
|
+
) {
|
|
2932
|
+
root.appendChild(el("p", "empty", "该节点没有登记会生成或使用的文件。"));
|
|
2933
|
+
}
|
|
2934
|
+
return root;
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2937
|
+
async function prependArtifactInventory(content, dagRunId, node) {
|
|
2938
|
+
const result = await fetchDagNodeArtifacts(dagRunId, node.nodeId);
|
|
2939
|
+
if (
|
|
2940
|
+
!content.isConnected ||
|
|
2941
|
+
content.dataset.dagRunId !== String(dagRunId) ||
|
|
2942
|
+
content.dataset.dagNodeId !== String(node.nodeId) ||
|
|
2943
|
+
activeInspectorTab() !== "output"
|
|
2944
|
+
)
|
|
2945
|
+
return;
|
|
2946
|
+
const section =
|
|
2947
|
+
result.ok && result.body
|
|
2948
|
+
? artifactInventorySection(result.body, dagRunId, node.nodeId)
|
|
2949
|
+
: el(
|
|
2950
|
+
"p",
|
|
2951
|
+
"node-input-error node-artifact-inventory",
|
|
2952
|
+
result.body?.error || "无法加载产物绑定事实。",
|
|
2953
|
+
);
|
|
2954
|
+
const lead = content.querySelector(".inspector-page-lead");
|
|
2955
|
+
content.insertBefore(section, lead?.nextSibling ?? content.firstChild);
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
async function renderRunLineage(content, dagRunId, node) {
|
|
2959
|
+
ensureInspectorPageLead(content, "lineage");
|
|
2960
|
+
content.appendChild(el("p", "muted", "正在加载来源与影响关系…"));
|
|
2961
|
+
const result = await fetchDagRunLineage(dagRunId);
|
|
2962
|
+
if (
|
|
2963
|
+
!content.isConnected ||
|
|
2964
|
+
content.dataset.dagRunId !== String(dagRunId) ||
|
|
2965
|
+
content.dataset.dagNodeId !== String(node.nodeId) ||
|
|
2966
|
+
activeInspectorTab() !== "lineage"
|
|
2967
|
+
)
|
|
2968
|
+
return;
|
|
2969
|
+
clearNode(content);
|
|
2970
|
+
ensureInspectorPageLead(content, "lineage");
|
|
2971
|
+
if (!result.ok || !result.body) {
|
|
2972
|
+
content.appendChild(
|
|
2973
|
+
el("p", "node-input-error", result.body?.error || "无法加载来源与影响关系。"),
|
|
2974
|
+
);
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
const data = result.body;
|
|
2978
|
+
const root = el("div", "node-transparency-root");
|
|
2979
|
+
root.appendChild(
|
|
2980
|
+
transparencyMetaList([
|
|
2981
|
+
["运行类型", data.kind === "root" ? "首次运行" : "派生运行"],
|
|
2982
|
+
["来源运行", data.parentRunId ?? null],
|
|
2983
|
+
["发起方式", inspectorValueLabel("发起方式", data.trigger)],
|
|
2984
|
+
["人工选择节点", data.operatorSelectedNodeId ?? null],
|
|
2985
|
+
["从此节点重新执行", data.effectiveFromNodeId ?? null],
|
|
2986
|
+
["重跑计划哈希", data.planHash ?? null],
|
|
2987
|
+
]),
|
|
2988
|
+
);
|
|
2989
|
+
appendCodeList(root, "沿用既有结果的节点", data.importedNodeIds ?? []);
|
|
2990
|
+
appendCodeList(root, "替换结果的节点", data.overriddenNodeIds ?? []);
|
|
2991
|
+
if (data.kind === "root")
|
|
2992
|
+
root.appendChild(
|
|
2993
|
+
el("p", "muted", "这是首次运行,没有来源运行。"),
|
|
2994
|
+
);
|
|
2995
|
+
content.appendChild(root);
|
|
2996
|
+
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "lineage");
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
function activeInspectorTab() {
|
|
3000
|
+
return [
|
|
3001
|
+
"overview",
|
|
3002
|
+
"input",
|
|
3003
|
+
"context",
|
|
3004
|
+
"timeline",
|
|
3005
|
+
"output",
|
|
3006
|
+
"lineage",
|
|
3007
|
+
"spec-evidence",
|
|
3008
|
+
"prompt-restart",
|
|
3009
|
+
].includes(uiState.dagInspectorTab)
|
|
3010
|
+
? uiState.dagInspectorTab
|
|
3011
|
+
: "output";
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
function saveInspectorContentScroll(
|
|
3015
|
+
content,
|
|
3016
|
+
dagRunId,
|
|
3017
|
+
nodeId,
|
|
3018
|
+
tab,
|
|
3019
|
+
options = {},
|
|
3020
|
+
) {
|
|
3021
|
+
if (!content) return null;
|
|
3022
|
+
const regionKey = inspectorViewportRegionKey(dagRunId, nodeId, tab);
|
|
3023
|
+
const saved = saveDagInspectorViewportState(
|
|
3024
|
+
regionKey,
|
|
3025
|
+
content.scrollLeft,
|
|
3026
|
+
content.scrollTop,
|
|
3027
|
+
options,
|
|
3028
|
+
);
|
|
3029
|
+
if (tab === "input") {
|
|
3030
|
+
uiState.dagNodeInputViewportState = updateDagOutputViewportState(
|
|
3031
|
+
uiState.dagNodeInputViewportState,
|
|
3032
|
+
regionKey,
|
|
3033
|
+
saved?.scrollLeft ?? 0,
|
|
3034
|
+
saved?.scrollTop ?? 0,
|
|
3035
|
+
false,
|
|
3036
|
+
);
|
|
3037
|
+
} else if (tab === "output") {
|
|
3038
|
+
const followLatest = computeFollowLatest(
|
|
3039
|
+
content.scrollTop,
|
|
3040
|
+
content.scrollHeight,
|
|
3041
|
+
content.clientHeight,
|
|
3042
|
+
);
|
|
3043
|
+
uiState.dagNodeOutputViewportState = updateDagOutputViewportState(
|
|
3044
|
+
uiState.dagNodeOutputViewportState,
|
|
3045
|
+
regionKey,
|
|
3046
|
+
content.scrollLeft,
|
|
3047
|
+
content.scrollTop,
|
|
3048
|
+
followLatest,
|
|
3049
|
+
);
|
|
3050
|
+
} else if (tab === "spec-evidence") {
|
|
3051
|
+
uiState.dagNodeSpecEvidenceViewportState = saved;
|
|
3052
|
+
}
|
|
3053
|
+
return saved;
|
|
3054
|
+
}
|
|
3055
|
+
|
|
3056
|
+
function restoreInspectorContentScroll(content, dagRunId, nodeId, tab) {
|
|
3057
|
+
if (!content) return;
|
|
3058
|
+
const regionKey = inspectorViewportRegionKey(dagRunId, nodeId, tab);
|
|
3059
|
+
const apply = () => {
|
|
3060
|
+
if (
|
|
3061
|
+
!content.isConnected ||
|
|
3062
|
+
content.dataset.dagNodeId !== String(nodeId ?? "") ||
|
|
3063
|
+
content.dataset.dagRunId !== String(dagRunId ?? "") ||
|
|
3064
|
+
activeInspectorTab() !== tab
|
|
3065
|
+
) {
|
|
3066
|
+
return;
|
|
3067
|
+
}
|
|
3068
|
+
if (tab === "timeline" && uiState.dagTimelineAutoScrollEnabled !== false) {
|
|
3069
|
+
content.scrollLeft = uiState.dagTimelineViewportState?.scrollLeft ?? 0;
|
|
3070
|
+
content.scrollTop = content.scrollHeight;
|
|
3071
|
+
return;
|
|
3072
|
+
}
|
|
3073
|
+
if (tab === "output") {
|
|
3074
|
+
const saved = uiState.dagNodeOutputViewportState;
|
|
3075
|
+
if (saved?.regionKey === regionKey && saved.followLatest) {
|
|
3076
|
+
content.scrollTop = content.scrollHeight;
|
|
3077
|
+
content.scrollLeft = saved.scrollLeft ?? 0;
|
|
3078
|
+
return;
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
const saved =
|
|
3082
|
+
getDagInspectorViewportState(regionKey) ??
|
|
3083
|
+
(tab === "input" &&
|
|
3084
|
+
uiState.dagNodeInputViewportState?.regionKey === regionKey
|
|
3085
|
+
? uiState.dagNodeInputViewportState
|
|
3086
|
+
: null) ??
|
|
3087
|
+
(tab === "output" &&
|
|
3088
|
+
uiState.dagNodeOutputViewportState?.regionKey === regionKey
|
|
3089
|
+
? uiState.dagNodeOutputViewportState
|
|
3090
|
+
: null) ??
|
|
3091
|
+
(tab === "spec-evidence" &&
|
|
3092
|
+
uiState.dagNodeSpecEvidenceViewportState?.regionKey === regionKey
|
|
3093
|
+
? uiState.dagNodeSpecEvidenceViewportState
|
|
3094
|
+
: null);
|
|
3095
|
+
content.scrollLeft = saved?.scrollLeft ?? 0;
|
|
3096
|
+
content.scrollTop = saved?.scrollTop ?? 0;
|
|
3097
|
+
};
|
|
3098
|
+
apply();
|
|
3099
|
+
if (typeof requestAnimationFrame === "function") {
|
|
3100
|
+
requestAnimationFrame(apply);
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3104
|
+
function ensureInspectorContentScrollCapture(content, dagRunId, nodeId, tab) {
|
|
3105
|
+
if (!content || content.dataset.scrollCaptureBound === "1") return;
|
|
3106
|
+
content.dataset.scrollCaptureBound = "1";
|
|
3107
|
+
content.addEventListener(
|
|
3108
|
+
"scroll",
|
|
3109
|
+
() => {
|
|
3110
|
+
const runId = content.dataset.dagRunId;
|
|
3111
|
+
const nId = content.dataset.dagNodeId;
|
|
3112
|
+
const active = activeInspectorTab();
|
|
3113
|
+
if (!runId || !nId || !active) return;
|
|
3114
|
+
saveInspectorContentScroll(content, runId, nId, active, {
|
|
3115
|
+
// Clearing a tall input pane for its loading shell can emit a native
|
|
3116
|
+
// scroll-to-zero event. Preserve the user's prior intent until the
|
|
3117
|
+
// asynchronous content has been restored.
|
|
3118
|
+
preserveIntent:
|
|
3119
|
+
active === "input" && Boolean(uiState.dagNodeInputLoading),
|
|
3120
|
+
});
|
|
3121
|
+
},
|
|
3122
|
+
{ passive: true },
|
|
3123
|
+
);
|
|
3124
|
+
// Touch current context so callers always have a key even before first scroll.
|
|
3125
|
+
saveInspectorContentScroll(content, dagRunId, nodeId, tab, {
|
|
3126
|
+
preserveIntent: true,
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
function attemptPreviewStatus(status) {
|
|
3131
|
+
if (!status) return null;
|
|
3132
|
+
const normalized = String(status).toLowerCase();
|
|
3133
|
+
if (
|
|
3134
|
+
["success", "finished", "completed", "succeeded", "done"].includes(
|
|
3135
|
+
normalized,
|
|
3136
|
+
)
|
|
3137
|
+
) {
|
|
3138
|
+
return { cls: "succeeded", label: "成功" };
|
|
3139
|
+
}
|
|
3140
|
+
if (
|
|
3141
|
+
[
|
|
3142
|
+
"failure",
|
|
3143
|
+
"failed",
|
|
3144
|
+
"error",
|
|
3145
|
+
"partial_failed",
|
|
3146
|
+
"partial-failed",
|
|
3147
|
+
"interrupted",
|
|
3148
|
+
].includes(normalized)
|
|
3149
|
+
) {
|
|
3150
|
+
return { cls: "failed", label: "失败" };
|
|
3151
|
+
}
|
|
3152
|
+
return null;
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
/**
|
|
3156
|
+
* Attempt selector options for a node: per-attempt when attempts>1,
|
|
3157
|
+
* per-pass when convergence passes>1, none otherwise (legacy/single).
|
|
3158
|
+
* 主文案为中文:首次尝试 / 第 N 次尝试 / 初始执行 / 修复轮次 N-1
|
|
3159
|
+
* (AC-001/AC-002);option value 保持 raw attempt-<n>/pass-<n>(AC-003)。
|
|
1068
3160
|
*/
|
|
1069
3161
|
function attemptSelectorOptions(node) {
|
|
1070
3162
|
const summary = node.executionSummary;
|
|
@@ -1214,7 +3306,7 @@ function effectiveExecutionKey(dagRunId, node) {
|
|
|
1214
3306
|
async function fetchExecutionOutput(dagRunId, nodeId, key) {
|
|
1215
3307
|
const url = `/api/dag-runs/${encodeURIComponent(dagRunId)}/nodes/${encodeURIComponent(nodeId)}/execution-output?key=${encodeURIComponent(key)}`;
|
|
1216
3308
|
try {
|
|
1217
|
-
const res = await
|
|
3309
|
+
const res = await fetchWithWorkspaceScope(url);
|
|
1218
3310
|
let body = null;
|
|
1219
3311
|
try {
|
|
1220
3312
|
body = await res.json();
|
|
@@ -1254,7 +3346,7 @@ function appendOutputBody(content, outputText, errorText, options = null) {
|
|
|
1254
3346
|
content.appendChild(el("p", "empty", UI_TEXT.noOutput));
|
|
1255
3347
|
return;
|
|
1256
3348
|
}
|
|
1257
|
-
if (outputText) content.appendChild(
|
|
3349
|
+
if (outputText) content.appendChild(renderInspectorDocument(outputText));
|
|
1258
3350
|
// Truncation note only for full/cached execution-output bodies (AC-003);
|
|
1259
3351
|
// preview path never invents truncated/maxBytes.
|
|
1260
3352
|
if (options?.truncated === true) {
|
|
@@ -1270,7 +3362,7 @@ function appendOutputBody(content, outputText, errorText, options = null) {
|
|
|
1270
3362
|
if (errorText) {
|
|
1271
3363
|
const error = el("section", "markdown-error");
|
|
1272
3364
|
error.appendChild(el("p", "markdown-error-title", "错误输出"));
|
|
1273
|
-
error.appendChild(
|
|
3365
|
+
error.appendChild(renderInspectorDocument(errorText));
|
|
1274
3366
|
content.appendChild(error);
|
|
1275
3367
|
}
|
|
1276
3368
|
}
|
|
@@ -1301,7 +3393,7 @@ function renderCachedOrPreviewBody(content, dagRunId, node, key, isLatest) {
|
|
|
1301
3393
|
}
|
|
1302
3394
|
if (cached && cached.ok === false) {
|
|
1303
3395
|
const message =
|
|
1304
|
-
cached.error || "
|
|
3396
|
+
cached.error || "该次执行输出暂不可用(记录文件缺失或无法读取)。";
|
|
1305
3397
|
const error = el("p", "empty", message);
|
|
1306
3398
|
error.setAttribute("role", "status");
|
|
1307
3399
|
content.appendChild(error);
|
|
@@ -1345,7 +3437,7 @@ async function loadAndRenderExecutionOutput(
|
|
|
1345
3437
|
(result.status === 0
|
|
1346
3438
|
? "加载执行输出失败(网络错误)。"
|
|
1347
3439
|
: result.status === 404
|
|
1348
|
-
? "
|
|
3440
|
+
? "该次执行输出暂不可用(记录文件缺失或无法读取)。"
|
|
1349
3441
|
: `加载执行输出失败(HTTP ${result.status})。`);
|
|
1350
3442
|
// Cache the miss for this key only — never wipe other valid bodies.
|
|
1351
3443
|
setDagNodeExecutionOutputCache(dagRunId, nodeId, key, {
|
|
@@ -1381,8 +3473,10 @@ function repaintOutputTabBody(content, dagRunId, node) {
|
|
|
1381
3473
|
return;
|
|
1382
3474
|
}
|
|
1383
3475
|
// Remove everything after the attempt bar (or all if no bar).
|
|
3476
|
+
const inventory = content.querySelector(".node-artifact-inventory");
|
|
1384
3477
|
const bar = content.querySelector(".dag-inspector-attempt-bar");
|
|
1385
|
-
const
|
|
3478
|
+
const lead = content.querySelector(".inspector-page-lead");
|
|
3479
|
+
const keep = [lead, inventory, bar].filter(Boolean);
|
|
1386
3480
|
while (content.firstChild) content.removeChild(content.firstChild);
|
|
1387
3481
|
for (const nodeEl of keep) content.appendChild(nodeEl);
|
|
1388
3482
|
|
|
@@ -1404,7 +3498,276 @@ function repaintOutputTabBody(content, dagRunId, node) {
|
|
|
1404
3498
|
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "output");
|
|
1405
3499
|
}
|
|
1406
3500
|
|
|
1407
|
-
function
|
|
3501
|
+
function processEmptyMessage(body) {
|
|
3502
|
+
const reason = body?.emptyReason;
|
|
3503
|
+
if (reason === "static-no-process") return UI_TEXT.staticNoProcess;
|
|
3504
|
+
if (reason === "shell-receipt-missing") return UI_TEXT.noShellProcess;
|
|
3505
|
+
if (reason === "shell-preset-pending") return UI_TEXT.noPresetProcess;
|
|
3506
|
+
if (reason === "pi-session") return UI_TEXT.noSessionEvents;
|
|
3507
|
+
return UI_TEXT.noSessionEvents;
|
|
3508
|
+
}
|
|
3509
|
+
|
|
3510
|
+
function formatProcessBlock(text) {
|
|
3511
|
+
if (!text) return "";
|
|
3512
|
+
return prettyJsonBlock(text) ?? text;
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
function appendProcessPre(parent, text) {
|
|
3516
|
+
if (!text) return;
|
|
3517
|
+
const pre = el("pre", "process-timeline-code");
|
|
3518
|
+
pre.textContent = formatProcessBlock(text);
|
|
3519
|
+
parent.appendChild(pre);
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
function renderProcessCommandCard(command) {
|
|
3523
|
+
const failed = command.ok === false;
|
|
3524
|
+
const card = el(
|
|
3525
|
+
"div",
|
|
3526
|
+
`process-timeline-card process-timeline-tool-card${failed ? " is-error" : ""}`,
|
|
3527
|
+
);
|
|
3528
|
+
const details = document.createElement("details");
|
|
3529
|
+
details.className = "process-timeline-details";
|
|
3530
|
+
details.open = failed;
|
|
3531
|
+
const summary = el("summary", "process-timeline-summary");
|
|
3532
|
+
summary.appendChild(
|
|
3533
|
+
el("span", "process-timeline-summary-title", command.command || "command"),
|
|
3534
|
+
);
|
|
3535
|
+
summary.appendChild(
|
|
3536
|
+
el(
|
|
3537
|
+
"span",
|
|
3538
|
+
`process-timeline-summary-status status-${failed ? "failed" : "succeeded"}`,
|
|
3539
|
+
failed ? "失败" : command.reused ? "复用" : "成功",
|
|
3540
|
+
),
|
|
3541
|
+
);
|
|
3542
|
+
details.appendChild(summary);
|
|
3543
|
+
const body = el("div", "process-timeline-card-body");
|
|
3544
|
+
const meta = [
|
|
3545
|
+
command.exitCode != null ? `退出码 ${command.exitCode}` : null,
|
|
3546
|
+
command.durationMs != null ? `耗时 ${formatMs(command.durationMs)}` : null,
|
|
3547
|
+
command.failureCategory ? command.failureCategory : null,
|
|
3548
|
+
].filter(Boolean);
|
|
3549
|
+
if (meta.length > 0) {
|
|
3550
|
+
body.appendChild(
|
|
3551
|
+
el("div", "process-timeline-section-label", meta.join(" · ")),
|
|
3552
|
+
);
|
|
3553
|
+
}
|
|
3554
|
+
if (command.stdout) {
|
|
3555
|
+
body.appendChild(el("div", "process-timeline-section-label", "正常输出"));
|
|
3556
|
+
appendProcessPre(body, command.stdout);
|
|
3557
|
+
}
|
|
3558
|
+
if (command.stderr) {
|
|
3559
|
+
body.appendChild(el("div", "process-timeline-section-label", "错误输出"));
|
|
3560
|
+
appendProcessPre(body, command.stderr);
|
|
3561
|
+
}
|
|
3562
|
+
if (command.truncated) {
|
|
3563
|
+
body.appendChild(el("p", "muted", "内容过长,已截断。"));
|
|
3564
|
+
}
|
|
3565
|
+
details.appendChild(body);
|
|
3566
|
+
card.appendChild(details);
|
|
3567
|
+
return card;
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3570
|
+
function renderProcessStepCard(step) {
|
|
3571
|
+
const failed = step.ok === false;
|
|
3572
|
+
const card = el(
|
|
3573
|
+
"div",
|
|
3574
|
+
`process-timeline-card process-timeline-tool-card${failed ? " is-error" : ""}`,
|
|
3575
|
+
);
|
|
3576
|
+
const details = document.createElement("details");
|
|
3577
|
+
details.className = "process-timeline-details";
|
|
3578
|
+
details.open = true;
|
|
3579
|
+
const summary = el("summary", "process-timeline-summary");
|
|
3580
|
+
summary.appendChild(
|
|
3581
|
+
el(
|
|
3582
|
+
"span",
|
|
3583
|
+
"process-timeline-summary-title",
|
|
3584
|
+
step.label || step.id || "step",
|
|
3585
|
+
),
|
|
3586
|
+
);
|
|
3587
|
+
summary.appendChild(
|
|
3588
|
+
el(
|
|
3589
|
+
"span",
|
|
3590
|
+
`process-timeline-summary-status status-${failed ? "failed" : "succeeded"}`,
|
|
3591
|
+
failed ? "失败" : "成功",
|
|
3592
|
+
),
|
|
3593
|
+
);
|
|
3594
|
+
details.appendChild(summary);
|
|
3595
|
+
const body = el("div", "process-timeline-card-body");
|
|
3596
|
+
if (step.durationMs != null) {
|
|
3597
|
+
body.appendChild(
|
|
3598
|
+
el(
|
|
3599
|
+
"div",
|
|
3600
|
+
"process-timeline-section-label",
|
|
3601
|
+
`耗时 ${formatMs(step.durationMs)}`,
|
|
3602
|
+
),
|
|
3603
|
+
);
|
|
3604
|
+
}
|
|
3605
|
+
if (step.detail) appendProcessPre(body, step.detail);
|
|
3606
|
+
if (step.truncated) {
|
|
3607
|
+
body.appendChild(el("p", "muted", "内容过长,已截断。"));
|
|
3608
|
+
}
|
|
3609
|
+
details.appendChild(body);
|
|
3610
|
+
card.appendChild(details);
|
|
3611
|
+
return card;
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3614
|
+
function renderNonPiProcess(content, body) {
|
|
3615
|
+
content.classList.add("process-timeline-scroll");
|
|
3616
|
+
if (
|
|
3617
|
+
!body ||
|
|
3618
|
+
body.emptyReason ||
|
|
3619
|
+
((body.commands ?? []).length === 0 && (body.steps ?? []).length === 0)
|
|
3620
|
+
) {
|
|
3621
|
+
content.appendChild(el("p", "empty", processEmptyMessage(body)));
|
|
3622
|
+
return;
|
|
3623
|
+
}
|
|
3624
|
+
const heading =
|
|
3625
|
+
body.kind === "shell-preset"
|
|
3626
|
+
? UI_TEXT.shellPresetHeading
|
|
3627
|
+
: UI_TEXT.shellCommandsHeading;
|
|
3628
|
+
if (body.handler) {
|
|
3629
|
+
content.appendChild(
|
|
3630
|
+
el("p", "process-timeline-note", `${heading} · ${body.handler}`),
|
|
3631
|
+
);
|
|
3632
|
+
}
|
|
3633
|
+
const ul = el("ul", "process-timeline process-timeline-rich");
|
|
3634
|
+
const items =
|
|
3635
|
+
(body.commands ?? []).length > 0 ? body.commands : (body.steps ?? []);
|
|
3636
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
3637
|
+
const item = items[index];
|
|
3638
|
+
const failed = item.ok === false;
|
|
3639
|
+
const li = el(
|
|
3640
|
+
"li",
|
|
3641
|
+
`process-timeline-item process-timeline-tool-end${failed ? " is-error" : ""}${index === 0 ? " is-first" : ""}${index === items.length - 1 ? " is-last" : ""}`,
|
|
3642
|
+
);
|
|
3643
|
+
const rail = el("span", "process-timeline-rail");
|
|
3644
|
+
rail.appendChild(el("span", "process-timeline-dot"));
|
|
3645
|
+
li.appendChild(rail);
|
|
3646
|
+
const cardBody = el("div", "process-timeline-body");
|
|
3647
|
+
cardBody.appendChild(
|
|
3648
|
+
body.kind === "shell-preset"
|
|
3649
|
+
? renderProcessStepCard(item)
|
|
3650
|
+
: renderProcessCommandCard(item),
|
|
3651
|
+
);
|
|
3652
|
+
li.appendChild(cardBody);
|
|
3653
|
+
ul.appendChild(li);
|
|
3654
|
+
}
|
|
3655
|
+
content.appendChild(ul);
|
|
3656
|
+
appendProcessExportButton(content, body, body);
|
|
3657
|
+
}
|
|
3658
|
+
|
|
3659
|
+
function downloadTextFile(filename, text) {
|
|
3660
|
+
const blob = new Blob([text], { type: "text/html;charset=utf-8" });
|
|
3661
|
+
const url = URL.createObjectURL(blob);
|
|
3662
|
+
const a = document.createElement("a");
|
|
3663
|
+
a.href = url;
|
|
3664
|
+
a.download = filename;
|
|
3665
|
+
document.body.appendChild(a);
|
|
3666
|
+
a.click();
|
|
3667
|
+
a.remove();
|
|
3668
|
+
URL.revokeObjectURL(url);
|
|
3669
|
+
}
|
|
3670
|
+
|
|
3671
|
+
function appendProcessExportButton(content, body, meta) {
|
|
3672
|
+
if (!body || ((body.commands ?? []).length === 0 && (body.steps ?? []).length === 0)) return;
|
|
3673
|
+
const toolbar = el("div", "process-timeline-export-bar");
|
|
3674
|
+
const btn = el("button", "btn btn-secondary", "导出 HTML");
|
|
3675
|
+
btn.type = "button";
|
|
3676
|
+
btn.addEventListener("click", async () => {
|
|
3677
|
+
const cssText = await fetchPageStylesheetText();
|
|
3678
|
+
// 复用页面真实渲染 DOM,保证导出排版与页面一致。
|
|
3679
|
+
const clone = content.cloneNode(true);
|
|
3680
|
+
const bar = clone.querySelector(".process-timeline-export-bar");
|
|
3681
|
+
if (bar) bar.remove();
|
|
3682
|
+
downloadTextFile(
|
|
3683
|
+
`node-process-${meta?.nodeId || "node"}-${Date.now()}.html`,
|
|
3684
|
+
buildPageStyledDoc(clone.innerHTML, meta ?? {}, cssText),
|
|
3685
|
+
);
|
|
3686
|
+
});
|
|
3687
|
+
toolbar.appendChild(btn);
|
|
3688
|
+
content.insertBefore(toolbar, content.firstChild);
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
export async function mergeNodeProcess(dagRunId, node) {
|
|
3692
|
+
if (!dagRunId || !node?.nodeId) return;
|
|
3693
|
+
const nodeId = node.nodeId;
|
|
3694
|
+
const key = effectiveExecutionKey(dagRunId, node);
|
|
3695
|
+
const identity = makeDagNodeProcessIdentity(dagRunId, nodeId, key);
|
|
3696
|
+
uiState.dagNodeProcessIdentity = identity;
|
|
3697
|
+
uiState.dagNodeProcessLoading = true;
|
|
3698
|
+
const result = await fetchDagNodeProcess(dagRunId, nodeId, key);
|
|
3699
|
+
if (uiState.dagNodeProcessIdentity !== identity) return;
|
|
3700
|
+
if (!result.ok || !result.body) {
|
|
3701
|
+
uiState.dagNodeProcessError = result.body?.error || UI_TEXT.processError;
|
|
3702
|
+
uiState.dagNodeProcessData = {
|
|
3703
|
+
schemaVersion: 1,
|
|
3704
|
+
dagRunId,
|
|
3705
|
+
nodeId,
|
|
3706
|
+
kind: "none",
|
|
3707
|
+
executor: node.executor ?? null,
|
|
3708
|
+
handler: null,
|
|
3709
|
+
emptyReason: "not-executed",
|
|
3710
|
+
key: key ?? null,
|
|
3711
|
+
commands: [],
|
|
3712
|
+
steps: [],
|
|
3713
|
+
};
|
|
3714
|
+
uiState.dagNodeProcessLoading = false;
|
|
3715
|
+
return;
|
|
3716
|
+
}
|
|
3717
|
+
uiState.dagNodeProcessError = null;
|
|
3718
|
+
uiState.dagNodeProcessData = result.body;
|
|
3719
|
+
uiState.dagNodeProcessLoading = false;
|
|
3720
|
+
}
|
|
3721
|
+
|
|
3722
|
+
function renderExecutorAwareTimeline(content, dagRunId, node) {
|
|
3723
|
+
content.dataset.dagRunId = String(dagRunId ?? "");
|
|
3724
|
+
content.dataset.nodeId = String(node.nodeId ?? "");
|
|
3725
|
+
const key = effectiveExecutionKey(dagRunId, node);
|
|
3726
|
+
const cached = uiState.dagNodeProcessData;
|
|
3727
|
+
const sameNode =
|
|
3728
|
+
cached &&
|
|
3729
|
+
cached.dagRunId === dagRunId &&
|
|
3730
|
+
cached.nodeId === node.nodeId &&
|
|
3731
|
+
(cached.key ?? null) === (key ?? null);
|
|
3732
|
+
if (sameNode && uiState.dagNodeProcessError) {
|
|
3733
|
+
content.appendChild(el("p", "empty", uiState.dagNodeProcessError));
|
|
3734
|
+
return;
|
|
3735
|
+
}
|
|
3736
|
+
if (sameNode && cached.kind === "pi-session") {
|
|
3737
|
+
renderSessionTimeline(content, node.nodeId, {
|
|
3738
|
+
executionKey: effectiveExecutionKey(dagRunId, node),
|
|
3739
|
+
});
|
|
3740
|
+
return;
|
|
3741
|
+
}
|
|
3742
|
+
if (sameNode && cached.kind !== "pi-session") {
|
|
3743
|
+
renderNonPiProcess(content, cached);
|
|
3744
|
+
return;
|
|
3745
|
+
}
|
|
3746
|
+
if ((node.executor ?? "pi") === "pi") {
|
|
3747
|
+
renderSessionTimeline(content, node.nodeId, {
|
|
3748
|
+
executionKey: effectiveExecutionKey(dagRunId, node),
|
|
3749
|
+
});
|
|
3750
|
+
return;
|
|
3751
|
+
}
|
|
3752
|
+
if (uiState.dagNodeProcessError && sameNode) {
|
|
3753
|
+
content.appendChild(el("p", "empty", uiState.dagNodeProcessError));
|
|
3754
|
+
return;
|
|
3755
|
+
}
|
|
3756
|
+
const loading = el("p", "muted", UI_TEXT.processLoading);
|
|
3757
|
+
loading.setAttribute("role", "status");
|
|
3758
|
+
content.appendChild(loading);
|
|
3759
|
+
void mergeNodeProcess(dagRunId, node).then(() => {
|
|
3760
|
+
if (
|
|
3761
|
+
uiState.dagInspectorTab === "timeline" &&
|
|
3762
|
+
uiState.selectedDagNodeId === node.nodeId &&
|
|
3763
|
+
uiState.currentDagRunId === dagRunId
|
|
3764
|
+
) {
|
|
3765
|
+
renderDagInspectorForCurrent();
|
|
3766
|
+
}
|
|
3767
|
+
});
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
function fillDagInspectorContent(content, dagRunId, node, run) {
|
|
1408
3771
|
const previousRenderedNode = content.dataset.dagNodeId ?? "";
|
|
1409
3772
|
const previousRenderedRun = content.dataset.dagRunId ?? "";
|
|
1410
3773
|
const previousTab = content.dataset.inspectorTab ?? "";
|
|
@@ -1442,22 +3805,39 @@ function fillDagInspectorContent(content, dagRunId, node) {
|
|
|
1442
3805
|
content.dataset.inspectorTab = activeTab;
|
|
1443
3806
|
// Drop timeline-only classes when switching tabs so output layout stays clean.
|
|
1444
3807
|
content.className = "dag-inspector-content";
|
|
3808
|
+
if (activeTab !== "prompt-restart") {
|
|
3809
|
+
content.classList.add("is-readable-page");
|
|
3810
|
+
}
|
|
1445
3811
|
ensureInspectorContentScrollCapture(
|
|
1446
3812
|
content,
|
|
1447
3813
|
dagRunId,
|
|
1448
3814
|
node.nodeId,
|
|
1449
3815
|
activeTab,
|
|
1450
3816
|
);
|
|
1451
|
-
if (activeTab === "
|
|
3817
|
+
if (activeTab === "overview") {
|
|
3818
|
+
renderNodeOverview(content, dagRunId, node);
|
|
3819
|
+
} else if (activeTab === "context") {
|
|
3820
|
+
void renderEffectiveContext(content, dagRunId, node);
|
|
3821
|
+
} else if (activeTab === "lineage") {
|
|
3822
|
+
void renderRunLineage(content, dagRunId, node);
|
|
3823
|
+
} else if (activeTab === "spec-evidence") {
|
|
3824
|
+
ensureInspectorPageLead(content, "spec-evidence");
|
|
1452
3825
|
void renderSpecEvidence(content, dagRunId, node.nodeId);
|
|
3826
|
+
} else if (activeTab === "prompt-restart") {
|
|
3827
|
+
void renderPromptRestart(content, dagRunId, node, run);
|
|
1453
3828
|
} else if (activeTab === "timeline") {
|
|
3829
|
+
ensureInspectorPageLead(content, "timeline");
|
|
1454
3830
|
const attemptBuilt = buildAttemptBar(dagRunId, node);
|
|
1455
3831
|
if (attemptBuilt?.bar) content.appendChild(attemptBuilt.bar);
|
|
1456
|
-
|
|
3832
|
+
renderExecutorAwareTimeline(content, dagRunId, node);
|
|
3833
|
+
// Initial content is rendered before it is attached. Restore again on the
|
|
3834
|
+
// connected animation frame so live-follow sees the final scroll height.
|
|
3835
|
+
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "timeline");
|
|
1457
3836
|
} else if (activeTab === "input") {
|
|
1458
3837
|
void renderDagNodeInput(content, dagRunId, node);
|
|
1459
3838
|
} else {
|
|
1460
3839
|
// output tab: attempt bar + latest preview immediate / historical async body.
|
|
3840
|
+
ensureInspectorPageLead(content, "output");
|
|
1461
3841
|
const attemptBuilt = buildAttemptBar(dagRunId, node);
|
|
1462
3842
|
if (attemptBuilt?.bar) content.appendChild(attemptBuilt.bar);
|
|
1463
3843
|
const key = effectiveExecutionKey(dagRunId, node);
|
|
@@ -1485,9 +3865,20 @@ function fillDagInspectorContent(content, dagRunId, node) {
|
|
|
1485
3865
|
}
|
|
1486
3866
|
// Single-execution nodes (!key) already painted preview via renderCachedOrPreviewBody.
|
|
1487
3867
|
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "output");
|
|
3868
|
+
void prependArtifactInventory(content, dagRunId, node);
|
|
1488
3869
|
}
|
|
1489
3870
|
}
|
|
1490
3871
|
|
|
3872
|
+
function inspectorNodePurpose(node) {
|
|
3873
|
+
return describeDagNodePurpose(node?.nodeId, node);
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
function appendInspectorPurpose(title, node) {
|
|
3877
|
+
const purpose = inspectorNodePurpose(node);
|
|
3878
|
+
if (!purpose) return;
|
|
3879
|
+
title.appendChild(el("p", "dag-inspector-purpose", purpose));
|
|
3880
|
+
}
|
|
3881
|
+
|
|
1491
3882
|
function buildDagInspectorHeader(dagRunId, node) {
|
|
1492
3883
|
const header = el("div", "dag-inspector-header");
|
|
1493
3884
|
header.dataset.dagRunId = String(dagRunId ?? "");
|
|
@@ -1495,6 +3886,7 @@ function buildDagInspectorHeader(dagRunId, node) {
|
|
|
1495
3886
|
const title = el("div", "dag-inspector-title");
|
|
1496
3887
|
title.appendChild(el("h3", null, "节点检查器"));
|
|
1497
3888
|
title.appendChild(el("div", "dag-inspector-node", node.nodeId));
|
|
3889
|
+
appendInspectorPurpose(title, node);
|
|
1498
3890
|
header.appendChild(title);
|
|
1499
3891
|
const controls = el("div", "dag-inspector-controls");
|
|
1500
3892
|
const status = badge(node.status ?? "unknown");
|
|
@@ -1511,12 +3903,15 @@ function buildDagInspectorHeader(dagRunId, node) {
|
|
|
1511
3903
|
controls.appendChild(close);
|
|
1512
3904
|
header.appendChild(controls);
|
|
1513
3905
|
|
|
1514
|
-
const tabDefs = [
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
3906
|
+
const tabDefs = DAG_INSPECTOR_READ_ONLY_TABS.map((definition) => [
|
|
3907
|
+
...definition,
|
|
3908
|
+
]);
|
|
3909
|
+
// Export/rerun mutation surface: the server injects a SCOPED inspect token.
|
|
3910
|
+
// The emergency kill switch suppresses the token;
|
|
3911
|
+
// no token → no tab → the inspector stays strictly read-only.
|
|
3912
|
+
if (globalThis.__INSPECT_MUTATION_TOKEN__) {
|
|
3913
|
+
tabDefs.push([...DAG_INSPECTOR_MUTATION_TAB]);
|
|
3914
|
+
}
|
|
1520
3915
|
const tabs = el("div", "dag-inspector-tabs");
|
|
1521
3916
|
tabs.setAttribute("role", "tablist");
|
|
1522
3917
|
tabs.setAttribute("aria-label", "节点检查器面板");
|
|
@@ -1567,6 +3962,16 @@ function syncDagInspectorHeader(panel, dagRunId, node) {
|
|
|
1567
3962
|
header.dataset.dagNodeId = String(node.nodeId ?? "");
|
|
1568
3963
|
const nodeLabel = header.querySelector(".dag-inspector-node");
|
|
1569
3964
|
if (nodeLabel) nodeLabel.textContent = node.nodeId;
|
|
3965
|
+
const title = header.querySelector(".dag-inspector-title");
|
|
3966
|
+
const purposeLine = header.querySelector(".dag-inspector-purpose");
|
|
3967
|
+
const purpose = inspectorNodePurpose(node);
|
|
3968
|
+
if (purposeLine && purpose) {
|
|
3969
|
+
purposeLine.textContent = purpose;
|
|
3970
|
+
} else if (purposeLine && !purpose) {
|
|
3971
|
+
purposeLine.remove();
|
|
3972
|
+
} else if (!purposeLine && purpose && title) {
|
|
3973
|
+
title.appendChild(el("p", "dag-inspector-purpose", purpose));
|
|
3974
|
+
}
|
|
1570
3975
|
const status = header.querySelector(".dag-inspector-status");
|
|
1571
3976
|
if (status) {
|
|
1572
3977
|
const next = badge(node.status ?? "unknown");
|
|
@@ -1606,7 +4011,14 @@ function dagInspectorSignature(dagRunId, node) {
|
|
|
1606
4011
|
uiState.dagNodeExecutionOutputLoading ? "loading" : "idle",
|
|
1607
4012
|
]
|
|
1608
4013
|
: tab === "timeline"
|
|
1609
|
-
? [
|
|
4014
|
+
? [
|
|
4015
|
+
uiState.sessionEventOffset,
|
|
4016
|
+
uiState.dagNodeProcessData?.kind ?? "",
|
|
4017
|
+
uiState.dagNodeProcessData?.emptyReason ?? "",
|
|
4018
|
+
(uiState.dagNodeProcessData?.commands ?? []).length,
|
|
4019
|
+
(uiState.dagNodeProcessData?.steps ?? []).length,
|
|
4020
|
+
uiState.dagNodeProcessLoading ? "loading" : "idle",
|
|
4021
|
+
]
|
|
1610
4022
|
: [node.status ?? ""];
|
|
1611
4023
|
// Attempt dimension: selection identity + history shape. Poll refreshes keep
|
|
1612
4024
|
// the DOM while selection/history are unchanged; switching attempt or a
|
|
@@ -1626,12 +4038,13 @@ function dagInspectorSignature(dagRunId, node) {
|
|
|
1626
4038
|
]);
|
|
1627
4039
|
}
|
|
1628
4040
|
|
|
1629
|
-
export function renderDagInspector(dagRunId, node, initial = true) {
|
|
4041
|
+
export function renderDagInspector(dagRunId, node, initial = true, run = null) {
|
|
1630
4042
|
// Record the current selection before any early-return so tab handlers
|
|
1631
4043
|
// (which reference the mutable inspectorSelection slot) always re-render
|
|
1632
4044
|
// the currently selected node, never a stale build-time closure.
|
|
1633
4045
|
inspectorSelection.dagRunId = dagRunId;
|
|
1634
4046
|
inspectorSelection.node = node;
|
|
4047
|
+
inspectorSelection.run = run;
|
|
1635
4048
|
const panel = document.getElementById("dag-inspector");
|
|
1636
4049
|
if (!panel) return;
|
|
1637
4050
|
captureDagTimelineViewportState(panel);
|
|
@@ -1681,7 +4094,7 @@ export function renderDagInspector(dagRunId, node, initial = true) {
|
|
|
1681
4094
|
scrollTop: pre.scrollTop,
|
|
1682
4095
|
}));
|
|
1683
4096
|
clearNode(existingContent);
|
|
1684
|
-
fillDagInspectorContent(existingContent, dagRunId, node);
|
|
4097
|
+
fillDagInspectorContent(existingContent, dagRunId, node, run);
|
|
1685
4098
|
// Async tabs restore themselves after fetch; sync tabs restore here.
|
|
1686
4099
|
if (activeTab === "output" || activeTab === "timeline") {
|
|
1687
4100
|
restoreInspectorContentScroll(
|
|
@@ -1712,7 +4125,7 @@ export function renderDagInspector(dagRunId, node, initial = true) {
|
|
|
1712
4125
|
panel.appendChild(buildDagInspectorHeader(dagRunId, node));
|
|
1713
4126
|
|
|
1714
4127
|
const content = el("div", "dag-inspector-content");
|
|
1715
|
-
fillDagInspectorContent(content, dagRunId, node);
|
|
4128
|
+
fillDagInspectorContent(content, dagRunId, node, run);
|
|
1716
4129
|
panel.appendChild(content);
|
|
1717
4130
|
panel.dataset.contentSignature = nextContentSignature;
|
|
1718
4131
|
}
|