@tea-agent/loop-agent 0.39.2 → 0.40.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +133 -92
- package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
- package/dist/adapters/context-transfer/pi-session.js +61 -0
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +12 -0
- package/dist/cli/program.js +23 -1
- package/dist/commands/dag-artifact.js +284 -0
- package/dist/commands/dag-context.js +184 -0
- package/dist/commands/dag-rerun.js +206 -1
- package/dist/executors/dag-pi-executor.js +108 -19
- package/dist/executors/pi-executor.js +4 -2
- package/dist/executors/pi-sdk-executor.js +49 -1
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +42 -2
- package/dist/executors/workspace-write-snapshot.js +68 -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/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/operator/capabilities.js +14 -0
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/preview.js +28 -4
- package/dist/task/config-types.js +10 -0
- package/dist/worker/console/chat/chat-event-store.js +77 -7
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +12 -0
- package/dist/worker/console/chat/pi-runtime.js +331 -18
- package/dist/worker/console/chat/provider-error.js +98 -0
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +389 -56
- package/dist/worker/console/chat/session-stats.js +179 -0
- package/dist/worker/console/chat/session-store.js +94 -64
- 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 +20 -55
- 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-update-runtime.js +1 -1
- 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 +1 -1
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +1 -1
- package/dist/worker/console/human-gate-token.js +1 -1
- package/dist/worker/console/index.js +3 -3
- 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-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 +104 -3
- package/dist/worker/console/operator-surface-health.js +1 -1
- package/dist/worker/console/operator-user-error.js +128 -0
- package/dist/worker/console/routes.js +927 -8
- package/dist/worker/console/security.js +39 -4
- package/dist/worker/console/server.js +532 -187
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-CTx1TrNa.js → abnfDiagram-N423BO3Z-CpWvwARc.js} +1 -1
- package/dist/worker/console/static/assets/{arc-B4i9cVxX.js → arc-DctXgO-g.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-BAXE8_Rl.js → architectureDiagram-T3A2C74G-D4mIkoQl.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-C5Xh59at.js → blockDiagram-VBNYF7ZC-ClG0--KO.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-B_asOzAu.js → c4Diagram-5PPSVZJV-CwdLk78T.js} +1 -1
- package/dist/worker/console/static/assets/channel-C9VQZ-ru.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-wRO_iRNc.js → chunk-2GRJ4B5K-DKczcu-O.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-ByOaSh_G.js → chunk-2Q5K7J3B-BV6F-vBI.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-DjLzudan.js → chunk-5RXB4S5H-DtojVnvA.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-JCNGkXYT.js → chunk-5VM5RSS4-BjDQRGnO.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BhrPXXMZ.js → chunk-6Q2QTUOP-I0fV6ngU.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-TJ5JuEBT.js → chunk-GF5L2VYU-BM8C-mmC.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-VVthn_mD.js → chunk-JWPE2WC7-BEK-a15e.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-D60-Mny4.js → chunk-KBJHAD2P-CQsg_fSR.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-zXv7aVye.js → chunk-RYQCIY6F-B-BcaUm3.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-By9VQoi1.js → chunk-XXDRQBXY-D1Bu08fg.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BsCkw5MF.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BsCkw5MF.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-C4zQLe-M.js → cose-bilkent-JH36ORCC-q8nwtxBR.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-wh5N2ReN.js → cynefin-VYW2F7L2-CruhpURw.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-Dlu5wIqs.js → cynefinDiagram-MW4NZA55-CJne6iYF.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-CrDgthc6.js → dagre-VZM6K2ZE-CbeLvBU5.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-zN1clg27.js → diagram-7IWD3JNH-DmCxH1Pe.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BN-o7J7-.js → diagram-B4RE2ZJO-DJ5OYhtC.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-C8SuPt0d.js → diagram-LBJQPF4R-B-UN-hln.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BoizuHbZ.js → diagram-Q27KOJAE-CcEro8Ey.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-BzUzXixG.js → diagram-UB23O5K3-BBBzDden.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-Ev3lA4Cf.js → ebnfDiagram-BXEA7PRR-xKEyH-oo.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-GALUzRbs.js → erDiagram-JOGREHBK-C7xl63VC.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-CZJN65Sb.js → flowDiagram-UKHOOZJN-nthQQ9nR.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-JLB9OESl.js → ganttDiagram-PKOTCBZU-CWN5mE33.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-CcvCr4GD.js → gitGraphDiagram-DS77QQ5N-Wn86tQ6N.js} +1 -1
- package/dist/worker/console/static/assets/index-D-0NVyMk.css +1 -0
- package/dist/worker/console/static/assets/index-gwyOxQiS.js +407 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-HG5z7aVg.js → infoDiagram-6WML65LV-_WQymGtW.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-BHEu9chR.js → ishikawaDiagram-WSZJBQD7-COBeivBm.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Cp_Up8-a.js → journeyDiagram-NVQOT4AX-CwGOJl3Q.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DvVeY-em.js → kanban-definition-27J2QSJJ-Ci0CJ5Vi.js} +1 -1
- package/dist/worker/console/static/assets/{linear-aGmcjgTn.js → linear-CPjMq6vN.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-Biyo-tqA.js → mermaid.core-Z0wGoe0b.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-DyxY2pIb.js → mindmap-definition-FAOFIHXS-dISked0d.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-CkdGuc50.js → pegDiagram-VL7TDLO6-BJxgof7Y.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-NNQI9xVR.js → pieDiagram-7S7Q4E2Y-CIblU8eW.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-PAJkuz_G.js → quadrantDiagram-CIZ2JOQS-vwYiqh8E.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-ZwrQod0O.js → railroadDiagram-AXF67PYL-_iOsVeFm.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-D3ZfrzM2.js → requirementDiagram-LRYGKXZP-Dk0MLxO_.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DDGFmWk5.js → sankeyDiagram-W5VNT64P-Dx7HtLVW.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-DO6mmXTA.js → sequenceDiagram-SI44F4Z6-DRuWjlpL.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-DMbCQiJt.js → sizeCapture-X5ZJPWSS-Bhy9DQAA.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-Di_YUEfC.js → stateDiagram-OKZ733FA-DAx9twnU.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Dmdf8cGy.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-Bn2PphNJ.js → swimlanes-SLNWSIFB-okMlvVrM.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-W1IcAFff.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-DPh8pRsp.js → timeline-definition-Z64GVDOM-DXqCKe37.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-GMfl26pW.js → vennDiagram-T6HMQDX7-CeIUkwBh.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-DTlmVrmF.js → wardleyDiagram-T6FBY63Y-BP76BKTN.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-YGBjKAS5.js → xychartDiagram-ELKLHX3M-BpVI0OpF.js} +1 -1
- package/dist/worker/console/static/index.html +7 -2
- package/dist/worker/console/static-src/app/console-types.js +29 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +36 -6
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +10 -11
- package/dist/worker/console/static-src/app/useRunProgress.js +2 -1
- package/dist/worker/console/static-src/app/useTaskWizard.js +2 -2
- package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +141 -8
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +79 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -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/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +25 -0
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +3 -2
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +181 -87
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +159 -44
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +177 -8
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +63 -9
- 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/shell/useWorkspaces.js +299 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +339 -0
- package/dist/worker/console/workspace-context.js +260 -0
- package/dist/worker/console/workspace-registry.js +214 -0
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +51 -1
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/static/api.js +94 -10
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +120 -0
- package/dist/worker/observe/static/index.html +1 -1
- package/dist/worker/observe/static/inspect-workspace.js +307 -0
- package/dist/worker/observe/static/operator-chrome.css +145 -20
- package/dist/worker/observe/static/operator-chrome.d.ts +20 -3
- package/dist/worker/observe/static/operator-chrome.js +330 -100
- package/dist/worker/observe/static/router.d.ts +46 -0
- package/dist/worker/observe/static/router.js +25 -1
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +175 -1
- package/dist/worker/observe/static/styles.css +1039 -128
- package/dist/worker/observe/static/views/dag-inspector.js +1218 -60
- package/dist/worker/observe/static/views/dag.js +2 -1
- package/dist/worker/observe/static/views/dashboard.js +6 -4
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +1 -0
- package/dist/worker/observe/static/views/run.js +3 -1
- package/dist/worker/observe/static/views/session-timeline.js +75 -10
- package/dist/worker/observe/static/views/task.js +1 -1
- 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/workflows/dag/artifact-bindings.js +149 -0
- package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +11 -10
- package/dist/workflows/dag/backend-test-writer-completeness.js +7 -12
- 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/dynamic-runtime/map.js +1 -0
- package/dist/workflows/dag/init-hybrid.js +178 -47
- package/dist/workflows/dag/interrupt-request.js +3 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +112 -27
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +29 -4
- package/dist/workflows/dag/rerun-plan.js +272 -0
- package/dist/workflows/dag/rerun-run.js +390 -12
- package/dist/workflows/dag/skill-snapshot.js +1 -0
- package/dist/workflows/dag/types.js +203 -8
- package/docs/README.md +1 -0
- package/docs/architecture/runtime-boundaries.md +6 -6
- package/docs/operations/local-development-environment.md +21 -0
- package/docs/templates/agent-dag.schema.json +50 -0
- package/docs/templates/backend-test-dag.json +265 -237
- package/harness.json +3 -3
- package/package.json +5 -1
- package/skills/loop-agent/references/command-reference.md +6 -0
- package/dist/worker/console/static/assets/channel-Dj_4Moei.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-C0YYAyCa.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-C0YYAyCa.js +0 -1
- package/dist/worker/console/static/assets/index-CW88Fjbw.js +0 -406
- package/dist/worker/console/static/assets/index-DP0ZJl39.css +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DrdDvela.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DPkEAULl.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/dist/{worker → infrastructure}/console/operation-store.js +0 -0
- /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
|
@@ -11,20 +11,36 @@ 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 {
|
|
15
|
+
contextTransferReasonLabel,
|
|
16
|
+
describeTransferError,
|
|
17
|
+
formatContextTransferReasonList,
|
|
18
|
+
} from "../dag-context-reason-labels.js";
|
|
14
19
|
import {
|
|
15
20
|
fetchJson,
|
|
16
21
|
fetchSpecEvidenceFile,
|
|
17
22
|
fetchDagNodeInput,
|
|
23
|
+
fetchDagNodeContext,
|
|
24
|
+
fetchDagNodeArtifacts,
|
|
25
|
+
fetchDagNodeArtifactPreview,
|
|
26
|
+
fetchDagRunLineage,
|
|
18
27
|
fetchDagNodeProcess,
|
|
19
28
|
postOperatorAction,
|
|
20
29
|
fetchOperatorOperation,
|
|
30
|
+
downloadContextExport,
|
|
21
31
|
} from "../api.js";
|
|
22
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
badge,
|
|
34
|
+
formatLedgerSummary,
|
|
35
|
+
formatMs,
|
|
36
|
+
prettyJsonBlock,
|
|
37
|
+
} from "../format.js";
|
|
23
38
|
import { renderMarkdown, renderInspectorDocument } from "../markdown-render.js";
|
|
24
39
|
import { describeDagNodePurpose } from "../dag-node-purpose.js";
|
|
25
40
|
import { buildPromptRestartCandidateOptions } from "../prompt-restart-candidates.js";
|
|
26
41
|
import { copyText } from "../copy.js";
|
|
27
42
|
import {
|
|
43
|
+
fetchWithWorkspaceScope,
|
|
28
44
|
uiState,
|
|
29
45
|
makeSessionEventIdentity,
|
|
30
46
|
makeDagNodeInputIdentity,
|
|
@@ -55,6 +71,89 @@ import { createCustomSelect } from "../custom-select.js";
|
|
|
55
71
|
// reference, always resolving the currently selected node identity.
|
|
56
72
|
const inspectorSelection = { dagRunId: null, node: null };
|
|
57
73
|
|
|
74
|
+
/**
|
|
75
|
+
* 失败状态行统一入口:错误信息中嵌入的已知 reason code 先给中文语义
|
|
76
|
+
* (原码与原始信息保留),未知内容原样展示,不做成功方向的猜测。
|
|
77
|
+
*/
|
|
78
|
+
function transferErrorStatusText(error, fallback) {
|
|
79
|
+
const raw = error instanceof Error ? error.message : String(error ?? "");
|
|
80
|
+
return describeTransferError(raw) ?? (raw || fallback);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const DAG_INSPECTOR_READ_ONLY_TABS = Object.freeze([
|
|
84
|
+
["overview", "节点概览", "ri-dashboard-line"],
|
|
85
|
+
["input", "执行设置", "ri-login-box-line"],
|
|
86
|
+
["context", "实际上下文", "ri-stack-line"],
|
|
87
|
+
["timeline", "执行记录", "ri-route-line"],
|
|
88
|
+
["spec-evidence", "规范证据", "ri-book-open-line"],
|
|
89
|
+
["output", "产出", "ri-file-text-line"],
|
|
90
|
+
["lineage", "来源与影响", "ri-git-branch-line"],
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
export const DAG_INSPECTOR_MUTATION_TAB = Object.freeze([
|
|
94
|
+
"prompt-restart",
|
|
95
|
+
"导出与重跑",
|
|
96
|
+
"ri-share-forward-line",
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
export const DAG_ACTION_SECTION_ORDER = Object.freeze([
|
|
100
|
+
"artifact-revision",
|
|
101
|
+
"prompt-restart",
|
|
102
|
+
"context-export",
|
|
103
|
+
]);
|
|
104
|
+
|
|
105
|
+
export const ARTIFACT_FILE_PREVIEW_SURFACES = Object.freeze({
|
|
106
|
+
produced: "produced-artifact-preview",
|
|
107
|
+
consumed: "consumed-artifact-preview",
|
|
108
|
+
revisionSelection: "artifact-revision-current-preview",
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export const CONTEXT_EXPORT_TARGETS = Object.freeze([
|
|
112
|
+
{
|
|
113
|
+
value: "generic",
|
|
114
|
+
label: "通用 Agent 交接包",
|
|
115
|
+
description: "适合交给其他 Agent 或 LLM 继续处理",
|
|
116
|
+
icon: "ri-robot-2-line",
|
|
117
|
+
contents: "receipt · manifest · handoff.md",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
value: "pi-session",
|
|
121
|
+
label: "Pi 可重开会话",
|
|
122
|
+
description: "兼容时附带可由 Pi 打开的 session JSONL",
|
|
123
|
+
icon: "ri-terminal-box-line",
|
|
124
|
+
contents: "receipt · manifest · session.jsonl(兼容时)",
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
value: "readable",
|
|
128
|
+
label: "可读执行记录",
|
|
129
|
+
description: "便于人工审阅,不承诺完整重现执行",
|
|
130
|
+
icon: "ri-file-list-3-line",
|
|
131
|
+
contents: "receipt · manifest · transcript.md",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
value: "pi-handoff",
|
|
135
|
+
label: "Pi Handoff 交接包",
|
|
136
|
+
description: "面向 Pi Handoff 工作流的兼容格式",
|
|
137
|
+
icon: "ri-share-forward-box-line",
|
|
138
|
+
contents: "receipt · manifest · handoff.md",
|
|
139
|
+
},
|
|
140
|
+
]);
|
|
141
|
+
|
|
142
|
+
export const CONTEXT_EXPORT_PROFILES = Object.freeze([
|
|
143
|
+
{
|
|
144
|
+
value: "redacted",
|
|
145
|
+
label: "脱敏后导出",
|
|
146
|
+
description: "自动隐藏匹配到的疑似凭据",
|
|
147
|
+
badge: "推荐",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
value: "raw",
|
|
151
|
+
label: "保留原始内容",
|
|
152
|
+
description: "可能包含凭据、绝对路径和未脱敏文本",
|
|
153
|
+
badge: "高风险",
|
|
154
|
+
},
|
|
155
|
+
]);
|
|
156
|
+
|
|
58
157
|
function createPromptRestartCopyButton(readCandidate) {
|
|
59
158
|
const buildIcon = (kind) => {
|
|
60
159
|
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
@@ -103,7 +202,7 @@ function createPromptRestartCopyButton(readCandidate) {
|
|
|
103
202
|
};
|
|
104
203
|
const button = el(
|
|
105
204
|
"button",
|
|
106
|
-
"dags-copy-btn
|
|
205
|
+
"dags-copy-btn prompt-restart-copy-button",
|
|
107
206
|
);
|
|
108
207
|
button.type = "button";
|
|
109
208
|
button.setAttribute("data-testid", "prompt-restart-copy");
|
|
@@ -111,6 +210,8 @@ function createPromptRestartCopyButton(readCandidate) {
|
|
|
111
210
|
button.setAttribute("title", "复制当前提示词候选");
|
|
112
211
|
button.appendChild(buildIcon("copy"));
|
|
113
212
|
button.appendChild(buildIcon("check"));
|
|
213
|
+
const label = el("span", "prompt-restart-copy-label", "复制提示词");
|
|
214
|
+
button.appendChild(label);
|
|
114
215
|
button.addEventListener("click", (event) => {
|
|
115
216
|
event.preventDefault();
|
|
116
217
|
event.stopPropagation();
|
|
@@ -124,10 +225,12 @@ function createPromptRestartCopyButton(readCandidate) {
|
|
|
124
225
|
button.classList.toggle("is-copied", ok);
|
|
125
226
|
button.setAttribute("aria-label", feedback);
|
|
126
227
|
button.setAttribute("title", feedback);
|
|
228
|
+
label.textContent = feedback;
|
|
127
229
|
setTimeout(() => {
|
|
128
230
|
button.classList.remove("is-copied");
|
|
129
231
|
button.setAttribute("aria-label", "复制当前提示词候选");
|
|
130
232
|
button.setAttribute("title", "复制当前提示词候选");
|
|
233
|
+
label.textContent = "复制提示词";
|
|
131
234
|
}, 1500);
|
|
132
235
|
});
|
|
133
236
|
});
|
|
@@ -1083,8 +1186,8 @@ function renderDagNodeInputDetail(content, data) {
|
|
|
1083
1186
|
"p",
|
|
1084
1187
|
"muted",
|
|
1085
1188
|
facts.parseError
|
|
1086
|
-
|
|
1087
|
-
|
|
1189
|
+
? `产物 ${facts.artifact} 读取失败(${facts.parseError})。`
|
|
1190
|
+
: `产物 ${facts.artifact} 尚未生成(节点未执行或缺失)。`,
|
|
1088
1191
|
),
|
|
1089
1192
|
);
|
|
1090
1193
|
} else {
|
|
@@ -1098,11 +1201,7 @@ function renderDagNodeInputDetail(content, data) {
|
|
|
1098
1201
|
null,
|
|
1099
1202
|
);
|
|
1100
1203
|
section.appendChild(dl);
|
|
1101
|
-
appendCodeList(
|
|
1102
|
-
section,
|
|
1103
|
-
"requested",
|
|
1104
|
-
facts.requested,
|
|
1105
|
-
);
|
|
1204
|
+
appendCodeList(section, "requested", facts.requested);
|
|
1106
1205
|
for (const missingEntry of facts.missing ?? []) {
|
|
1107
1206
|
section.appendChild(
|
|
1108
1207
|
el(
|
|
@@ -1286,7 +1385,7 @@ export function frontendGateLedgerLines(input) {
|
|
|
1286
1385
|
/** DAG run 专属 prewrite-result 只读拉取(内联 fetch,不新增 api.js 依赖)。 */
|
|
1287
1386
|
async function fetchPrewriteResultJson(dagRunId) {
|
|
1288
1387
|
try {
|
|
1289
|
-
const res = await
|
|
1388
|
+
const res = await fetchWithWorkspaceScope(
|
|
1290
1389
|
`/api/dag-runs/${encodeURIComponent(dagRunId)}/prewrite-result`,
|
|
1291
1390
|
{ credentials: "same-origin" },
|
|
1292
1391
|
);
|
|
@@ -1303,9 +1402,7 @@ async function fetchPrewriteResultJson(dagRunId) {
|
|
|
1303
1402
|
* relying on source-string assertions.
|
|
1304
1403
|
*/
|
|
1305
1404
|
export async function fetchFrontendGateLedgerData(dagRunId) {
|
|
1306
|
-
const run = await fetchJson(
|
|
1307
|
-
`/api/dag-runs/${encodeURIComponent(dagRunId)}`,
|
|
1308
|
-
);
|
|
1405
|
+
const run = await fetchJson(`/api/dag-runs/${encodeURIComponent(dagRunId)}`);
|
|
1309
1406
|
const taskId = typeof run?.taskId === "string" ? run.taskId : "";
|
|
1310
1407
|
const prewriteResult = await fetchPrewriteResultJson(dagRunId);
|
|
1311
1408
|
let ledgerBody = null;
|
|
@@ -1358,14 +1455,733 @@ async function renderFrontendGateLedger(content, dagRunId) {
|
|
|
1358
1455
|
* restart flow: preflight (dagRerunPlan) binds the edit into planHash, dagRerun
|
|
1359
1456
|
* executes it as a Console operation, and on success we jump to the new run.
|
|
1360
1457
|
*/
|
|
1458
|
+
function buildContextExportSection(dagRunId, node) {
|
|
1459
|
+
const zone = el("section", "dag-action-export-zone");
|
|
1460
|
+
zone.dataset.actionSection = "context-export";
|
|
1461
|
+
const divider = el("div", "dag-action-export-divider");
|
|
1462
|
+
divider.append(
|
|
1463
|
+
el("span", null, "不需要重跑?"),
|
|
1464
|
+
el("p", null, "你也可以只把这个节点的上下文打包带走。"),
|
|
1465
|
+
);
|
|
1466
|
+
zone.appendChild(divider);
|
|
1467
|
+
const section = el("div", "prompt-restart-box context-export-box");
|
|
1468
|
+
section.setAttribute("role", "region");
|
|
1469
|
+
section.setAttribute("aria-labelledby", "context-export-title");
|
|
1470
|
+
const heading = el("div", "context-export-heading");
|
|
1471
|
+
const headingCopy = el("div", null);
|
|
1472
|
+
headingCopy.appendChild(el("span", "context-export-eyebrow", "上下文交接包"));
|
|
1473
|
+
const title = el("h4", null, "把这个节点交给另一个 Agent");
|
|
1474
|
+
title.id = "context-export-title";
|
|
1475
|
+
headingCopy.appendChild(title);
|
|
1476
|
+
headingCopy.appendChild(
|
|
1477
|
+
el("p", null, "选择接收方式和保护级别,系统会生成一个可核验的 ZIP 交接包。"),
|
|
1478
|
+
);
|
|
1479
|
+
const invariant = el("div", "context-export-invariant");
|
|
1480
|
+
const lockIcon = el("i", "ri-lock-2-line");
|
|
1481
|
+
lockIcon.setAttribute("aria-hidden", "true");
|
|
1482
|
+
invariant.append(lockIcon, document.createTextNode(" 原运行保持不变"));
|
|
1483
|
+
heading.append(headingCopy, invariant);
|
|
1484
|
+
section.appendChild(heading);
|
|
1485
|
+
|
|
1486
|
+
const workspace = el("div", "context-export-workspace");
|
|
1487
|
+
const controls = el("div", "context-export-controls");
|
|
1488
|
+
const targetFieldset = document.createElement("fieldset");
|
|
1489
|
+
targetFieldset.className = "context-export-fieldset";
|
|
1490
|
+
targetFieldset.dataset.testid = "context-export-target";
|
|
1491
|
+
targetFieldset.appendChild(el("legend", null, "交给谁使用?"));
|
|
1492
|
+
const targetChoices = el("div", "context-export-target-grid");
|
|
1493
|
+
for (const [index, option] of CONTEXT_EXPORT_TARGETS.entries()) {
|
|
1494
|
+
const choice = el("label", "context-export-choice");
|
|
1495
|
+
const input = document.createElement("input");
|
|
1496
|
+
input.type = "radio";
|
|
1497
|
+
input.name = "context-export-target";
|
|
1498
|
+
input.value = option.value;
|
|
1499
|
+
input.checked = index === 0;
|
|
1500
|
+
const icon = el("i", option.icon);
|
|
1501
|
+
icon.setAttribute("aria-hidden", "true");
|
|
1502
|
+
const copy = el("span", "context-export-choice-copy");
|
|
1503
|
+
copy.append(
|
|
1504
|
+
el("strong", null, option.label),
|
|
1505
|
+
el("small", null, option.description),
|
|
1506
|
+
);
|
|
1507
|
+
choice.append(input, icon, copy);
|
|
1508
|
+
targetChoices.appendChild(choice);
|
|
1509
|
+
}
|
|
1510
|
+
targetFieldset.appendChild(targetChoices);
|
|
1511
|
+
controls.appendChild(targetFieldset);
|
|
1512
|
+
|
|
1513
|
+
const profileFieldset = document.createElement("fieldset");
|
|
1514
|
+
profileFieldset.className = "context-export-fieldset";
|
|
1515
|
+
profileFieldset.dataset.testid = "context-export-profile";
|
|
1516
|
+
profileFieldset.appendChild(el("legend", null, "如何保护内容?"));
|
|
1517
|
+
const profileChoices = el("div", "context-export-profile-grid");
|
|
1518
|
+
for (const [index, option] of CONTEXT_EXPORT_PROFILES.entries()) {
|
|
1519
|
+
const choice = el(
|
|
1520
|
+
"label",
|
|
1521
|
+
`context-export-profile-choice${option.value === "raw" ? " is-risk" : ""}`,
|
|
1522
|
+
);
|
|
1523
|
+
const input = document.createElement("input");
|
|
1524
|
+
input.type = "radio";
|
|
1525
|
+
input.name = "context-export-profile";
|
|
1526
|
+
input.value = option.value;
|
|
1527
|
+
input.checked = index === 0;
|
|
1528
|
+
const copy = el("span", "context-export-choice-copy");
|
|
1529
|
+
const titleRow = el("span", "context-export-profile-title");
|
|
1530
|
+
titleRow.append(
|
|
1531
|
+
el("strong", null, option.label),
|
|
1532
|
+
el("span", `context-export-profile-badge is-${option.value}`, option.badge),
|
|
1533
|
+
);
|
|
1534
|
+
copy.append(titleRow, el("small", null, option.description));
|
|
1535
|
+
choice.append(input, copy);
|
|
1536
|
+
profileChoices.appendChild(choice);
|
|
1537
|
+
}
|
|
1538
|
+
profileFieldset.appendChild(profileChoices);
|
|
1539
|
+
controls.appendChild(profileFieldset);
|
|
1540
|
+
|
|
1541
|
+
const rawAckLabel = el("label", "prompt-restart-field context-export-raw-ack");
|
|
1542
|
+
const rawAck = document.createElement("input");
|
|
1543
|
+
rawAck.type = "checkbox";
|
|
1544
|
+
rawAck.dataset.testid = "context-export-raw-ack";
|
|
1545
|
+
rawAckLabel.appendChild(rawAck);
|
|
1546
|
+
const rawAckCopy = el("span", null);
|
|
1547
|
+
rawAckCopy.append(
|
|
1548
|
+
el("strong", null, "确认导出未脱敏内容"),
|
|
1549
|
+
el("small", null, "我理解文件可能包含凭据、绝对路径和执行原文。"),
|
|
1550
|
+
);
|
|
1551
|
+
rawAckLabel.appendChild(rawAckCopy);
|
|
1552
|
+
rawAckLabel.hidden = true;
|
|
1553
|
+
controls.appendChild(rawAckLabel);
|
|
1554
|
+
workspace.appendChild(controls);
|
|
1555
|
+
|
|
1556
|
+
const ticket = el("aside", "context-export-ticket");
|
|
1557
|
+
ticket.setAttribute("aria-label", "交接包预览");
|
|
1558
|
+
ticket.setAttribute("aria-live", "polite");
|
|
1559
|
+
const ticketTop = el("div", "context-export-ticket-top");
|
|
1560
|
+
ticketTop.append(
|
|
1561
|
+
el("span", "context-export-ticket-type", "CONTEXT / ZIP"),
|
|
1562
|
+
el("span", "context-export-ticket-safety", "已脱敏"),
|
|
1563
|
+
);
|
|
1564
|
+
const ticketTitle = el("strong", "context-export-ticket-title", "通用 Agent 交接包");
|
|
1565
|
+
const ticketRows = el("dl", "context-export-ticket-rows");
|
|
1566
|
+
const appendTicketRow = (label, value, className) => {
|
|
1567
|
+
const term = el("dt", null, label);
|
|
1568
|
+
const detail = el("dd", className ?? null, value);
|
|
1569
|
+
ticketRows.append(term, detail);
|
|
1570
|
+
return detail;
|
|
1571
|
+
};
|
|
1572
|
+
const recipientValue = appendTicketRow("用途", "适合交给其他 Agent 或 LLM 继续处理");
|
|
1573
|
+
const contentsValue = appendTicketRow("包含", CONTEXT_EXPORT_TARGETS[0].contents, "is-mono");
|
|
1574
|
+
const protectionValue = appendTicketRow("保护", "自动隐藏匹配到的疑似凭据");
|
|
1575
|
+
const attemptValue = appendTicketRow(
|
|
1576
|
+
"来源",
|
|
1577
|
+
`${node.nodeId} · attempt ${selectedAttemptNumber(dagRunId, node) ?? 1}`,
|
|
1578
|
+
"is-mono",
|
|
1579
|
+
);
|
|
1580
|
+
ticket.append(
|
|
1581
|
+
ticketTop,
|
|
1582
|
+
el("span", "context-export-ticket-label", "即将生成"),
|
|
1583
|
+
ticketTitle,
|
|
1584
|
+
ticketRows,
|
|
1585
|
+
el("p", "context-export-ticket-foot", "附带 manifest 哈希,可核对来源与完整性"),
|
|
1586
|
+
);
|
|
1587
|
+
workspace.appendChild(ticket);
|
|
1588
|
+
section.appendChild(workspace);
|
|
1589
|
+
|
|
1590
|
+
const selectedValue = (name) =>
|
|
1591
|
+
section.querySelector(`input[name="${name}"]:checked`)?.value ?? "";
|
|
1592
|
+
const updatePreview = () => {
|
|
1593
|
+
const targetValue = selectedValue("context-export-target");
|
|
1594
|
+
const profileValue = selectedValue("context-export-profile");
|
|
1595
|
+
const target =
|
|
1596
|
+
CONTEXT_EXPORT_TARGETS.find((option) => option.value === targetValue) ??
|
|
1597
|
+
CONTEXT_EXPORT_TARGETS[0];
|
|
1598
|
+
const profile =
|
|
1599
|
+
CONTEXT_EXPORT_PROFILES.find((option) => option.value === profileValue) ??
|
|
1600
|
+
CONTEXT_EXPORT_PROFILES[0];
|
|
1601
|
+
ticketTitle.textContent = target.label;
|
|
1602
|
+
recipientValue.textContent = target.description;
|
|
1603
|
+
contentsValue.textContent = target.contents;
|
|
1604
|
+
protectionValue.textContent = profile.description;
|
|
1605
|
+
attemptValue.textContent = `${node.nodeId} · attempt ${selectedAttemptNumber(dagRunId, node) ?? 1}`;
|
|
1606
|
+
const safety = ticket.querySelector(".context-export-ticket-safety");
|
|
1607
|
+
if (safety) {
|
|
1608
|
+
safety.textContent = profileValue === "raw" ? "原始内容" : "已脱敏";
|
|
1609
|
+
safety.classList.toggle("is-risk", profileValue === "raw");
|
|
1610
|
+
}
|
|
1611
|
+
rawAckLabel.hidden = profileValue !== "raw";
|
|
1612
|
+
if (profileValue !== "raw") rawAck.checked = false;
|
|
1613
|
+
};
|
|
1614
|
+
for (const input of section.querySelectorAll(
|
|
1615
|
+
'input[name="context-export-target"], input[name="context-export-profile"]',
|
|
1616
|
+
)) {
|
|
1617
|
+
input.addEventListener("change", updatePreview);
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
const actions = el("div", "prompt-restart-actions");
|
|
1621
|
+
const submit = document.createElement("button");
|
|
1622
|
+
submit.type = "button";
|
|
1623
|
+
submit.className = "prompt-restart-submit context-export-submit";
|
|
1624
|
+
submit.dataset.testid = "context-export-submit";
|
|
1625
|
+
const submitIcon = el("i", "ri-download-cloud-2-line");
|
|
1626
|
+
submitIcon.setAttribute("aria-hidden", "true");
|
|
1627
|
+
submit.append(submitIcon, document.createTextNode(" 生成交接包并下载"));
|
|
1628
|
+
actions.appendChild(submit);
|
|
1629
|
+
section.appendChild(actions);
|
|
1630
|
+
const status = el("p", "prompt-restart-status", "");
|
|
1631
|
+
status.setAttribute("role", "status");
|
|
1632
|
+
status.setAttribute("aria-live", "polite");
|
|
1633
|
+
section.appendChild(status);
|
|
1634
|
+
const setStatus = (message, error = false) => {
|
|
1635
|
+
status.textContent = message;
|
|
1636
|
+
status.classList.toggle("prompt-restart-error", error);
|
|
1637
|
+
};
|
|
1638
|
+
submit.addEventListener("click", () => {
|
|
1639
|
+
void (async () => {
|
|
1640
|
+
const targetValue = selectedValue("context-export-target");
|
|
1641
|
+
const profileValue = selectedValue("context-export-profile");
|
|
1642
|
+
if (profileValue === "raw" && !rawAck.checked) {
|
|
1643
|
+
setStatus("原始导出前必须勾选风险确认。", true);
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
submit.disabled = true;
|
|
1647
|
+
try {
|
|
1648
|
+
setStatus("正在生成可验证 Context Bundle…");
|
|
1649
|
+
const clientRequestId = `inspect-context-export-${Date.now()}-${Math.random()
|
|
1650
|
+
.toString(36)
|
|
1651
|
+
.slice(2, 10)}`;
|
|
1652
|
+
const response = await postOperatorAction(
|
|
1653
|
+
"contextExport",
|
|
1654
|
+
{
|
|
1655
|
+
runId: dagRunId,
|
|
1656
|
+
nodeId: node.nodeId,
|
|
1657
|
+
attempt: selectedAttemptNumber(dagRunId, node) ?? 1,
|
|
1658
|
+
target: targetValue,
|
|
1659
|
+
profile: profileValue,
|
|
1660
|
+
rawAcknowledged: profileValue === "raw" && rawAck.checked,
|
|
1661
|
+
},
|
|
1662
|
+
clientRequestId,
|
|
1663
|
+
);
|
|
1664
|
+
const operationId = response.body?.operationId;
|
|
1665
|
+
if (!response.ok || !operationId) {
|
|
1666
|
+
throw new Error(response.body?.error?.message ?? "导出操作未被接受");
|
|
1667
|
+
}
|
|
1668
|
+
const operation = await pollOperationToTerminal(operationId, (message) =>
|
|
1669
|
+
setStatus(message.replace("续跑", "导出")),
|
|
1670
|
+
);
|
|
1671
|
+
if (operation?.state !== "succeeded" || !operation.result?.downloadUrl) {
|
|
1672
|
+
throw new Error(operation?.errorMessage ?? "导出未成功完成");
|
|
1673
|
+
}
|
|
1674
|
+
setStatus("Bundle 已生成,正在安全下载…");
|
|
1675
|
+
const downloaded = await downloadContextExport(operation.result.downloadUrl);
|
|
1676
|
+
const objectUrl = URL.createObjectURL(downloaded.blob);
|
|
1677
|
+
const link = document.createElement("a");
|
|
1678
|
+
link.href = objectUrl;
|
|
1679
|
+
link.download = downloaded.filename;
|
|
1680
|
+
document.body.appendChild(link);
|
|
1681
|
+
link.click();
|
|
1682
|
+
link.remove();
|
|
1683
|
+
URL.revokeObjectURL(objectUrl);
|
|
1684
|
+
setStatus(
|
|
1685
|
+
`下载完成 · ${operation.result.bundleId} · ${new Intl.NumberFormat("zh-CN").format(operation.result.bytes)} bytes\nSHA-256 ${operation.result.bundleSha256}`,
|
|
1686
|
+
);
|
|
1687
|
+
} catch (error) {
|
|
1688
|
+
setStatus(transferErrorStatusText(error, "导出未成功完成"), true);
|
|
1689
|
+
} finally {
|
|
1690
|
+
submit.disabled = false;
|
|
1691
|
+
}
|
|
1692
|
+
})();
|
|
1693
|
+
});
|
|
1694
|
+
updatePreview();
|
|
1695
|
+
zone.appendChild(section);
|
|
1696
|
+
return zone;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
function createDagActionCard({ eyebrow, title, description, icon, className }) {
|
|
1700
|
+
const section = el("section", `dag-action-card ${className ?? ""}`.trim());
|
|
1701
|
+
const header = el("div", "dag-action-card-header");
|
|
1702
|
+
const iconBox = el("div", "dag-action-card-icon");
|
|
1703
|
+
const iconElement = el("i", icon);
|
|
1704
|
+
iconElement.setAttribute("aria-hidden", "true");
|
|
1705
|
+
iconBox.appendChild(iconElement);
|
|
1706
|
+
const copy = el("div", "dag-action-card-copy");
|
|
1707
|
+
copy.append(
|
|
1708
|
+
el("span", "dag-action-eyebrow", eyebrow),
|
|
1709
|
+
el("h4", null, title),
|
|
1710
|
+
el("p", null, description),
|
|
1711
|
+
);
|
|
1712
|
+
header.append(iconBox, copy);
|
|
1713
|
+
const body = el("div", "dag-action-card-body");
|
|
1714
|
+
section.append(header, body);
|
|
1715
|
+
return { section, body };
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
function buildDagActionAvailability({ title, description, reasonCode, tone = "neutral" }) {
|
|
1719
|
+
const panel = el("div", `dag-action-availability is-${tone}`);
|
|
1720
|
+
const icon = el(
|
|
1721
|
+
"i",
|
|
1722
|
+
tone === "blocked"
|
|
1723
|
+
? "ri-forbid-2-line"
|
|
1724
|
+
: tone === "ready"
|
|
1725
|
+
? "ri-checkbox-circle-line"
|
|
1726
|
+
: "ri-information-line",
|
|
1727
|
+
);
|
|
1728
|
+
icon.setAttribute("aria-hidden", "true");
|
|
1729
|
+
const copy = el("div", null);
|
|
1730
|
+
copy.append(el("strong", null, title), el("p", null, description));
|
|
1731
|
+
if (reasonCode) {
|
|
1732
|
+
const label = contextTransferReasonLabel(reasonCode);
|
|
1733
|
+
if (label) copy.appendChild(el("p", "dag-action-reason-copy", label));
|
|
1734
|
+
copy.appendChild(el("code", null, reasonCode));
|
|
1735
|
+
}
|
|
1736
|
+
panel.append(icon, copy);
|
|
1737
|
+
return panel;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
function buildFullContentCta() {
|
|
1741
|
+
// Honest limitation note (review 2026-08-26): the context bundle exports
|
|
1742
|
+
// node *inputs*; it does not necessarily contain the full bytes of a
|
|
1743
|
+
// produced artifact or a revision candidate, so pointing the truncated
|
|
1744
|
+
// preview at the export flow would overpromise. State the bound plainly.
|
|
1745
|
+
return el(
|
|
1746
|
+
"p",
|
|
1747
|
+
"artifact-content-preview-full-cta",
|
|
1748
|
+
"预览有截断;当前版本暂不提供完整文件下载。",
|
|
1749
|
+
);
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
function createArtifactContentPreview(
|
|
1753
|
+
dagRunId,
|
|
1754
|
+
nodeId,
|
|
1755
|
+
resolveArtifact,
|
|
1756
|
+
{ label = "查看文件内容", testId = "artifact-file-preview" } = {},
|
|
1757
|
+
) {
|
|
1758
|
+
const details = document.createElement("details");
|
|
1759
|
+
details.className = "artifact-content-preview";
|
|
1760
|
+
details.dataset.testid = testId;
|
|
1761
|
+
const summary = document.createElement("summary");
|
|
1762
|
+
const icon = el("i", "ri-eye-line");
|
|
1763
|
+
icon.setAttribute("aria-hidden", "true");
|
|
1764
|
+
const summaryText = el("span", null, label);
|
|
1765
|
+
summary.append(icon, summaryText);
|
|
1766
|
+
details.appendChild(summary);
|
|
1767
|
+
const host = el("div", "artifact-content-preview-body");
|
|
1768
|
+
details.appendChild(host);
|
|
1769
|
+
let loadedArtifactId = null;
|
|
1770
|
+
let requestVersion = 0;
|
|
1771
|
+
|
|
1772
|
+
const reset = () => {
|
|
1773
|
+
requestVersion += 1;
|
|
1774
|
+
loadedArtifactId = null;
|
|
1775
|
+
details.open = false;
|
|
1776
|
+
clearNode(host);
|
|
1777
|
+
};
|
|
1778
|
+
const renderStatus = (message, error = false) => {
|
|
1779
|
+
clearNode(host);
|
|
1780
|
+
const status = el(
|
|
1781
|
+
"p",
|
|
1782
|
+
error ? "artifact-content-preview-error" : "muted",
|
|
1783
|
+
message,
|
|
1784
|
+
);
|
|
1785
|
+
status.setAttribute("role", error ? "alert" : "status");
|
|
1786
|
+
status.setAttribute("aria-live", "polite");
|
|
1787
|
+
host.appendChild(status);
|
|
1788
|
+
};
|
|
1789
|
+
const load = async () => {
|
|
1790
|
+
const artifact = resolveArtifact();
|
|
1791
|
+
if (!artifact?.artifactId) {
|
|
1792
|
+
renderStatus("没有可预览的文件。", true);
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1795
|
+
if (loadedArtifactId === artifact.artifactId) return;
|
|
1796
|
+
const version = ++requestVersion;
|
|
1797
|
+
renderStatus("正在读取并核验文件内容…");
|
|
1798
|
+
const result = await fetchDagNodeArtifactPreview(
|
|
1799
|
+
dagRunId,
|
|
1800
|
+
nodeId,
|
|
1801
|
+
artifact.artifactId,
|
|
1802
|
+
);
|
|
1803
|
+
if (version !== requestVersion || !details.isConnected) return;
|
|
1804
|
+
if (!result.ok || !result.body) {
|
|
1805
|
+
renderStatus(result.body?.error || "文件内容暂时无法预览。", true);
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
loadedArtifactId = artifact.artifactId;
|
|
1809
|
+
const data = result.body;
|
|
1810
|
+
clearNode(host);
|
|
1811
|
+
const header = el("div", "artifact-content-preview-meta");
|
|
1812
|
+
const metaChildren = [
|
|
1813
|
+
el("code", null, data.path ?? artifact.path ?? artifact.artifactId),
|
|
1814
|
+
el(
|
|
1815
|
+
"span",
|
|
1816
|
+
null,
|
|
1817
|
+
`${data.mediaType ?? "unknown"} · ${new Intl.NumberFormat("zh-CN").format(data.sourceBytes ?? 0)} bytes`,
|
|
1818
|
+
),
|
|
1819
|
+
];
|
|
1820
|
+
if (typeof data.sha256 === "string" && data.sha256.length >= 12) {
|
|
1821
|
+
const sha = el(
|
|
1822
|
+
"span",
|
|
1823
|
+
null,
|
|
1824
|
+
` · sha256 ${data.sha256.slice(0, 12)}…`,
|
|
1825
|
+
);
|
|
1826
|
+
sha.title = data.sha256;
|
|
1827
|
+
metaChildren.push(sha);
|
|
1828
|
+
}
|
|
1829
|
+
header.append(...metaChildren);
|
|
1830
|
+
host.appendChild(header);
|
|
1831
|
+
if (data.previewKind !== "text" || typeof data.content !== "string") {
|
|
1832
|
+
host.appendChild(
|
|
1833
|
+
el(
|
|
1834
|
+
"p",
|
|
1835
|
+
"artifact-content-preview-unavailable",
|
|
1836
|
+
"该文件的媒体类型不支持安全内嵌显示;路径、大小和 SHA-256 已核验。",
|
|
1837
|
+
),
|
|
1838
|
+
);
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1841
|
+
const normalizedMedia = String(data.mediaType ?? "").toLowerCase();
|
|
1842
|
+
if (normalizedMedia.includes("markdown")) {
|
|
1843
|
+
const documentPreview = el("div", "artifact-content-preview-document");
|
|
1844
|
+
documentPreview.appendChild(renderMarkdown(data.content));
|
|
1845
|
+
host.appendChild(documentPreview);
|
|
1846
|
+
} else {
|
|
1847
|
+
const pre = el("pre", "artifact-content-preview-code");
|
|
1848
|
+
pre.textContent = normalizedMedia.includes("json")
|
|
1849
|
+
? prettyJsonBlock(data.content) ?? data.content
|
|
1850
|
+
: data.content;
|
|
1851
|
+
host.appendChild(pre);
|
|
1852
|
+
}
|
|
1853
|
+
const notes = [];
|
|
1854
|
+
if (data.redacted) notes.push("疑似凭据已脱敏");
|
|
1855
|
+
if (data.truncated) {
|
|
1856
|
+
notes.push(
|
|
1857
|
+
`仅显示前 ${new Intl.NumberFormat("zh-CN").format(data.maxBytes ?? 0)} bytes`,
|
|
1858
|
+
);
|
|
1859
|
+
}
|
|
1860
|
+
if (notes.length > 0) {
|
|
1861
|
+
host.appendChild(el("p", "artifact-content-preview-note", notes.join(" · ")));
|
|
1862
|
+
}
|
|
1863
|
+
if (data.truncated) {
|
|
1864
|
+
host.appendChild(buildFullContentCta());
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
details.addEventListener("toggle", () => {
|
|
1868
|
+
if (details.open) void load();
|
|
1869
|
+
});
|
|
1870
|
+
return { element: details, reset };
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
function buildArtifactRevisionSection(dagRunId, node) {
|
|
1874
|
+
const { section, body } = createDagActionCard({
|
|
1875
|
+
eyebrow: "产出修订",
|
|
1876
|
+
title: "替换产出后继续运行",
|
|
1877
|
+
description: "上传一个候选新版本,先校验差异和影响范围,再决定是否创建新的运行。",
|
|
1878
|
+
icon: "ri-file-transfer-line",
|
|
1879
|
+
className: "artifact-revision-box",
|
|
1880
|
+
});
|
|
1881
|
+
section.dataset.actionSection = "artifact-revision";
|
|
1882
|
+
body.appendChild(
|
|
1883
|
+
buildDagActionAvailability({
|
|
1884
|
+
title: "正在检查是否可以安全修订",
|
|
1885
|
+
description: "读取已冻结的产出关系和修订规则。",
|
|
1886
|
+
}),
|
|
1887
|
+
);
|
|
1888
|
+
void (async () => {
|
|
1889
|
+
const response = await fetchDagNodeArtifacts(dagRunId, node.nodeId);
|
|
1890
|
+
clearNode(body);
|
|
1891
|
+
if (!response.ok || response.body?.binding?.available !== true) {
|
|
1892
|
+
body.appendChild(
|
|
1893
|
+
buildDagActionAvailability({
|
|
1894
|
+
tone: "blocked",
|
|
1895
|
+
title: "这个运行暂时不能安全修订产出",
|
|
1896
|
+
description:
|
|
1897
|
+
"缺少结构化的产出关系,系统无法可靠判断哪些后续节点会受影响,也不会根据文件名或提示词猜测。",
|
|
1898
|
+
reasonCode:
|
|
1899
|
+
response.body?.reasonCode ??
|
|
1900
|
+
response.body?.binding?.reasonCode ??
|
|
1901
|
+
"ARTIFACT_BINDING_UNAVAILABLE",
|
|
1902
|
+
}),
|
|
1903
|
+
);
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
const eligible = (response.body.produces ?? []).filter(
|
|
1907
|
+
(artifact) => artifact.revision?.eligible === true,
|
|
1908
|
+
);
|
|
1909
|
+
if (eligible.length === 0) {
|
|
1910
|
+
body.appendChild(
|
|
1911
|
+
buildDagActionAvailability({
|
|
1912
|
+
title: "这个节点没有可替换的已生成文件",
|
|
1913
|
+
description:
|
|
1914
|
+
"当前节点没有同时满足“已经生成”和“允许替换”的产出。失败节点仍可在下方修改提示词后重跑。",
|
|
1915
|
+
}),
|
|
1916
|
+
);
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
body.appendChild(
|
|
1920
|
+
buildDagActionAvailability({
|
|
1921
|
+
tone: "ready",
|
|
1922
|
+
title: `可修订 ${eligible.length} 个产出`,
|
|
1923
|
+
description: "父运行不会被修改;确认后会创建一条新的派生运行。",
|
|
1924
|
+
}),
|
|
1925
|
+
);
|
|
1926
|
+
const form = el("div", "dag-action-form artifact-revision-form");
|
|
1927
|
+
const artifactLabel = el("label", "prompt-restart-field");
|
|
1928
|
+
artifactLabel.appendChild(el("span", "dag-action-field-label", "选择要替换的产出"));
|
|
1929
|
+
const artifactSelect = document.createElement("select");
|
|
1930
|
+
artifactSelect.className = "prompt-restart-mode-select";
|
|
1931
|
+
artifactSelect.dataset.testid = "artifact-revision-artifact";
|
|
1932
|
+
for (const artifact of eligible) {
|
|
1933
|
+
const option = document.createElement("option");
|
|
1934
|
+
option.value = artifact.artifactId;
|
|
1935
|
+
option.textContent = `${artifact.artifactId} · ${artifact.path}`;
|
|
1936
|
+
artifactSelect.appendChild(option);
|
|
1937
|
+
}
|
|
1938
|
+
artifactLabel.appendChild(artifactSelect);
|
|
1939
|
+
form.appendChild(artifactLabel);
|
|
1940
|
+
const currentArtifactPreview = createArtifactContentPreview(
|
|
1941
|
+
dagRunId,
|
|
1942
|
+
node.nodeId,
|
|
1943
|
+
() => eligible.find((artifact) => artifact.artifactId === artifactSelect.value),
|
|
1944
|
+
{
|
|
1945
|
+
label: "查看当前文件",
|
|
1946
|
+
testId: ARTIFACT_FILE_PREVIEW_SURFACES.revisionSelection,
|
|
1947
|
+
},
|
|
1948
|
+
);
|
|
1949
|
+
form.appendChild(currentArtifactPreview.element);
|
|
1950
|
+
artifactSelect.addEventListener("change", currentArtifactPreview.reset);
|
|
1951
|
+
const fileLabel = el("label", "prompt-restart-field");
|
|
1952
|
+
fileLabel.appendChild(el("span", "dag-action-field-label", "选择新文件(最多 10 MiB)"));
|
|
1953
|
+
const file = document.createElement("input");
|
|
1954
|
+
file.type = "file";
|
|
1955
|
+
file.className = "dag-action-file-input";
|
|
1956
|
+
file.dataset.testid = "artifact-revision-file";
|
|
1957
|
+
fileLabel.appendChild(file);
|
|
1958
|
+
form.appendChild(fileLabel);
|
|
1959
|
+
const reasonLabel = el("label", "prompt-restart-field");
|
|
1960
|
+
reasonLabel.appendChild(el("span", "dag-action-field-label", "为什么要替换?"));
|
|
1961
|
+
const reason = document.createElement("textarea");
|
|
1962
|
+
reason.className = "prompt-restart-textarea";
|
|
1963
|
+
reason.rows = 3;
|
|
1964
|
+
reason.placeholder = "说明为什么要替换此产物";
|
|
1965
|
+
reason.dataset.testid = "artifact-revision-reason";
|
|
1966
|
+
reasonLabel.appendChild(reason);
|
|
1967
|
+
form.appendChild(reasonLabel);
|
|
1968
|
+
const actions = el("div", "prompt-restart-actions");
|
|
1969
|
+
const preview = document.createElement("button");
|
|
1970
|
+
preview.type = "button";
|
|
1971
|
+
preview.className = "prompt-restart-submit dag-action-primary";
|
|
1972
|
+
const previewIcon = el("i", "ri-radar-line");
|
|
1973
|
+
previewIcon.setAttribute("aria-hidden", "true");
|
|
1974
|
+
preview.append(previewIcon, document.createTextNode(" 校验文件并预览影响"));
|
|
1975
|
+
preview.dataset.testid = "artifact-revision-preview";
|
|
1976
|
+
actions.appendChild(preview);
|
|
1977
|
+
form.appendChild(actions);
|
|
1978
|
+
const status = el("p", "prompt-restart-status", "");
|
|
1979
|
+
status.setAttribute("role", "status");
|
|
1980
|
+
status.setAttribute("aria-live", "polite");
|
|
1981
|
+
form.appendChild(status);
|
|
1982
|
+
const planHost = el("div", "artifact-revision-plan");
|
|
1983
|
+
form.appendChild(planHost);
|
|
1984
|
+
body.appendChild(form);
|
|
1985
|
+
const setStatus = (message, error = false) => {
|
|
1986
|
+
status.textContent = message;
|
|
1987
|
+
status.classList.toggle("prompt-restart-error", error);
|
|
1988
|
+
};
|
|
1989
|
+
preview.addEventListener("click", () => {
|
|
1990
|
+
void (async () => {
|
|
1991
|
+
const selected = eligible.find((artifact) => artifact.artifactId === artifactSelect.value);
|
|
1992
|
+
const selectedFile = file.files?.[0];
|
|
1993
|
+
if (!selected || !selectedFile) {
|
|
1994
|
+
setStatus("请选择一个替换文件。", true);
|
|
1995
|
+
return;
|
|
1996
|
+
}
|
|
1997
|
+
if (selectedFile.size > 10 * 1024 * 1024) {
|
|
1998
|
+
setStatus("文件超过 10 MiB 限制。", true);
|
|
1999
|
+
return;
|
|
2000
|
+
}
|
|
2001
|
+
if (!reason.value.trim()) {
|
|
2002
|
+
setStatus("需要填写派生运行原因。", true);
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
2005
|
+
preview.disabled = true;
|
|
2006
|
+
clearNode(planHost);
|
|
2007
|
+
try {
|
|
2008
|
+
const dataUrl = await new Promise((resolve, reject) => {
|
|
2009
|
+
const reader = new FileReader();
|
|
2010
|
+
reader.onerror = () => reject(reader.error ?? new Error("读取文件失败"));
|
|
2011
|
+
reader.onload = () => resolve(String(reader.result ?? ""));
|
|
2012
|
+
reader.readAsDataURL(selectedFile);
|
|
2013
|
+
});
|
|
2014
|
+
const candidateBase64 = String(dataUrl).split(",", 2)[1] ?? "";
|
|
2015
|
+
setStatus("正在校验候选字节、schema 与 diff…");
|
|
2016
|
+
const stageId = `artifact-stage-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2017
|
+
const staged = await postOperatorAction(
|
|
2018
|
+
"artifactRevisionStage",
|
|
2019
|
+
{
|
|
2020
|
+
runId: dagRunId,
|
|
2021
|
+
nodeId: node.nodeId,
|
|
2022
|
+
artifactId: selected.artifactId,
|
|
2023
|
+
mediaType: selected.mediaType,
|
|
2024
|
+
candidateBase64,
|
|
2025
|
+
},
|
|
2026
|
+
stageId,
|
|
2027
|
+
);
|
|
2028
|
+
if (!staged.ok || !staged.body?.operationId) throw new Error(staged.body?.error?.message ?? "修订 staging 失败");
|
|
2029
|
+
const stageOp = await pollOperationToTerminal(staged.body.operationId, (message) =>
|
|
2030
|
+
setStatus(message.replace("续跑", "修订校验")),
|
|
2031
|
+
);
|
|
2032
|
+
const revision = stageOp?.result?.revision;
|
|
2033
|
+
if (stageOp?.state !== "succeeded" || !revision?.revisionId) {
|
|
2034
|
+
throw new Error(stageOp?.errorMessage ?? "修订校验失败");
|
|
2035
|
+
}
|
|
2036
|
+
setStatus("校验通过,正在计算 direct consumers 与传递影响闭包…");
|
|
2037
|
+
const planId = `artifact-plan-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2038
|
+
const planned = await postOperatorAction(
|
|
2039
|
+
"artifactRevisionPlan",
|
|
2040
|
+
{ runId: dagRunId, artifactId: selected.artifactId, revisionId: revision.revisionId },
|
|
2041
|
+
planId,
|
|
2042
|
+
);
|
|
2043
|
+
if (!planned.ok || !planned.body?.operationId) throw new Error(planned.body?.error?.message ?? "影响预览失败");
|
|
2044
|
+
const planOp = await pollOperationToTerminal(planned.body.operationId, (message) =>
|
|
2045
|
+
setStatus(message.replace("续跑", "影响分析")),
|
|
2046
|
+
);
|
|
2047
|
+
const plan = planOp?.result?.plan;
|
|
2048
|
+
if (!plan) throw new Error(planOp?.errorMessage ?? "影响预览失败");
|
|
2049
|
+
planHost.appendChild(el("h5", null, "修订与影响预览"));
|
|
2050
|
+
planHost.appendChild(
|
|
2051
|
+
transparencyMetaList([
|
|
2052
|
+
["修订 ID", revision.revisionId],
|
|
2053
|
+
["候选文件 SHA-256", revision.candidate?.sha256],
|
|
2054
|
+
["差异类型", revision.diff?.kind],
|
|
2055
|
+
["风险级别", plan.risk],
|
|
2056
|
+
["直接使用者", plan.impact?.directConsumerNodeIds?.join(", ") || "无"],
|
|
2057
|
+
["需要重跑", plan.impact?.affectedNodeIds?.join(", ") || "无"],
|
|
2058
|
+
["可以沿用", plan.impact?.importedNodeIds?.join(", ") || "无"],
|
|
2059
|
+
["计划哈希", plan.planHash],
|
|
2060
|
+
]),
|
|
2061
|
+
);
|
|
2062
|
+
if (revision.diff?.summary) {
|
|
2063
|
+
const diff = document.createElement("pre");
|
|
2064
|
+
diff.className = "prompt-restart-readonly";
|
|
2065
|
+
diff.textContent = revision.diff.summary;
|
|
2066
|
+
planHost.appendChild(diff);
|
|
2067
|
+
}
|
|
2068
|
+
if (plan.eligible !== true) {
|
|
2069
|
+
setStatus(
|
|
2070
|
+
`派生运行被阻断:${formatContextTransferReasonList(plan.blockedReasons) ?? "当前不满足继续运行的条件"}`,
|
|
2071
|
+
true,
|
|
2072
|
+
);
|
|
2073
|
+
return;
|
|
2074
|
+
}
|
|
2075
|
+
const execute = document.createElement("button");
|
|
2076
|
+
execute.type = "button";
|
|
2077
|
+
execute.className = "prompt-restart-submit dag-action-primary";
|
|
2078
|
+
execute.textContent = "确认并创建新运行";
|
|
2079
|
+
execute.dataset.testid = "artifact-revision-execute";
|
|
2080
|
+
planHost.appendChild(execute);
|
|
2081
|
+
execute.addEventListener("click", () => {
|
|
2082
|
+
void (async () => {
|
|
2083
|
+
execute.disabled = true;
|
|
2084
|
+
try {
|
|
2085
|
+
setStatus("正在执行受影响闭包;父 run 保持不可变…");
|
|
2086
|
+
const executeId = `artifact-execute-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2087
|
+
const accepted = await postOperatorAction(
|
|
2088
|
+
"artifactRevisionExecute",
|
|
2089
|
+
{
|
|
2090
|
+
runId: dagRunId,
|
|
2091
|
+
artifactId: selected.artifactId,
|
|
2092
|
+
revisionId: revision.revisionId,
|
|
2093
|
+
planHash: plan.planHash,
|
|
2094
|
+
reason: reason.value.trim(),
|
|
2095
|
+
},
|
|
2096
|
+
executeId,
|
|
2097
|
+
);
|
|
2098
|
+
if (!accepted.ok || !accepted.body?.operationId) throw new Error(accepted.body?.error?.message ?? "派生运行未被接受");
|
|
2099
|
+
const operation = await pollOperationToTerminal(accepted.body.operationId, setStatus);
|
|
2100
|
+
const childRunId = operation?.result?.newRunId;
|
|
2101
|
+
if (childRunId) {
|
|
2102
|
+
const open = document.createElement("button");
|
|
2103
|
+
open.type = "button";
|
|
2104
|
+
open.className =
|
|
2105
|
+
"prompt-restart-submit dag-action-secondary";
|
|
2106
|
+
open.textContent =
|
|
2107
|
+
operation?.state === "succeeded"
|
|
2108
|
+
? "打开新运行"
|
|
2109
|
+
: "打开失败的新运行";
|
|
2110
|
+
open.addEventListener("click", () => {
|
|
2111
|
+
window.location.hash = `#/dag/${encodeURIComponent(childRunId)}`;
|
|
2112
|
+
});
|
|
2113
|
+
planHost.appendChild(open);
|
|
2114
|
+
}
|
|
2115
|
+
if (operation?.state !== "succeeded" || !operation.result?.newRunId) {
|
|
2116
|
+
throw new Error(operation?.errorMessage ?? operation?.result?.message ?? "派生运行失败");
|
|
2117
|
+
}
|
|
2118
|
+
setStatus(`派生运行完成:${operation.result.newRunId}`);
|
|
2119
|
+
} catch (error) {
|
|
2120
|
+
setStatus(transferErrorStatusText(error, "派生运行失败"), true);
|
|
2121
|
+
} finally {
|
|
2122
|
+
execute.disabled = false;
|
|
2123
|
+
}
|
|
2124
|
+
})();
|
|
2125
|
+
});
|
|
2126
|
+
setStatus("影响预览已冻结;确认后将重新规划并校验 plan hash。" );
|
|
2127
|
+
} catch (error) {
|
|
2128
|
+
setStatus(transferErrorStatusText(error, "影响预览失败"), true);
|
|
2129
|
+
} finally {
|
|
2130
|
+
preview.disabled = false;
|
|
2131
|
+
}
|
|
2132
|
+
})();
|
|
2133
|
+
});
|
|
2134
|
+
})();
|
|
2135
|
+
return section;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
function buildDagActionIntro(node) {
|
|
2139
|
+
const intro = el("header", "dag-action-page-intro");
|
|
2140
|
+
const copy = el("div", null);
|
|
2141
|
+
copy.append(
|
|
2142
|
+
el("span", "dag-action-eyebrow", "节点操作"),
|
|
2143
|
+
el("h4", null, "选择下一步"),
|
|
2144
|
+
el(
|
|
2145
|
+
"p",
|
|
2146
|
+
null,
|
|
2147
|
+
"重跑会创建新的运行;当前运行及其已经保存的事实始终保持不变。",
|
|
2148
|
+
),
|
|
2149
|
+
);
|
|
2150
|
+
const state = el("span", "dag-action-node-state", node.status ?? "unknown");
|
|
2151
|
+
intro.append(copy, state);
|
|
2152
|
+
return intro;
|
|
2153
|
+
}
|
|
2154
|
+
|
|
1361
2155
|
async function renderPromptRestart(content, dagRunId, node) {
|
|
1362
2156
|
const nodeId = node.nodeId;
|
|
1363
2157
|
clearNode(content);
|
|
1364
|
-
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
2158
|
+
const intro = buildDagActionIntro(node);
|
|
2159
|
+
const revisionSection = buildArtifactRevisionSection(dagRunId, node);
|
|
2160
|
+
const { section: promptSection, body: promptBody } = createDagActionCard({
|
|
2161
|
+
eyebrow: "提示词重跑",
|
|
2162
|
+
title: "修改失败提示后重新执行",
|
|
2163
|
+
description: "仅失败节点可编辑提示词并从当前节点继续;其他节点只提供冻结提示查看。",
|
|
2164
|
+
icon: "ri-restart-line",
|
|
2165
|
+
className: "prompt-rerun-action-box",
|
|
2166
|
+
});
|
|
2167
|
+
promptSection.dataset.actionSection = "prompt-restart";
|
|
2168
|
+
promptBody.appendChild(
|
|
2169
|
+
buildDagActionAvailability({
|
|
2170
|
+
title: "正在读取节点提示",
|
|
2171
|
+
description: "检查冻结版本和历史失败候选。",
|
|
2172
|
+
}),
|
|
2173
|
+
);
|
|
2174
|
+
const exportSection = buildContextExportSection(dagRunId, node);
|
|
2175
|
+
const sections = new Map([
|
|
2176
|
+
["artifact-revision", revisionSection],
|
|
2177
|
+
["prompt-restart", promptSection],
|
|
2178
|
+
["context-export", exportSection],
|
|
2179
|
+
]);
|
|
2180
|
+
content.appendChild(intro);
|
|
2181
|
+
for (const sectionId of DAG_ACTION_SECTION_ORDER) {
|
|
2182
|
+
const section = sections.get(sectionId);
|
|
2183
|
+
if (section) content.appendChild(section);
|
|
2184
|
+
}
|
|
1369
2185
|
const input = await fetchDagNodeInput(dagRunId, nodeId);
|
|
1370
2186
|
if (
|
|
1371
2187
|
!content.isConnected ||
|
|
@@ -1375,20 +2191,27 @@ async function renderPromptRestart(content, dagRunId, node) {
|
|
|
1375
2191
|
) {
|
|
1376
2192
|
return;
|
|
1377
2193
|
}
|
|
1378
|
-
clearNode(
|
|
2194
|
+
clearNode(promptBody);
|
|
1379
2195
|
|
|
1380
2196
|
if (!input.ok || !input.body?.available) {
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
2197
|
+
promptBody.appendChild(
|
|
2198
|
+
buildDagActionAvailability({
|
|
2199
|
+
tone: "blocked",
|
|
2200
|
+
title: "无法读取这个节点的冻结提示",
|
|
2201
|
+
description: "当前不能安全预览或修改提示词。可以继续使用最下方的上下文导出。",
|
|
2202
|
+
}),
|
|
2203
|
+
);
|
|
1384
2204
|
return;
|
|
1385
2205
|
}
|
|
1386
2206
|
const frozenBasePrompt =
|
|
1387
2207
|
typeof input.body.prompt?.text === "string" ? input.body.prompt.text : "";
|
|
1388
2208
|
if (!frozenBasePrompt) {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
2209
|
+
promptBody.appendChild(
|
|
2210
|
+
buildDagActionAvailability({
|
|
2211
|
+
title: "这个节点没有冻结提示",
|
|
2212
|
+
description: "因此不能从这里修改提示词重跑。",
|
|
2213
|
+
}),
|
|
2214
|
+
);
|
|
1392
2215
|
return;
|
|
1393
2216
|
}
|
|
1394
2217
|
const promptCandidateOptions = buildPromptRestartCandidateOptions(
|
|
@@ -1398,7 +2221,9 @@ async function renderPromptRestart(content, dagRunId, node) {
|
|
|
1398
2221
|
let selectedCandidate = promptCandidateOptions[0];
|
|
1399
2222
|
const historicalCandidatesMissing = Array.isArray(input.body.warnings)
|
|
1400
2223
|
? input.body.warnings.some((warning) =>
|
|
1401
|
-
String(warning).startsWith(
|
|
2224
|
+
String(warning).startsWith(
|
|
2225
|
+
"Failed prompt candidate missing for attempt ",
|
|
2226
|
+
),
|
|
1402
2227
|
)
|
|
1403
2228
|
: false;
|
|
1404
2229
|
|
|
@@ -1438,18 +2263,19 @@ async function renderPromptRestart(content, dagRunId, node) {
|
|
|
1438
2263
|
});
|
|
1439
2264
|
panel.appendChild(picker.field);
|
|
1440
2265
|
panel.appendChild(promptCard.card);
|
|
1441
|
-
|
|
2266
|
+
promptBody.appendChild(panel);
|
|
1442
2267
|
return;
|
|
1443
2268
|
}
|
|
1444
2269
|
|
|
1445
2270
|
if (input.body.prompt?.truncated === true) {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
2271
|
+
promptBody.appendChild(
|
|
2272
|
+
buildDagActionAvailability({
|
|
2273
|
+
tone: "blocked",
|
|
2274
|
+
title: "冻结提示不完整,无法安全编辑",
|
|
2275
|
+
description:
|
|
2276
|
+
"为避免用截断文本覆盖完整提示,请改用 CLI:dag rerun --prompt-override。",
|
|
2277
|
+
}),
|
|
1450
2278
|
);
|
|
1451
|
-
error.setAttribute("role", "alert");
|
|
1452
|
-
content.appendChild(error);
|
|
1453
2279
|
return;
|
|
1454
2280
|
}
|
|
1455
2281
|
|
|
@@ -1576,7 +2402,7 @@ async function renderPromptRestart(content, dagRunId, node) {
|
|
|
1576
2402
|
row.appendChild(submit);
|
|
1577
2403
|
box.appendChild(row);
|
|
1578
2404
|
|
|
1579
|
-
|
|
2405
|
+
promptBody.appendChild(box);
|
|
1580
2406
|
|
|
1581
2407
|
const setStatus = (text, isError = false) => {
|
|
1582
2408
|
status.textContent = text ?? "";
|
|
@@ -1590,8 +2416,7 @@ async function renderPromptRestart(content, dagRunId, node) {
|
|
|
1590
2416
|
return;
|
|
1591
2417
|
}
|
|
1592
2418
|
const mode = modeSelect.value === "replace" ? "replace" : "append";
|
|
1593
|
-
const prompt =
|
|
1594
|
-
mode === "append" ? addendumArea.value : replaceArea.value;
|
|
2419
|
+
const prompt = mode === "append" ? addendumArea.value : replaceArea.value;
|
|
1595
2420
|
const reason = reasonArea.value.trim();
|
|
1596
2421
|
if (!prompt.trim()) {
|
|
1597
2422
|
setStatus(
|
|
@@ -1625,7 +2450,7 @@ async function renderPromptRestart(content, dagRunId, node) {
|
|
|
1625
2450
|
if (!planRes.ok || plan?.eligible !== true || !plan?.planHash) {
|
|
1626
2451
|
setStatus(
|
|
1627
2452
|
planRes.body?.error?.message ??
|
|
1628
|
-
plan?.blockedReasons
|
|
2453
|
+
formatContextTransferReasonList(plan?.blockedReasons) ??
|
|
1629
2454
|
"资格预检未通过。",
|
|
1630
2455
|
true,
|
|
1631
2456
|
);
|
|
@@ -1714,10 +2539,325 @@ async function pollOperationToTerminal(operationId, onProgress) {
|
|
|
1714
2539
|
return null;
|
|
1715
2540
|
}
|
|
1716
2541
|
|
|
1717
|
-
function
|
|
1718
|
-
|
|
1719
|
-
|
|
2542
|
+
function transparencyMetaList(rows) {
|
|
2543
|
+
const dl = el("dl", "node-input-summary node-transparency-summary");
|
|
2544
|
+
for (const [label, value] of rows) {
|
|
2545
|
+
if (value == null || value === "") continue;
|
|
2546
|
+
appendMetaRow(dl, label, value, null);
|
|
2547
|
+
}
|
|
2548
|
+
return dl;
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
function renderNodeOverview(content, dagRunId, node) {
|
|
2552
|
+
const root = el("div", "node-transparency-root");
|
|
2553
|
+
root.appendChild(
|
|
2554
|
+
el("p", "node-input-semantics", "本页只展示当前运行已持久化的节点事实。"),
|
|
2555
|
+
);
|
|
2556
|
+
const summary = el("section", "node-input-section");
|
|
2557
|
+
summary.appendChild(el("h4", null, "节点事实"));
|
|
2558
|
+
summary.appendChild(
|
|
2559
|
+
transparencyMetaList([
|
|
2560
|
+
["run", dagRunId],
|
|
2561
|
+
["node", node.nodeId],
|
|
2562
|
+
["status", node.status ?? "unknown"],
|
|
2563
|
+
["executor", node.executor ?? "unknown"],
|
|
2564
|
+
["model", node.model ?? null],
|
|
2565
|
+
["rank", node.rank ?? null],
|
|
2566
|
+
["origin", node.originKind ?? "unknown"],
|
|
2567
|
+
["duration", node.durationMs != null ? formatMs(node.durationMs) : null],
|
|
2568
|
+
]),
|
|
2569
|
+
);
|
|
2570
|
+
root.appendChild(summary);
|
|
2571
|
+
const semantics = el("section", "node-input-section");
|
|
2572
|
+
semantics.appendChild(el("h4", null, "事实阶段"));
|
|
2573
|
+
semantics.appendChild(
|
|
2574
|
+
el(
|
|
2575
|
+
"p",
|
|
2576
|
+
"muted",
|
|
2577
|
+
"输入页是 frozen declaration;有效上下文页是 dispatch-time receipt;产物页是执行后 materialization。缺失阶段会明确标记,不用预览冒充事实。",
|
|
2578
|
+
),
|
|
2579
|
+
);
|
|
2580
|
+
root.appendChild(semantics);
|
|
2581
|
+
content.appendChild(root);
|
|
2582
|
+
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "overview");
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
function selectedAttemptNumber(dagRunId, node) {
|
|
2586
|
+
const key = effectiveExecutionKey(dagRunId, node);
|
|
2587
|
+
const match = /^attempt-(\d+)$/.exec(key ?? "");
|
|
2588
|
+
return match ? Number(match[1]) : undefined;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
async function renderEffectiveContext(content, dagRunId, node) {
|
|
2592
|
+
content.appendChild(el("p", "muted", "正在加载有效上下文事实…"));
|
|
2593
|
+
const result = await fetchDagNodeContext(
|
|
2594
|
+
dagRunId,
|
|
2595
|
+
node.nodeId,
|
|
2596
|
+
selectedAttemptNumber(dagRunId, node),
|
|
2597
|
+
);
|
|
2598
|
+
if (
|
|
2599
|
+
!content.isConnected ||
|
|
2600
|
+
content.dataset.dagRunId !== String(dagRunId) ||
|
|
2601
|
+
content.dataset.dagNodeId !== String(node.nodeId) ||
|
|
2602
|
+
activeInspectorTab() !== "context"
|
|
2603
|
+
)
|
|
2604
|
+
return;
|
|
2605
|
+
clearNode(content);
|
|
2606
|
+
if (!result.ok || !result.body) {
|
|
2607
|
+
const error = el(
|
|
2608
|
+
"p",
|
|
2609
|
+
"node-input-error",
|
|
2610
|
+
result.body?.error || "无法加载有效上下文事实。",
|
|
2611
|
+
);
|
|
2612
|
+
error.setAttribute("role", "alert");
|
|
2613
|
+
content.appendChild(error);
|
|
2614
|
+
return;
|
|
2615
|
+
}
|
|
2616
|
+
const data = result.body;
|
|
2617
|
+
const receipt = data.effectiveContext;
|
|
2618
|
+
const root = el("div", "node-transparency-root");
|
|
2619
|
+
root.appendChild(
|
|
2620
|
+
transparencyMetaList([
|
|
2621
|
+
["attempt", data.attempt],
|
|
2622
|
+
["declared", data.declared?.status],
|
|
2623
|
+
["dispatched", data.dispatched?.status],
|
|
2624
|
+
["node status", data.dispatched?.nodeStatus],
|
|
2625
|
+
]),
|
|
2626
|
+
);
|
|
2627
|
+
if (receipt?.status !== "captured") {
|
|
2628
|
+
const missing = el("div", "node-transparency-omission");
|
|
2629
|
+
missing.appendChild(
|
|
2630
|
+
el(
|
|
2631
|
+
"h4",
|
|
2632
|
+
null,
|
|
2633
|
+
receipt?.status === "invalid" ? "Receipt 不可用" : "未捕获",
|
|
2634
|
+
),
|
|
2635
|
+
);
|
|
2636
|
+
missing.appendChild(
|
|
2637
|
+
el("code", null, receipt?.reasonCode ?? "CONTEXT_RECEIPT_MISSING"),
|
|
2638
|
+
);
|
|
2639
|
+
const missingLabel = contextTransferReasonLabel(
|
|
2640
|
+
receipt?.reasonCode ?? "CONTEXT_RECEIPT_MISSING",
|
|
2641
|
+
);
|
|
2642
|
+
if (missingLabel) {
|
|
2643
|
+
missing.appendChild(el("p", "muted", missingLabel));
|
|
2644
|
+
}
|
|
2645
|
+
missing.appendChild(
|
|
2646
|
+
el(
|
|
2647
|
+
"p",
|
|
2648
|
+
"muted",
|
|
2649
|
+
"当前只有 frozen input / prompt 指纹;它们不是 Effective Context。历史 run 不做事后回填。",
|
|
2650
|
+
),
|
|
2651
|
+
);
|
|
2652
|
+
root.appendChild(missing);
|
|
2653
|
+
} else {
|
|
2654
|
+
const captured = el("section", "node-input-section");
|
|
2655
|
+
captured.appendChild(el("h4", null, "Captured receipt"));
|
|
2656
|
+
captured.appendChild(
|
|
2657
|
+
transparencyMetaList([
|
|
2658
|
+
["context digest", receipt.contextDigest],
|
|
2659
|
+
["captured at", receipt.capturedAt],
|
|
2660
|
+
["components", receipt.componentCount],
|
|
2661
|
+
["truncations", receipt.truncationCount],
|
|
2662
|
+
["executor", receipt.runtime?.executor],
|
|
2663
|
+
["model", receipt.runtime?.model],
|
|
2664
|
+
["skills", receipt.runtime?.skillCount],
|
|
2665
|
+
["extensions", receipt.runtime?.extensionCount],
|
|
2666
|
+
["tools", receipt.runtime?.toolCount],
|
|
2667
|
+
]),
|
|
2668
|
+
);
|
|
2669
|
+
appendCodeList(
|
|
2670
|
+
captured,
|
|
2671
|
+
"组件类型",
|
|
2672
|
+
Object.entries(receipt.componentKinds ?? {}).map(
|
|
2673
|
+
([kind, count]) => `${kind}: ${count}`,
|
|
2674
|
+
),
|
|
2675
|
+
);
|
|
2676
|
+
appendCodeList(
|
|
2677
|
+
captured,
|
|
2678
|
+
"包含状态",
|
|
2679
|
+
Object.entries(receipt.inclusionCounts ?? {}).map(
|
|
2680
|
+
([kind, count]) => `${kind}: ${count}`,
|
|
2681
|
+
),
|
|
2682
|
+
);
|
|
2683
|
+
root.appendChild(captured);
|
|
2684
|
+
}
|
|
2685
|
+
content.appendChild(root);
|
|
2686
|
+
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "context");
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
function artifactInventorySection(data, dagRunId, nodeId) {
|
|
2690
|
+
const root = el("section", "node-input-section node-artifact-inventory");
|
|
2691
|
+
root.appendChild(el("h4", null, "声明产物与消费关系"));
|
|
2692
|
+
if (!data?.binding?.available) {
|
|
2693
|
+
const warning = el("div", "node-transparency-omission");
|
|
2694
|
+
const bindingCode =
|
|
2695
|
+
data?.binding?.reasonCode ?? "ARTIFACT_BINDING_UNAVAILABLE";
|
|
2696
|
+
warning.appendChild(el("code", null, bindingCode));
|
|
2697
|
+
const bindingLabel = contextTransferReasonLabel(bindingCode);
|
|
2698
|
+
if (bindingLabel) {
|
|
2699
|
+
warning.appendChild(el("p", "muted", bindingLabel));
|
|
2700
|
+
}
|
|
2701
|
+
warning.appendChild(
|
|
2702
|
+
el(
|
|
2703
|
+
"p",
|
|
2704
|
+
"muted",
|
|
2705
|
+
"该历史 run 没有 frozen Artifact Binding;不会从 prompt、outputContract、路径或文件名推断 consumer。",
|
|
2706
|
+
),
|
|
2707
|
+
);
|
|
2708
|
+
root.appendChild(warning);
|
|
2709
|
+
return root;
|
|
2710
|
+
}
|
|
2711
|
+
root.appendChild(
|
|
2712
|
+
transparencyMetaList([
|
|
2713
|
+
["origin", data.origin?.kind ?? "unknown"],
|
|
2714
|
+
["parent", data.origin?.parentRunId ?? null],
|
|
2715
|
+
["graph sha256", data.binding.artifactGraphSha256],
|
|
2716
|
+
]),
|
|
2717
|
+
);
|
|
2718
|
+
for (const artifact of data.produces ?? []) {
|
|
2719
|
+
const card = el("div", "node-artifact-card");
|
|
2720
|
+
card.appendChild(el("h5", null, artifact.artifactId));
|
|
2721
|
+
card.appendChild(
|
|
2722
|
+
transparencyMetaList([
|
|
2723
|
+
["path", artifact.path],
|
|
2724
|
+
["media", artifact.mediaType],
|
|
2725
|
+
["schema", artifact.schemaId ?? null],
|
|
2726
|
+
["materialization", artifact.materialization?.status],
|
|
2727
|
+
["bytes", artifact.materialization?.bytes],
|
|
2728
|
+
["origin", artifact.origin?.kind],
|
|
2729
|
+
["revision", artifact.origin?.revisionId],
|
|
2730
|
+
["supersedes", artifact.origin?.supersedes],
|
|
2731
|
+
[
|
|
2732
|
+
"revision",
|
|
2733
|
+
artifact.revision?.eligible
|
|
2734
|
+
? "eligible"
|
|
2735
|
+
: (contextTransferReasonLabel(artifact.revision?.reasonCode) ??
|
|
2736
|
+
artifact.revision?.reasonCode ??
|
|
2737
|
+
"blocked"),
|
|
2738
|
+
],
|
|
2739
|
+
]),
|
|
2740
|
+
);
|
|
2741
|
+
appendCodeList(
|
|
2742
|
+
card,
|
|
2743
|
+
"Direct consumers",
|
|
2744
|
+
artifact.directConsumerNodeIds ?? [],
|
|
2745
|
+
);
|
|
2746
|
+
if (artifact.materialization?.status === "materialized") {
|
|
2747
|
+
card.appendChild(
|
|
2748
|
+
createArtifactContentPreview(dagRunId, nodeId, () => artifact, {
|
|
2749
|
+
testId: `${ARTIFACT_FILE_PREVIEW_SURFACES.produced}-${artifact.artifactId}`,
|
|
2750
|
+
}).element,
|
|
2751
|
+
);
|
|
2752
|
+
}
|
|
2753
|
+
root.appendChild(card);
|
|
2754
|
+
}
|
|
2755
|
+
for (const artifact of data.consumes ?? []) {
|
|
2756
|
+
const card = el("div", "node-artifact-card is-consumed");
|
|
2757
|
+
card.appendChild(el("h5", null, `消费 ${artifact.artifactId}`));
|
|
2758
|
+
card.appendChild(
|
|
2759
|
+
transparencyMetaList([
|
|
2760
|
+
["producer", artifact.producerNodeId],
|
|
2761
|
+
["path", artifact.path],
|
|
2762
|
+
["required", artifact.required ? "yes" : "no"],
|
|
2763
|
+
]),
|
|
2764
|
+
);
|
|
2765
|
+
card.appendChild(
|
|
2766
|
+
createArtifactContentPreview(dagRunId, nodeId, () => artifact, {
|
|
2767
|
+
testId: `${ARTIFACT_FILE_PREVIEW_SURFACES.consumed}-${artifact.artifactId}`,
|
|
2768
|
+
}).element,
|
|
2769
|
+
);
|
|
2770
|
+
root.appendChild(card);
|
|
2771
|
+
}
|
|
2772
|
+
if (
|
|
2773
|
+
(data.produces ?? []).length === 0 &&
|
|
2774
|
+
(data.consumes ?? []).length === 0
|
|
2775
|
+
) {
|
|
2776
|
+
root.appendChild(el("p", "empty", "该节点没有声明的产物绑定。"));
|
|
2777
|
+
}
|
|
2778
|
+
return root;
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
async function prependArtifactInventory(content, dagRunId, node) {
|
|
2782
|
+
const result = await fetchDagNodeArtifacts(dagRunId, node.nodeId);
|
|
2783
|
+
if (
|
|
2784
|
+
!content.isConnected ||
|
|
2785
|
+
content.dataset.dagRunId !== String(dagRunId) ||
|
|
2786
|
+
content.dataset.dagNodeId !== String(node.nodeId) ||
|
|
2787
|
+
activeInspectorTab() !== "output"
|
|
1720
2788
|
)
|
|
2789
|
+
return;
|
|
2790
|
+
const section =
|
|
2791
|
+
result.ok && result.body
|
|
2792
|
+
? artifactInventorySection(result.body, dagRunId, node.nodeId)
|
|
2793
|
+
: el(
|
|
2794
|
+
"p",
|
|
2795
|
+
"node-input-error node-artifact-inventory",
|
|
2796
|
+
result.body?.error || "无法加载产物绑定事实。",
|
|
2797
|
+
);
|
|
2798
|
+
content.insertBefore(section, content.firstChild);
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
async function renderRunLineage(content, dagRunId, node) {
|
|
2802
|
+
content.appendChild(el("p", "muted", "正在加载来源与影响关系…"));
|
|
2803
|
+
const result = await fetchDagRunLineage(dagRunId);
|
|
2804
|
+
if (
|
|
2805
|
+
!content.isConnected ||
|
|
2806
|
+
content.dataset.dagRunId !== String(dagRunId) ||
|
|
2807
|
+
content.dataset.dagNodeId !== String(node.nodeId) ||
|
|
2808
|
+
activeInspectorTab() !== "lineage"
|
|
2809
|
+
)
|
|
2810
|
+
return;
|
|
2811
|
+
clearNode(content);
|
|
2812
|
+
if (!result.ok || !result.body) {
|
|
2813
|
+
content.appendChild(
|
|
2814
|
+
el("p", "node-input-error", result.body?.error || "无法加载来源与影响关系。"),
|
|
2815
|
+
);
|
|
2816
|
+
return;
|
|
2817
|
+
}
|
|
2818
|
+
const data = result.body;
|
|
2819
|
+
const root = el("div", "node-transparency-root");
|
|
2820
|
+
const intro = el("section", "node-lineage-intro");
|
|
2821
|
+
intro.append(
|
|
2822
|
+
el("h4", null, "这个节点从哪里来,会影响哪里"),
|
|
2823
|
+
el(
|
|
2824
|
+
"p",
|
|
2825
|
+
"muted",
|
|
2826
|
+
"这里展示派生运行继承、替换或重新执行了哪些节点。产出文件的直接使用者请到“产出”中查看。",
|
|
2827
|
+
),
|
|
2828
|
+
);
|
|
2829
|
+
root.appendChild(intro);
|
|
2830
|
+
root.appendChild(
|
|
2831
|
+
transparencyMetaList([
|
|
2832
|
+
["运行类型", data.kind === "root" ? "首次运行" : "派生运行"],
|
|
2833
|
+
["来源运行", data.parentRunId ?? null],
|
|
2834
|
+
["发起方式", data.trigger ?? null],
|
|
2835
|
+
["人工选择节点", data.operatorSelectedNodeId ?? null],
|
|
2836
|
+
["从此节点重新执行", data.effectiveFromNodeId ?? null],
|
|
2837
|
+
["重跑计划哈希", data.planHash ?? null],
|
|
2838
|
+
]),
|
|
2839
|
+
);
|
|
2840
|
+
appendCodeList(root, "沿用既有结果的节点", data.importedNodeIds ?? []);
|
|
2841
|
+
appendCodeList(root, "替换结果的节点", data.overriddenNodeIds ?? []);
|
|
2842
|
+
if (data.kind === "root")
|
|
2843
|
+
root.appendChild(
|
|
2844
|
+
el("p", "muted", "这是首次运行,没有来源运行。"),
|
|
2845
|
+
);
|
|
2846
|
+
content.appendChild(root);
|
|
2847
|
+
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "lineage");
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
function activeInspectorTab() {
|
|
2851
|
+
return [
|
|
2852
|
+
"overview",
|
|
2853
|
+
"input",
|
|
2854
|
+
"context",
|
|
2855
|
+
"timeline",
|
|
2856
|
+
"output",
|
|
2857
|
+
"lineage",
|
|
2858
|
+
"spec-evidence",
|
|
2859
|
+
"prompt-restart",
|
|
2860
|
+
].includes(uiState.dagInspectorTab)
|
|
1721
2861
|
? uiState.dagInspectorTab
|
|
1722
2862
|
: "output";
|
|
1723
2863
|
}
|
|
@@ -2012,7 +3152,7 @@ function effectiveExecutionKey(dagRunId, node) {
|
|
|
2012
3152
|
async function fetchExecutionOutput(dagRunId, nodeId, key) {
|
|
2013
3153
|
const url = `/api/dag-runs/${encodeURIComponent(dagRunId)}/nodes/${encodeURIComponent(nodeId)}/execution-output?key=${encodeURIComponent(key)}`;
|
|
2014
3154
|
try {
|
|
2015
|
-
const res = await
|
|
3155
|
+
const res = await fetchWithWorkspaceScope(url);
|
|
2016
3156
|
let body = null;
|
|
2017
3157
|
try {
|
|
2018
3158
|
body = await res.json();
|
|
@@ -2179,8 +3319,9 @@ function repaintOutputTabBody(content, dagRunId, node) {
|
|
|
2179
3319
|
return;
|
|
2180
3320
|
}
|
|
2181
3321
|
// Remove everything after the attempt bar (or all if no bar).
|
|
3322
|
+
const inventory = content.querySelector(".node-artifact-inventory");
|
|
2182
3323
|
const bar = content.querySelector(".dag-inspector-attempt-bar");
|
|
2183
|
-
const keep =
|
|
3324
|
+
const keep = [inventory, bar].filter(Boolean);
|
|
2184
3325
|
while (content.firstChild) content.removeChild(content.firstChild);
|
|
2185
3326
|
for (const nodeEl of keep) content.appendChild(nodeEl);
|
|
2186
3327
|
|
|
@@ -2251,7 +3392,9 @@ function renderProcessCommandCard(command) {
|
|
|
2251
3392
|
command.failureCategory ? command.failureCategory : null,
|
|
2252
3393
|
].filter(Boolean);
|
|
2253
3394
|
if (meta.length > 0) {
|
|
2254
|
-
body.appendChild(
|
|
3395
|
+
body.appendChild(
|
|
3396
|
+
el("div", "process-timeline-section-label", meta.join(" · ")),
|
|
3397
|
+
);
|
|
2255
3398
|
}
|
|
2256
3399
|
if (command.stdout) {
|
|
2257
3400
|
body.appendChild(el("div", "process-timeline-section-label", "stdout"));
|
|
@@ -2280,7 +3423,11 @@ function renderProcessStepCard(step) {
|
|
|
2280
3423
|
details.open = true;
|
|
2281
3424
|
const summary = el("summary", "process-timeline-summary");
|
|
2282
3425
|
summary.appendChild(
|
|
2283
|
-
el(
|
|
3426
|
+
el(
|
|
3427
|
+
"span",
|
|
3428
|
+
"process-timeline-summary-title",
|
|
3429
|
+
step.label || step.id || "step",
|
|
3430
|
+
),
|
|
2284
3431
|
);
|
|
2285
3432
|
summary.appendChild(
|
|
2286
3433
|
el(
|
|
@@ -2293,7 +3440,11 @@ function renderProcessStepCard(step) {
|
|
|
2293
3440
|
const body = el("div", "process-timeline-card-body");
|
|
2294
3441
|
if (step.durationMs != null) {
|
|
2295
3442
|
body.appendChild(
|
|
2296
|
-
el(
|
|
3443
|
+
el(
|
|
3444
|
+
"div",
|
|
3445
|
+
"process-timeline-section-label",
|
|
3446
|
+
`耗时 ${formatMs(step.durationMs)}`,
|
|
3447
|
+
),
|
|
2297
3448
|
);
|
|
2298
3449
|
}
|
|
2299
3450
|
if (step.detail) appendProcessPre(body, step.detail);
|
|
@@ -2307,7 +3458,11 @@ function renderProcessStepCard(step) {
|
|
|
2307
3458
|
|
|
2308
3459
|
function renderNonPiProcess(content, body) {
|
|
2309
3460
|
content.classList.add("process-timeline-scroll");
|
|
2310
|
-
if (
|
|
3461
|
+
if (
|
|
3462
|
+
!body ||
|
|
3463
|
+
body.emptyReason ||
|
|
3464
|
+
((body.commands ?? []).length === 0 && (body.steps ?? []).length === 0)
|
|
3465
|
+
) {
|
|
2311
3466
|
content.appendChild(el("p", "empty", processEmptyMessage(body)));
|
|
2312
3467
|
return;
|
|
2313
3468
|
}
|
|
@@ -2321,7 +3476,8 @@ function renderNonPiProcess(content, body) {
|
|
|
2321
3476
|
);
|
|
2322
3477
|
}
|
|
2323
3478
|
const ul = el("ul", "process-timeline process-timeline-rich");
|
|
2324
|
-
const items =
|
|
3479
|
+
const items =
|
|
3480
|
+
(body.commands ?? []).length > 0 ? body.commands : (body.steps ?? []);
|
|
2325
3481
|
for (let index = 0; index < items.length; index += 1) {
|
|
2326
3482
|
const item = items[index];
|
|
2327
3483
|
const failed = item.ok === false;
|
|
@@ -2354,8 +3510,7 @@ export async function mergeNodeProcess(dagRunId, node) {
|
|
|
2354
3510
|
const result = await fetchDagNodeProcess(dagRunId, nodeId, key);
|
|
2355
3511
|
if (uiState.dagNodeProcessIdentity !== identity) return;
|
|
2356
3512
|
if (!result.ok || !result.body) {
|
|
2357
|
-
uiState.dagNodeProcessError =
|
|
2358
|
-
result.body?.error || UI_TEXT.processError;
|
|
3513
|
+
uiState.dagNodeProcessError = result.body?.error || UI_TEXT.processError;
|
|
2359
3514
|
uiState.dagNodeProcessData = {
|
|
2360
3515
|
schemaVersion: 1,
|
|
2361
3516
|
dagRunId,
|
|
@@ -2468,7 +3623,13 @@ function fillDagInspectorContent(content, dagRunId, node) {
|
|
|
2468
3623
|
node.nodeId,
|
|
2469
3624
|
activeTab,
|
|
2470
3625
|
);
|
|
2471
|
-
if (activeTab === "
|
|
3626
|
+
if (activeTab === "overview") {
|
|
3627
|
+
renderNodeOverview(content, dagRunId, node);
|
|
3628
|
+
} else if (activeTab === "context") {
|
|
3629
|
+
void renderEffectiveContext(content, dagRunId, node);
|
|
3630
|
+
} else if (activeTab === "lineage") {
|
|
3631
|
+
void renderRunLineage(content, dagRunId, node);
|
|
3632
|
+
} else if (activeTab === "spec-evidence") {
|
|
2472
3633
|
void renderSpecEvidence(content, dagRunId, node.nodeId);
|
|
2473
3634
|
} else if (activeTab === "prompt-restart") {
|
|
2474
3635
|
void renderPromptRestart(content, dagRunId, node);
|
|
@@ -2507,6 +3668,7 @@ function fillDagInspectorContent(content, dagRunId, node) {
|
|
|
2507
3668
|
}
|
|
2508
3669
|
// Single-execution nodes (!key) already painted preview via renderCachedOrPreviewBody.
|
|
2509
3670
|
restoreInspectorContentScroll(content, dagRunId, node.nodeId, "output");
|
|
3671
|
+
void prependArtifactInventory(content, dagRunId, node);
|
|
2510
3672
|
}
|
|
2511
3673
|
}
|
|
2512
3674
|
|
|
@@ -2544,18 +3706,14 @@ function buildDagInspectorHeader(dagRunId, node) {
|
|
|
2544
3706
|
controls.appendChild(close);
|
|
2545
3707
|
header.appendChild(controls);
|
|
2546
3708
|
|
|
2547
|
-
const tabDefs = [
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
];
|
|
2553
|
-
// Prompt-override rerun: the server injects the SCOPED inspect mutation
|
|
2554
|
-
// token into /inspect HTML by default (it only authorizes
|
|
2555
|
-
// dagRerunPlan/dagRerun). The emergency kill switch suppresses the token;
|
|
3709
|
+
const tabDefs = DAG_INSPECTOR_READ_ONLY_TABS.map((definition) => [
|
|
3710
|
+
...definition,
|
|
3711
|
+
]);
|
|
3712
|
+
// Export/rerun mutation surface: the server injects a SCOPED inspect token.
|
|
3713
|
+
// The emergency kill switch suppresses the token;
|
|
2556
3714
|
// no token → no tab → the inspector stays strictly read-only.
|
|
2557
3715
|
if (globalThis.__INSPECT_MUTATION_TOKEN__) {
|
|
2558
|
-
tabDefs.push([
|
|
3716
|
+
tabDefs.push([...DAG_INSPECTOR_MUTATION_TAB]);
|
|
2559
3717
|
}
|
|
2560
3718
|
const tabs = el("div", "dag-inspector-tabs");
|
|
2561
3719
|
tabs.setAttribute("role", "tablist");
|