ralphflow-dsh 2.3.1 → 2.4.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.
Files changed (87) hide show
  1. package/README.md +48 -22
  2. package/graphs/codewiki/format.md +362 -0
  3. package/graphs/codewiki/graph.yaml +39 -0
  4. package/graphs/codewiki/nodes/assemble.md +24 -0
  5. package/graphs/codewiki/nodes/core-pages.md +17 -0
  6. package/graphs/codewiki/nodes/module-pages.md +18 -0
  7. package/graphs/codewiki/nodes/operations-pages.md +18 -0
  8. package/graphs/codewiki/nodes/survey.md +22 -0
  9. package/lib/asset-path.d.ts +59 -0
  10. package/lib/asset-path.js +181 -0
  11. package/lib/assets.d.ts +42 -0
  12. package/lib/assets.js +86 -0
  13. package/lib/client/phase.d.ts +29 -0
  14. package/lib/client/phase.js +86 -0
  15. package/lib/client/selection.d.ts +28 -0
  16. package/lib/client/selection.js +9 -0
  17. package/lib/client/status-source.d.ts +3 -1
  18. package/lib/client/status-source.js +3 -2
  19. package/lib/client/status.js +49 -13
  20. package/lib/client/viewer.d.ts +18 -0
  21. package/lib/client/viewer.js +540 -0
  22. package/lib/client.js +1159 -64
  23. package/lib/engine.d.ts +111 -47
  24. package/lib/engine.js +473 -320
  25. package/lib/facade.d.ts +175 -0
  26. package/lib/facade.js +553 -0
  27. package/lib/graph/agent-registry.d.ts +4 -0
  28. package/lib/graph/agent-registry.js +20 -0
  29. package/lib/graph/asset.d.ts +47 -0
  30. package/lib/graph/asset.js +276 -0
  31. package/lib/graph/assets.d.ts +47 -0
  32. package/lib/graph/assets.js +224 -0
  33. package/lib/graph/branches.d.ts +9 -0
  34. package/lib/graph/branches.js +13 -0
  35. package/lib/graph/check.d.ts +23 -0
  36. package/lib/graph/check.js +46 -0
  37. package/lib/graph/engine.d.ts +55 -0
  38. package/lib/graph/engine.js +2002 -0
  39. package/lib/graph/report.d.ts +9 -0
  40. package/lib/graph/report.js +117 -0
  41. package/lib/graph/state.d.ts +244 -0
  42. package/lib/graph/state.js +358 -0
  43. package/lib/graph/workspace.d.ts +68 -0
  44. package/lib/graph/workspace.js +262 -0
  45. package/lib/index.d.ts +11 -1
  46. package/lib/index.js +156 -49
  47. package/lib/owner.d.ts +34 -0
  48. package/lib/owner.js +49 -0
  49. package/lib/paths.d.ts +12 -0
  50. package/lib/paths.js +44 -0
  51. package/lib/pause.d.ts +12 -0
  52. package/lib/pause.js +19 -0
  53. package/lib/skills.d.ts +17 -30
  54. package/lib/skills.js +85 -21
  55. package/lib/status-contract.d.ts +114 -1
  56. package/lib/status-contract.js +106 -4
  57. package/lib/status-service.d.ts +5 -1
  58. package/lib/status-service.js +8 -1
  59. package/lib/tools.d.ts +14 -6
  60. package/lib/tools.js +88 -60
  61. package/lib/unfinished.d.ts +11 -0
  62. package/lib/unfinished.js +18 -0
  63. package/lib/verifier-preset.d.ts +40 -0
  64. package/lib/verifier-preset.js +126 -0
  65. package/lib/verify.d.ts +82 -13
  66. package/lib/verify.js +382 -95
  67. package/package.json +50 -38
  68. package/skills/ralphflow-create/SKILL.md +32 -0
  69. package/skills/ralphflow-create/graph-authoring.md +85 -0
  70. package/skills/ralphflow-create/matt/LICENSE +21 -0
  71. package/skills/ralphflow-create/matt/SHA256SUMS +6 -0
  72. package/skills/ralphflow-create/matt/SKILL-MECHANICS.md +22 -0
  73. package/skills/ralphflow-create/matt/SOURCE.md +12 -0
  74. package/skills/ralphflow-create/matt/grilling.md +30 -0
  75. package/skills/ralphflow-create/matt/to-spec.md +75 -0
  76. package/skills/ralphflow-create/matt/to-tickets.md +105 -0
  77. package/skills/ralphflow-create/matt/writing-for-agents.md +81 -0
  78. package/skills/ralphflow-create/ralphflow-authoring.md +31 -0
  79. package/skills/ralphflow-create/testing-workflow.md +60 -0
  80. package/{references → skills/ralphflow-create}/workflow-authoring.md +25 -5
  81. package/workflows/create-graph/steps/graph.md +17 -0
  82. package/workflows/create-graph/workflow.yaml +77 -0
  83. package/workflows/loop/workflow.yaml +23 -0
  84. package/lib/create.d.ts +0 -2
  85. package/lib/create.js +0 -17
  86. package/workflows/loop.yaml +0 -45
  87. /package/workflows/{spec.yaml → spec/workflow.yaml} +0 -0
@@ -0,0 +1,540 @@
1
+ import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * 只读查看器:右侧栏一个 tab,按工作流查看 Flow 步骤链或 Graph DAG。
4
+ *
5
+ * 边界(design §5):没有启动、暂停、取消、审批、产物写入或运行选择控制;数据来自同一个
6
+ * `ralphflowStatus` 只读流(与状态胶囊同源),不新开轮询、不碰运行状态。
7
+ *
8
+ * 视觉参考 RalphGraph 的只读工作图:一个工作流选择器 + 默认列表(Graph 可切依赖图画布)
9
+ * + 节点/步骤 inspector;所有颜色、边框、状态色走 dsh 原生 token。
10
+ */
11
+ import { useEffect, useRef, useState, useSyncExternalStore } from "react";
12
+ import { Menu } from "@deepseek-ai/dsh-client-ui-primitives";
13
+ import { flowPanelStatus, flowPhaseChips, graphAssetChips, graphPhaseChips, statusToneOf } from "./phase.js";
14
+ import { assetMenuLabel, pickAssetName } from "./selection.js";
15
+ export const VIEWER_TAB_ID = "ralphflow-viewer";
16
+ export const VIEWER_KIND = "ralphflow-viewer";
17
+ const ASSET_STORAGE_KEY = "ralphflow:viewer:asset";
18
+ const VIEW_STORAGE_KEY = "ralphflow:viewer:view";
19
+ const COLUMN_GAP = 16;
20
+ const MIN_CARD_WIDTH = 190;
21
+ const MAX_CARD_WIDTH = 252;
22
+ const CARD_HEIGHT = 168;
23
+ const ROW_STEP = 184;
24
+ const CANVAS_TOP = 36;
25
+ const STAGE_LABELS = {
26
+ executing: "执行中",
27
+ verifying: "独立验证中",
28
+ gate: "等待你审查",
29
+ paused: "已暂停",
30
+ switching: "切换中",
31
+ done: "已完成",
32
+ cancelled: "已取消",
33
+ failed: "失败",
34
+ unavailable: "不可用",
35
+ };
36
+ const css = `
37
+ .ralphflow-viewer {
38
+ --rv-ink: var(--dsw-alias-label-primary);
39
+ --rv-muted: var(--dsw-alias-label-secondary);
40
+ --rv-faint: var(--dsw-alias-label-tertiary);
41
+ --rv-line: var(--dsw-alias-border-l1);
42
+ --rv-line-strong: var(--dsw-alias-border-l2);
43
+ /* 品牌色是黑白中性色:拿它当主色,整张工作图会退化成黑白线稿。焦点色用业务蓝。 */
44
+ --rv-run: var(--dsw-alias-state-business-primary);
45
+ --rv-wait: var(--dsw-alias-state-warn-primary);
46
+ --rv-fault: var(--dsw-alias-state-error-primary);
47
+ --rv-done: var(--dsw-alias-state-success-primary);
48
+ --rv-accent: var(--rv-run);
49
+ --rv-track: color-mix(in srgb, var(--rv-muted) 11%, transparent);
50
+ --rv-panel: var(--dsw-alias-bg-layer-1);
51
+ --rv-card: var(--dsw-alias-bg-layer-2);
52
+ --rv-shadow: color-mix(in srgb, var(--rv-ink) 10%, transparent);
53
+ /* 状态底色:和主题卡片混色,亮/暗两套主题各自成立,不写死黑白色值。 */
54
+ --rv-run-wash: color-mix(in srgb, var(--rv-run) 15%, var(--rv-card));
55
+ --rv-wait-wash: color-mix(in srgb, var(--rv-wait) 14%, var(--rv-card));
56
+ --rv-done-wash: color-mix(in srgb, var(--rv-done) 11%, var(--rv-card));
57
+ --rv-fault-wash: color-mix(in srgb, var(--rv-fault) 13%, var(--rv-card));
58
+ --rv-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
59
+ box-sizing: border-box;
60
+ display: grid;
61
+ align-content: start;
62
+ gap: 14px;
63
+ width: 100%;
64
+ max-width: 100%;
65
+ min-width: 0;
66
+ min-height: 100%;
67
+ padding: 16px 14px 28px;
68
+ overflow-x: hidden;
69
+ background: linear-gradient(180deg, color-mix(in srgb, var(--rv-run) 5%, transparent), transparent 240px);
70
+ color: var(--rv-ink);
71
+ font-size: var(--dsh-content-font-size-secondary, 12.5px);
72
+ line-height: 1.55;
73
+ -webkit-font-smoothing: antialiased;
74
+ }
75
+ .ralphflow-viewer * { box-sizing: border-box; }
76
+ .ralphflow-viewer .rv-mono { font-family: var(--rv-mono); }
77
+ .ralphflow-viewer .rv-head { display: grid; gap: 8px; min-width: 0; max-width: 100%; }
78
+ .ralphflow-viewer .rv-kicker { display: inline-flex; align-items: center; gap: 6px; color: var(--rv-muted); font: 9.5px/1.4 var(--rv-mono); letter-spacing: .09em; text-transform: uppercase; }
79
+ .ralphflow-viewer .rv-kicker::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--rv-accent); }
80
+ .ralphflow-viewer .rv-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding-bottom: 7px; border-bottom: 1px solid color-mix(in srgb, var(--rv-run) 14%, var(--rv-line)); }
81
+ .ralphflow-viewer .rv-title { margin: 0; min-width: 0; font-size: 20px; line-height: 1.28; font-weight: 650; letter-spacing: -.014em; text-wrap: balance; overflow-wrap: anywhere; }
82
+ .ralphflow-viewer .rv-kind { flex: none; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; background: color-mix(in srgb, var(--rv-run) 10%, var(--rv-track)); color: color-mix(in srgb, var(--rv-run) 55%, var(--rv-ink)); font: 9.5px/1 var(--rv-mono); font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
83
+ .ralphflow-viewer .rv-meta { margin: 0; color: var(--rv-muted); font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
84
+ .ralphflow-viewer .rv-desc { margin: 0; color: var(--rv-muted); font-size: 11.5px; line-height: 1.6; text-wrap: pretty; overflow-wrap: anywhere; }
85
+ .ralphflow-viewer .rv-summary { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 1px; }
86
+ .ralphflow-viewer .rv-summary-item { display: inline-flex; align-items: baseline; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--rv-track); color: var(--rv-muted); font-size: 10px; line-height: 1.6; white-space: nowrap; }
87
+ .ralphflow-viewer .rv-summary-item strong { color: var(--rv-ink); font-weight: 700; font-variant-numeric: tabular-nums; }
88
+ .ralphflow-viewer .rv-summary-item[data-tone="done"] { background: color-mix(in srgb, var(--rv-done) 14%, transparent); color: var(--rv-done); }
89
+ .ralphflow-viewer .rv-summary-item[data-tone="done"] strong { color: var(--rv-done); }
90
+ .ralphflow-viewer .rv-summary-item[data-tone="run"] { background: color-mix(in srgb, var(--rv-run) 13%, transparent); color: var(--rv-run); }
91
+ .ralphflow-viewer .rv-summary-item[data-tone="run"] strong { color: var(--rv-run); }
92
+ .ralphflow-viewer .rv-summary-item[data-tone="wait"] { background: color-mix(in srgb, var(--rv-wait) 15%, transparent); color: var(--rv-wait); }
93
+ .ralphflow-viewer .rv-summary-item[data-tone="wait"] strong { color: var(--rv-wait); }
94
+ .ralphflow-viewer .rv-summary-item[data-tone="fault"] { background: color-mix(in srgb, var(--rv-fault) 13%, transparent); color: var(--rv-fault); }
95
+ .ralphflow-viewer .rv-summary-item[data-tone="fault"] strong { color: var(--rv-fault); }
96
+ .ralphflow-viewer .rv-callout { padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--rv-wait) 10%, var(--rv-panel)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rv-wait) 28%, var(--rv-line)); color: var(--rv-ink); font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
97
+ .ralphflow-viewer .rv-callout strong { color: var(--rv-wait); font-weight: 650; }
98
+ .ralphflow-viewer .rv-toolbar { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 6px 4px 9px; border-radius: 11px; background: var(--rv-panel); box-shadow: inset 0 0 0 1px var(--rv-line); }
99
+ .ralphflow-viewer .rv-select-label { flex: none; color: var(--rv-faint); font: 9.5px/1.4 var(--rv-mono); letter-spacing: .07em; text-transform: uppercase; }
100
+ .ralphflow-viewer .rv-picker { display: flex; flex: 1; min-width: 0; }
101
+ .ralphflow-viewer .rv-picker-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-width: 0; height: 30px; padding: 0 8px 0 4px; border: 0; border-radius: 7px; background: transparent; color: var(--rv-ink); font-family: inherit; font-size: 12px; line-height: 1.4; font-weight: 550; cursor: pointer; }
102
+ .ralphflow-viewer .rv-picker-trigger:hover { background: var(--rv-track); }
103
+ .ralphflow-viewer .rv-picker-trigger:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 1px; }
104
+ .ralphflow-viewer .rv-picker-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
105
+ .ralphflow-viewer .rv-picker-chevron { flex: none; color: var(--rv-muted); }
106
+ .ralphflow-viewer .rv-switch { flex: none; display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--rv-panel); box-shadow: inset 0 0 0 1px var(--rv-line); }
107
+ .ralphflow-viewer .rv-switch button { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 28px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: var(--rv-muted); font-family: inherit; font-size: 11px; line-height: 1; font-weight: 550; cursor: pointer; transition: background-color .16s ease, color .16s ease, box-shadow .16s ease, transform .12s ease; }
108
+ .ralphflow-viewer .rv-switch button:hover { background: var(--rv-track); color: var(--rv-ink); }
109
+ .ralphflow-viewer .rv-switch button:active { transform: scale(.96); }
110
+ .ralphflow-viewer .rv-switch button[aria-pressed="true"] { background: color-mix(in srgb, var(--rv-run) 12%, var(--rv-card)); color: var(--rv-ink); box-shadow: 0 1px 2px var(--rv-shadow), inset 0 0 0 1px color-mix(in srgb, var(--rv-run) 24%, var(--rv-line-strong)); }
111
+ .ralphflow-viewer .rv-switch button:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 1px; }
112
+ .ralphflow-viewer .rv-banner { padding: 8px 10px; border-radius: 10px; background: var(--rv-panel); box-shadow: inset 0 0 0 1px var(--rv-line); color: var(--rv-muted); font-size: 11.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
113
+ .ralphflow-viewer .rv-banner[data-kind="error"] { background: color-mix(in srgb, var(--rv-fault) 10%, var(--rv-panel)); color: var(--rv-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rv-fault) 32%, var(--rv-line)); }
114
+ .ralphflow-viewer .rv-empty { display: grid; gap: 7px; padding: 34px 18px; border-radius: 14px; background: var(--rv-panel); box-shadow: inset 0 0 0 1px var(--rv-line); color: var(--rv-muted); text-align: center; font-size: 11.5px; line-height: 1.65; text-wrap: pretty; }
115
+ .ralphflow-viewer .rv-empty strong { color: var(--rv-ink); font-size: 12.5px; font-weight: 650; }
116
+ .ralphflow-viewer .rv-canvas-wrap, .ralphflow-viewer .rv-toolbar, .ralphflow-viewer .rv-inspector, .ralphflow-viewer .rv-flow { min-width: 0; max-width: 100%; }
117
+ .ralphflow-viewer .rv-canvas-hint { padding: 7px 2px 0; color: var(--rv-faint); font: 9.5px/1.4 var(--rv-mono); letter-spacing: .04em; text-align: center; }
118
+ .ralphflow-viewer .rv-canvas-wrap { overflow: auto; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--rv-muted) 38%, transparent) transparent; overscroll-behavior-x: contain; border-radius: 14px; background: var(--rv-panel); box-shadow: inset 0 0 0 1px var(--rv-line); }
119
+ .ralphflow-viewer .rv-canvas { position: relative; background-color: var(--rv-panel); background-image: radial-gradient(900px 420px at 8% -12%, color-mix(in srgb, var(--rv-run) 16%, transparent), transparent 62%), radial-gradient(680px 340px at 100% -8%, color-mix(in srgb, var(--rv-wait) 10%, transparent), transparent 58%), radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--rv-run) 22%, transparent) 1px, transparent 0); background-size: auto, auto, 20px 20px; }
120
+ .ralphflow-viewer .rv-edge { fill: none; stroke: color-mix(in srgb, var(--rv-run) 24%, var(--rv-line)); stroke-width: 1.5; stroke-linecap: round; transition: stroke .18s ease, stroke-width .18s ease; }
121
+ .ralphflow-viewer .rv-edge[data-tone="run"] { stroke: color-mix(in srgb, var(--rv-run) 58%, var(--rv-line)); stroke-width: 2; }
122
+ .ralphflow-viewer .rv-edge[data-tone="done"] { stroke: color-mix(in srgb, var(--rv-done) 48%, var(--rv-line)); }
123
+ .ralphflow-viewer .rv-edge[data-tone="wait"] { stroke: color-mix(in srgb, var(--rv-wait) 55%, var(--rv-line)); stroke-dasharray: 5 5; }
124
+ .ralphflow-viewer .rv-edge[data-tone="fault"] { stroke: color-mix(in srgb, var(--rv-fault) 55%, var(--rv-line)); }
125
+ .ralphflow-viewer .rv-column { position: absolute; top: 0; display: grid; align-content: start; gap: 14px; }
126
+ .ralphflow-viewer .rv-column-head { padding: 9px 9px 2px; color: color-mix(in srgb, var(--rv-run) 45%, var(--rv-faint)); font: 9px/1.4 var(--rv-mono); letter-spacing: .07em; text-transform: uppercase; }
127
+ .ralphflow-viewer .rv-node { position: absolute; display: grid; overflow: hidden; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; gap: 7px; width: ${MAX_CARD_WIDTH}px; height: ${CARD_HEIGHT}px; padding: 13px; border: 0; border-left: 3px solid color-mix(in srgb, var(--rv-run) 30%, var(--rv-line)); border-radius: 12px; background: linear-gradient(150deg, color-mix(in srgb, var(--rv-run) 5%, var(--rv-card)), var(--rv-card) 58%, color-mix(in srgb, var(--rv-wait) 4%, var(--rv-card))); box-shadow: 0 1px 2px var(--rv-shadow), inset 0 0 0 1px var(--rv-line); color: inherit; text-align: left; font: inherit; cursor: pointer; transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease; }
128
+ .ralphflow-viewer .rv-node:hover { transform: translateY(-1px); box-shadow: 0 8px 20px color-mix(in srgb, var(--rv-ink) 12%, transparent), inset 0 0 0 1px var(--rv-line-strong); }
129
+ .ralphflow-viewer .rv-node:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 2px; }
130
+ .ralphflow-viewer .rv-node[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--rv-accent), 0 8px 20px var(--rv-shadow); }
131
+ .ralphflow-viewer .rv-node[data-status="running"], .ralphflow-viewer .rv-node[data-status="verifying"], .ralphflow-viewer .rv-node[data-status="reworking"], .ralphflow-viewer .rv-node[data-status="integrating"], .ralphflow-viewer .rv-node[data-status="accepting"] { border-left-color: var(--rv-run); background: linear-gradient(150deg, var(--rv-run-wash), var(--rv-card) 64%); }
132
+ .ralphflow-viewer .rv-node[data-status="waiting"], .ralphflow-viewer .rv-node[data-status="waiting_review"] { border-left-color: var(--rv-wait); background: linear-gradient(150deg, var(--rv-wait-wash), var(--rv-card) 64%); }
133
+ .ralphflow-viewer .rv-node[data-status="completed"] { border-left-color: var(--rv-done); background: linear-gradient(150deg, var(--rv-done-wash), var(--rv-card) 64%); }
134
+ .ralphflow-viewer .rv-node[data-status="failed"], .ralphflow-viewer .rv-node[data-status="cancelled"], .ralphflow-viewer .rv-node[data-status="interrupted"] { border-left-color: var(--rv-fault); background: linear-gradient(150deg, var(--rv-fault-wash), var(--rv-card) 64%); }
135
+ .ralphflow-viewer .rv-node-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; color: var(--rv-faint); font: 9.5px/1.4 var(--rv-mono); letter-spacing: .02em; }
136
+ .ralphflow-viewer .rv-node-top span:first-child { color: color-mix(in srgb, var(--rv-run) 55%, var(--rv-muted)); font-weight: 600; }
137
+ .ralphflow-viewer .rv-node-top span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
138
+ .ralphflow-viewer .rv-node > *, .ralphflow-viewer .rv-step > *, .ralphflow-viewer .rv-outline-row > * { min-width: 0; }
139
+ .ralphflow-viewer .rv-node h3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; max-height: 2.8em; overflow: hidden; margin: 0; font-size: 13.5px; line-height: 1.4; font-weight: 650; text-wrap: balance; overflow-wrap: anywhere; }
140
+ .ralphflow-viewer .rv-node-foot { align-self: end; display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-width: 0; color: var(--rv-faint); font-size: 10px; line-height: 1.5; white-space: nowrap; overflow: hidden; }
141
+ .ralphflow-viewer .rv-node-foot span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
142
+ .ralphflow-viewer .rv-node-foot span:last-child { flex: none; white-space: nowrap; }
143
+ .ralphflow-viewer .rv-chip { display: inline-flex; align-items: center; gap: 5px; width: fit-content; padding: 2px 8px; border-radius: 999px; background: var(--rv-track); color: var(--rv-muted); font-size: 10px; font-weight: 550; line-height: 1.6; white-space: nowrap; }
144
+ .ralphflow-viewer .rv-chip::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .9; }
145
+ .ralphflow-viewer .rv-chip[data-tone="run"] { background: color-mix(in srgb, var(--rv-run) 13%, transparent); color: var(--rv-run); }
146
+ .ralphflow-viewer .rv-chip[data-tone="done"] { background: color-mix(in srgb, var(--rv-done) 14%, transparent); color: var(--rv-done); }
147
+ .ralphflow-viewer .rv-chip[data-tone="wait"] { background: color-mix(in srgb, var(--rv-wait) 15%, transparent); color: var(--rv-wait); }
148
+ .ralphflow-viewer .rv-chip[data-tone="fault"] { background: color-mix(in srgb, var(--rv-fault) 13%, transparent); color: var(--rv-fault); }
149
+ .ralphflow-viewer .rv-chip[data-tone="off"] { opacity: .65; }
150
+ .ralphflow-viewer .rv-card-badges { display: flex; flex-wrap: wrap; gap: 4px; align-content: start; }
151
+ .ralphflow-viewer .rv-flow { display: grid; gap: 10px; }
152
+ .ralphflow-viewer .rv-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 2px 2px; color: var(--rv-faint); font: 9.5px/1.4 var(--rv-mono); letter-spacing: .05em; }
153
+ .ralphflow-viewer .rv-section-head span:first-child::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 2px; background: var(--rv-run); vertical-align: 1px; }
154
+ .ralphflow-viewer .rv-section-head span:last-child { text-transform: none; letter-spacing: 0; font-family: inherit; font-size: 10px; }
155
+ .ralphflow-viewer .rv-flow-item { position: relative; padding-left: 22px; }
156
+ .ralphflow-viewer .rv-flow-item::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: -10px; width: 1px; background: var(--rv-line); }
157
+ .ralphflow-viewer .rv-flow-item:last-child::before { bottom: auto; height: 20px; }
158
+ .ralphflow-viewer .rv-flow-dot { position: absolute; left: 3px; top: 20px; width: 9px; height: 9px; border-radius: 999px; background: color-mix(in srgb, var(--rv-run) 34%, var(--rv-line-strong)); box-shadow: 0 0 0 3px var(--rv-panel); }
159
+ .ralphflow-viewer .rv-flow-item[data-current="true"] .rv-flow-dot { background: var(--rv-run); }
160
+ .ralphflow-viewer .rv-flow-item[data-done="true"] .rv-flow-dot { background: var(--rv-done); }
161
+ .ralphflow-viewer .rv-step { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; width: 100%; padding: 13px; border: 0; border-left: 3px solid color-mix(in srgb, var(--rv-run) 26%, var(--rv-line)); border-radius: 12px; background: linear-gradient(150deg, color-mix(in srgb, var(--rv-run) 5%, var(--rv-card)), var(--rv-card) 58%, color-mix(in srgb, var(--rv-wait) 4%, var(--rv-card))); box-shadow: 0 1px 2px var(--rv-shadow), inset 0 0 0 1px var(--rv-line); color: inherit; text-align: left; font: inherit; cursor: pointer; transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease; }
162
+ .ralphflow-viewer .rv-step:hover { transform: translateY(-1px); box-shadow: 0 8px 20px color-mix(in srgb, var(--rv-ink) 12%, transparent), inset 0 0 0 1px var(--rv-line-strong); }
163
+ .ralphflow-viewer .rv-step:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 2px; }
164
+ .ralphflow-viewer .rv-step[data-current="true"] { border-left-color: var(--rv-run); background: linear-gradient(150deg, var(--rv-run-wash), var(--rv-card) 64%); }
165
+ .ralphflow-viewer .rv-step[data-done="true"] { border-left-color: var(--rv-done); background: linear-gradient(150deg, var(--rv-done-wash), var(--rv-card) 64%); }
166
+ .ralphflow-viewer .rv-step[data-failed="true"] { border-left-color: var(--rv-fault); background: linear-gradient(150deg, var(--rv-fault-wash), var(--rv-card) 64%); }
167
+ .ralphflow-viewer .rv-step h3 { margin: 0; font-size: 13px; line-height: 1.4; font-weight: 650; overflow-wrap: anywhere; }
168
+ .ralphflow-viewer .rv-step p { margin: 0; color: var(--rv-muted); font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
169
+ .ralphflow-viewer .rv-step .rv-step-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; max-height: 3.2em; overflow: hidden; color: var(--rv-faint); font-size: 10.5px; }
170
+ .ralphflow-viewer .rv-outline { display: grid; gap: 8px; padding: 10px; }
171
+ .ralphflow-viewer .rv-outline-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; width: 100%; padding: 12px 13px; border: 0; border-left: 3px solid color-mix(in srgb, var(--rv-run) 26%, var(--rv-line)); border-radius: 12px; background: linear-gradient(150deg, color-mix(in srgb, var(--rv-run) 5%, var(--rv-card)), var(--rv-card) 58%, color-mix(in srgb, var(--rv-wait) 4%, var(--rv-card))); box-shadow: 0 1px 2px var(--rv-shadow), inset 0 0 0 1px var(--rv-line); color: inherit; text-align: left; font: inherit; cursor: pointer; transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease; }
172
+ .ralphflow-viewer .rv-outline-row:hover { transform: translateY(-1px); box-shadow: 0 8px 20px color-mix(in srgb, var(--rv-ink) 12%, transparent), inset 0 0 0 1px var(--rv-line-strong); }
173
+ .ralphflow-viewer .rv-outline-row:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 2px; }
174
+ .ralphflow-viewer .rv-outline-row[data-status="running"], .ralphflow-viewer .rv-outline-row[data-status="verifying"], .ralphflow-viewer .rv-outline-row[data-status="reworking"], .ralphflow-viewer .rv-outline-row[data-status="integrating"], .ralphflow-viewer .rv-outline-row[data-status="accepting"] { border-left-color: var(--rv-run); background: linear-gradient(150deg, var(--rv-run-wash), var(--rv-card) 64%); }
175
+ .ralphflow-viewer .rv-outline-row[data-status="waiting"], .ralphflow-viewer .rv-outline-row[data-status="waiting_review"] { border-left-color: var(--rv-wait); background: linear-gradient(150deg, var(--rv-wait-wash), var(--rv-card) 64%); }
176
+ .ralphflow-viewer .rv-outline-row[data-status="completed"] { border-left-color: var(--rv-done); background: linear-gradient(150deg, var(--rv-done-wash), var(--rv-card) 64%); }
177
+ .ralphflow-viewer .rv-outline-row[data-status="failed"], .ralphflow-viewer .rv-outline-row[data-status="cancelled"], .ralphflow-viewer .rv-outline-row[data-status="interrupted"] { border-left-color: var(--rv-fault); background: linear-gradient(150deg, var(--rv-fault-wash), var(--rv-card) 64%); }
178
+ .ralphflow-viewer .rv-outline-name { font-size: 12.5px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
179
+ .ralphflow-viewer .rv-outline-meta { color: var(--rv-faint); font: 9.5px/1.5 var(--rv-mono); overflow-wrap: anywhere; }
180
+ .ralphflow-viewer .rv-outline-deps { margin: 0; color: var(--rv-muted); font-size: 10.5px; line-height: 1.5; overflow-wrap: anywhere; }
181
+ .ralphflow-viewer .rv-inspector { overflow: clip; border-radius: 14px; background: var(--rv-panel); box-shadow: inset 0 0 0 1px var(--rv-line); }
182
+ .ralphflow-viewer .rv-inspector[data-status="running"], .ralphflow-viewer .rv-inspector[data-status="verifying"], .ralphflow-viewer .rv-inspector[data-status="reworking"], .ralphflow-viewer .rv-inspector[data-status="integrating"], .ralphflow-viewer .rv-inspector[data-status="accepting"] { box-shadow: inset 0 3px 0 var(--rv-run), inset 0 0 0 1px var(--rv-line); }
183
+ .ralphflow-viewer .rv-inspector[data-status="waiting"], .ralphflow-viewer .rv-inspector[data-status="waiting_review"] { box-shadow: inset 0 3px 0 var(--rv-wait), inset 0 0 0 1px var(--rv-line); }
184
+ .ralphflow-viewer .rv-inspector[data-status="completed"] { box-shadow: inset 0 3px 0 var(--rv-done), inset 0 0 0 1px var(--rv-line); }
185
+ .ralphflow-viewer .rv-inspector[data-status="failed"], .ralphflow-viewer .rv-inspector[data-status="cancelled"], .ralphflow-viewer .rv-inspector[data-status="interrupted"] { box-shadow: inset 0 3px 0 var(--rv-fault), inset 0 0 0 1px var(--rv-line); }
186
+ .ralphflow-viewer .rv-inspector-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 14px; background: var(--rv-card); border-bottom: 1px solid var(--rv-line); }
187
+ .ralphflow-viewer .rv-eyebrow { color: var(--rv-faint); font: 9px/1.4 var(--rv-mono); letter-spacing: .07em; text-transform: uppercase; }
188
+ .ralphflow-viewer .rv-inspector-title { margin: 4px 0 0; font-size: 16px; line-height: 1.35; font-weight: 650; text-wrap: balance; overflow-wrap: anywhere; }
189
+ .ralphflow-viewer .rv-inspector-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 6px 0 0; color: var(--rv-muted); font-size: 10.5px; }
190
+ .ralphflow-viewer .rv-back { flex: none; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--rv-track); color: var(--rv-ink); font-family: inherit; font-size: 11px; line-height: 1; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color .16s ease, transform .12s ease; }
191
+ .ralphflow-viewer .rv-back:hover { background: color-mix(in srgb, var(--rv-muted) 18%, transparent); }
192
+ .ralphflow-viewer .rv-back:active { transform: scale(.96); }
193
+ .ralphflow-viewer .rv-back:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 1px; }
194
+ .ralphflow-viewer .rv-section { display: grid; gap: 7px; padding: 13px 14px; border-top: 1px solid var(--rv-line); }
195
+ .ralphflow-viewer .rv-inspector-head + .rv-section { border-top: 0; }
196
+ .ralphflow-viewer .rv-label { color: var(--rv-faint); font-size: 9.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
197
+ .ralphflow-viewer .rv-pre { margin: 0; padding: 10px 11px; border-radius: 10px; background: var(--rv-card); box-shadow: inset 0 0 0 1px var(--rv-line); color: var(--rv-ink); font: 11.5px/1.7 var(--rv-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
198
+ .ralphflow-viewer .rv-note { margin: 0; color: var(--rv-muted); font-size: 11.5px; line-height: 1.6; overflow-wrap: anywhere; }
199
+ .ralphflow-viewer .rv-meta-row { display: flex; flex-wrap: wrap; gap: 5px; }
200
+ .ralphflow-viewer .rv-check-list { display: grid; gap: 8px; }
201
+ .ralphflow-viewer .rv-check { display: grid; gap: 5px; }
202
+ .ralphflow-viewer .rv-code { display: inline-block; padding: 3px 7px; border-radius: 6px; background: var(--rv-card); box-shadow: inset 0 0 0 1px var(--rv-line); color: var(--rv-ink); font: 10.5px/1.6 var(--rv-mono); overflow-wrap: anywhere; }
203
+ .ralphflow-viewer .rv-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--rv-muted); font-size: 11.5px; line-height: 1.6; }
204
+ .ralphflow-viewer .rv-foot { padding-top: 2px; color: var(--rv-faint); font-size: 10px; line-height: 1.5; }
205
+ @media (max-width: 560px) {
206
+ .ralphflow-viewer { padding: 12px 10px 22px; gap: 11px; }
207
+ .ralphflow-viewer .rv-title { font-size: 18px; }
208
+ .ralphflow-viewer .rv-toolbar { flex-wrap: wrap; }
209
+ .ralphflow-viewer .rv-select { flex-basis: 150px; }
210
+ }
211
+ @media (prefers-reduced-motion: reduce) {
212
+ .ralphflow-viewer .rv-node, .ralphflow-viewer .rv-step, .ralphflow-viewer .rv-outline-row, .ralphflow-viewer .rv-switch button, .ralphflow-viewer .rv-back { transition: none; }
213
+ .ralphflow-viewer .rv-node:hover, .ralphflow-viewer .rv-step:hover, .ralphflow-viewer .rv-outline-row:hover { transform: none; }
214
+ }
215
+ `;
216
+ export function injectViewerCss() {
217
+ if (typeof document === "undefined" || document.querySelector("style[data-ralphflow-viewer-css]") !== null)
218
+ return;
219
+ const style = document.createElement("style");
220
+ style.dataset.ralphflowViewerCss = "";
221
+ style.textContent = css;
222
+ document.head.appendChild(style);
223
+ }
224
+ function readStored(key) {
225
+ try {
226
+ return typeof window === "undefined" ? null : window.localStorage.getItem(key);
227
+ }
228
+ catch {
229
+ return null;
230
+ }
231
+ }
232
+ function storeStored(key, value) {
233
+ try {
234
+ if (typeof window === "undefined")
235
+ return;
236
+ if (value === null)
237
+ window.localStorage.removeItem(key);
238
+ else
239
+ window.localStorage.setItem(key, value);
240
+ }
241
+ catch { }
242
+ }
243
+ /** 状态投影里的英文枚举是事实,界面只说人话。 */
244
+ const CHECK_LABELS = { passed: "已通过", failed: "未通过", infra: "验证未跑成", pending: "待验证", skipped: "已跳过" };
245
+ const CHECK_TONES = { passed: "done", failed: "fault", infra: "fault", pending: "off", skipped: "off" };
246
+ const MANUAL_LABELS = { pending: "待处理", waiting: "等待你审核", approved: "已批准", revise: "要求改稿", stale: "已过期", cancelled: "已取消" };
247
+ const INTEGRATION_LABELS = { accepted: "已合入", pending: "待合入" };
248
+ function graphRuntimeOf(status, asset) {
249
+ if (!status.status || status.status.workflow !== asset.name || status.status.kind !== "graph" || !status.status.graph)
250
+ return null;
251
+ return status.status.graph;
252
+ }
253
+ function flowRuntimeOf(status, asset) {
254
+ if (!status.status || status.status.workflow !== asset.name || status.status.kind !== "flow")
255
+ return null;
256
+ return status.status;
257
+ }
258
+ function nodeRuntimeOf(graph, id) {
259
+ return graph?.nodes.find((node) => node.id === id) ?? null;
260
+ }
261
+ function layoutGraph(nodes, availableWidth) {
262
+ const byId = new Map(nodes.map((node) => [node.id, node]));
263
+ const ranks = new Map();
264
+ const visiting = new Set();
265
+ const rankOf = (id) => {
266
+ const known = ranks.get(id);
267
+ if (known !== undefined)
268
+ return known;
269
+ if (visiting.has(id))
270
+ return 0;
271
+ visiting.add(id);
272
+ const node = byId.get(id);
273
+ let rank = 0;
274
+ for (const dependency of node?.dependsOn ?? [])
275
+ rank = Math.max(rank, rankOf(dependency) + 1);
276
+ visiting.delete(id);
277
+ ranks.set(id, rank);
278
+ return rank;
279
+ };
280
+ for (const node of nodes)
281
+ rankOf(node.id);
282
+ const unique = [...new Set([...ranks.values()])].sort((a, b) => a - b);
283
+ const columnIndex = new Map(unique.map((rank, index) => [rank, index]));
284
+ const columns = unique.map((rank) => ({ rank, ids: [] }));
285
+ for (const node of nodes) {
286
+ const index = columnIndex.get(ranks.get(node.id) ?? 0) ?? 0;
287
+ columns[index]?.ids.push(node.id);
288
+ }
289
+ const columnOf = new Map();
290
+ const rowOf = new Map();
291
+ for (const [index, column] of columns.entries()) {
292
+ for (const [row, id] of column.ids.entries()) {
293
+ columnOf.set(id, index);
294
+ rowOf.set(id, row);
295
+ }
296
+ }
297
+ const edges = [];
298
+ for (const node of nodes)
299
+ for (const dependency of node.dependsOn)
300
+ if (byId.has(dependency))
301
+ edges.push({ from: dependency, to: node.id });
302
+ const maxRows = Math.max(1, ...columns.map((column) => column.ids.length));
303
+ const room = availableWidth > 0 ? Math.floor((availableWidth - COLUMN_GAP * (columns.length - 1)) / columns.length) : MAX_CARD_WIDTH;
304
+ const cardWidth = Math.min(MAX_CARD_WIDTH, Math.max(MIN_CARD_WIDTH, room));
305
+ const naturalWidth = columns.length * cardWidth + COLUMN_GAP * (columns.length - 1);
306
+ const fits = availableWidth <= 0 || naturalWidth <= availableWidth;
307
+ const width = fits && availableWidth > 0 ? availableWidth : naturalWidth;
308
+ return {
309
+ columns,
310
+ columnOf,
311
+ rowOf,
312
+ edges,
313
+ cardWidth,
314
+ columnStep: cardWidth + COLUMN_GAP,
315
+ width,
316
+ height: CANVAS_TOP + maxRows * ROW_STEP,
317
+ scrollable: !fits,
318
+ };
319
+ }
320
+ function Chips({ chips, current }) {
321
+ return _jsx(_Fragment, { children: chips.map((chip, index) => _jsxs("span", { className: "rv-chip", "data-tone": chip.tone, children: [current && index === 0 ? "当前 · " : "", chip.label] }, `${index}-${chip.label}`)) });
322
+ }
323
+ function Summary({ items }) {
324
+ if (items.length === 0)
325
+ return null;
326
+ return _jsx("div", { className: "rv-summary", children: items.map((item) => (_jsxs("span", { className: "rv-summary-item", "data-tone": item.tone, children: [_jsx("strong", { children: item.value }), item.label] }, item.key))) });
327
+ }
328
+ function assetKey(asset) {
329
+ return `${asset.kind}:${asset.name}`;
330
+ }
331
+ function WorkflowPicker({ catalog, name, running, onChoose }) {
332
+ const [open, setOpen] = useState(false);
333
+ const selected = catalog.find((asset) => asset.name === name);
334
+ const items = [];
335
+ for (const kind of ["flow", "graph"]) {
336
+ const assets = catalog.filter((asset) => asset.kind === kind);
337
+ if (assets.length === 0)
338
+ continue;
339
+ items.push({ type: "label", id: `label-${kind}`, text: kind === "flow" ? "Flow" : "Graph" });
340
+ for (const asset of assets) {
341
+ items.push({
342
+ id: assetKey(asset),
343
+ label: assetMenuLabel(asset, running),
344
+ });
345
+ }
346
+ if (kind === "flow" && catalog.some((asset) => asset.kind === "graph"))
347
+ items.push({ type: "separator", id: "separator" });
348
+ }
349
+ return _jsx(Menu, { open: open, anchor: _jsxs("button", { type: "button", className: "rv-picker-trigger", "aria-haspopup": "menu", "aria-expanded": open, "aria-label": "\u9009\u62E9\u5DE5\u4F5C\u6D41", onClick: () => setOpen((value) => !value), children: [_jsx("span", { className: "rv-picker-text", children: selected ? `${selected.name} · ${selected.kind === "graph" ? `${selected.nodes.length} 节点` : `${selected.steps.length} 步`}` : "选择工作流" }), _jsx("svg", { className: "rv-picker-chevron", width: "10", height: "10", viewBox: "0 0 10 10", "aria-hidden": "true", children: _jsx("path", { d: "M2 3.5 5 6.5 8 3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }) })] }), items: items, selectedId: selected ? assetKey(selected) : undefined, onSelect: (id) => {
350
+ const next = catalog.find((asset) => assetKey(asset) === id);
351
+ setOpen(false);
352
+ if (next)
353
+ onChoose(next.name);
354
+ }, onClose: () => setOpen(false), portal: true, compact: true, className: "rv-picker", listClassName: "rv-picker-menu" });
355
+ }
356
+ function Header({ asset, graph, flow, catalog, name, running, onChoose, mode, onMode, }) {
357
+ const summary = graph ? [
358
+ graph.counts.completed > 0 ? { key: "completed", label: "完成", value: graph.counts.completed, tone: "done" } : null,
359
+ graph.counts.running > 0 ? { key: "running", label: "执行", value: graph.counts.running, tone: "run" } : null,
360
+ graph.counts.waiting > 0 ? { key: "waiting", label: "等待", value: graph.counts.waiting, tone: "wait" } : null,
361
+ graph.counts.pending > 0 ? { key: "pending", label: "待开始", value: graph.counts.pending, tone: "off" } : null,
362
+ graph.counts.blocked > 0 ? { key: "blocked", label: "阻塞", value: graph.counts.blocked, tone: "fault" } : null,
363
+ ].filter((item) => item !== null) : [];
364
+ const flowIndex = flow && asset ? asset.steps.findIndex((step) => step.id === flow.step) : -1;
365
+ const votesReturned = flow ? flow.votes.filter((vote) => vote.status === "passed" || vote.status === "failed" || vote.status === "infra").length : 0;
366
+ const baseMeta = !asset
367
+ ? "选择一个工作流查看只读结构"
368
+ : asset.invalid
369
+ ? `定义无效 · ${asset.problems[0] ?? "校验失败"}`
370
+ : asset.kind === "graph"
371
+ ? graph
372
+ ? `${graph.phase} · ${graph.counts.completed}/${graph.counts.total} 节点完成 · 只读浏览`
373
+ : `Graph · ${asset.nodes.length} 个节点 · 只读浏览`
374
+ : flow
375
+ ? `${STAGE_LABELS[flow.stage]}${flow.stage === "verifying" && flow.votes.length > 1 ? ` ${votesReturned}/${flow.votes.length} 票` : ""}${flowIndex >= 0 ? ` · 第 ${flowIndex + 1}/${asset.steps.length} 步` : ""} · 只读浏览`
376
+ : `Flow · ${asset.steps.length} 个步骤 · 只读浏览`;
377
+ // 正在跑的不是手上这个:明说一句,别让人以为看的就是运行中的。
378
+ const meta = running && asset && asset.name !== running ? `${baseMeta} · 运行中:${running}` : baseMeta;
379
+ return _jsxs("header", { className: "rv-head", children: [_jsxs("div", { className: "rv-kicker", children: ["RalphFlow ", _jsx("span", { "aria-hidden": "true", children: "/" }), " \u53EA\u8BFB\u5DE5\u4F5C\u56FE"] }), _jsxs("div", { className: "rv-title-row", children: [_jsx("h1", { className: "rv-title", children: asset?.name ?? "工作流浏览" }), asset ? _jsx("span", { className: "rv-kind", children: asset.kind === "graph" ? "Graph" : "Flow" }) : null] }), _jsx("p", { className: "rv-meta", children: meta }), asset?.description ? _jsx("p", { className: "rv-desc", children: asset.description }) : null, summary.length > 0 ? _jsx(Summary, { items: summary }) : null, graph?.nextAction ? _jsxs("div", { className: "rv-callout", children: [_jsx("strong", { children: graph.nextAction.label }), " \u00B7 ", graph.nextAction.message, " ", _jsx("span", { className: "rv-foot", children: "\u5728\u804A\u5929\u91CC\u5904\u7406\u3002" })] }) : null, !graph && flow && (flow.stage === "gate" || flow.stage === "paused") ? _jsxs("div", { className: "rv-callout", children: [_jsx("strong", { children: STAGE_LABELS[flow.stage] }), " \u00B7 ", flow.hint, " ", _jsx("span", { className: "rv-foot", children: "\u5728\u804A\u5929\u91CC\u7EE7\u7EED\u6216\u5BA1\u6279\u3002" })] }) : null, catalog.length > 0 ? _jsxs("div", { className: "rv-toolbar", children: [_jsx("label", { className: "rv-select-label", children: "\u5DE5\u4F5C\u6D41" }), _jsx(WorkflowPicker, { catalog: catalog, name: name, running: running, onChoose: onChoose }), asset?.kind === "graph" && !asset.invalid ? _jsxs("div", { className: "rv-switch", role: "group", "aria-label": "\u89C6\u56FE", children: [_jsx("button", { type: "button", "aria-pressed": mode === "columns", onClick: () => onMode("columns"), title: "\u4F9D\u8D56\u56FE\u753B\u5E03", children: "\u56FE" }), _jsx("button", { type: "button", "aria-pressed": mode === "outline", onClick: () => onMode("outline"), title: "\u4F9D\u8D56\u5217\u8868", children: "\u5217\u8868" })] }) : null] }) : null] });
380
+ }
381
+ function GraphCard({ node, graph, index, width, onOpen }) {
382
+ const runtime = nodeRuntimeOf(graph, node.id);
383
+ const status = runtime?.status ?? "pending";
384
+ return _jsxs("button", { type: "button", className: "rv-node", "data-ralphflow-node": node.id, "data-status": status, "aria-label": `查看节点 ${node.name}`, onClick: onOpen, style: { width }, children: [_jsxs("div", { className: "rv-node-top", children: [_jsxs("span", { children: ["\u8282\u70B9 ", String(index + 1).padStart(2, "0")] }), _jsx("span", { children: node.id })] }), _jsx("h3", { children: node.name }), _jsxs("div", { className: "rv-card-badges", children: [_jsx(Chips, { chips: runtime ? graphPhaseChips(runtime) : graphAssetChips(node), current: runtime?.current }), runtime?.check.reworks ? _jsxs("span", { className: "rv-chip", "data-tone": "fault", children: ["\u8FD4\u5DE5 ", runtime.check.reworks, " \u6B21"] }) : null, node.manual ? _jsx("span", { className: "rv-chip", "data-tone": "wait", children: "\u4EBA\u5DE5\u95E8" }) : null, node.execution === "main" ? _jsx("span", { className: "rv-chip", "data-tone": "off", children: "\u4E3B\u4F1A\u8BDD" }) : null] }), _jsxs("div", { className: "rv-node-foot", children: [_jsxs("span", { children: ["\u4F9D\u8D56\uFF1A", node.dependsOn.length ? node.dependsOn.join("、") : "起点节点"] }), _jsx("span", { children: "\u8BE6\u60C5 \u2192" })] })] });
385
+ }
386
+ function GraphCanvas({ asset, graph, mode, width: availableWidth, onOpen }) {
387
+ const layout = layoutGraph(asset.nodes, availableWidth);
388
+ if (mode === "outline") {
389
+ return _jsx("div", { className: "rv-outline", "data-ralphflow-outline": true, children: layout.columns.flatMap((column) => column.ids).map((id, index) => {
390
+ const node = asset.nodes.find((candidate) => candidate.id === id);
391
+ const runtime = nodeRuntimeOf(graph, node.id);
392
+ const status = runtime?.status ?? "pending";
393
+ return _jsxs("button", { type: "button", className: "rv-outline-row", "data-ralphflow-node": id, "data-status": status, "aria-label": `查看节点 ${node.name}`, onClick: () => onOpen(id), children: [_jsxs("div", { className: "rv-outline-name", children: [String(index + 1).padStart(2, "0"), " \u00B7 ", node.name] }), _jsxs("div", { className: "rv-outline-meta", children: ["id ", id, " \u00B7 \u4F9D\u8D56\u5C42 ", String((layout.columnOf.get(id) ?? 0) + 1).padStart(2, "0")] }), _jsxs("div", { className: "rv-card-badges", children: [_jsx(Chips, { chips: runtime ? graphPhaseChips(runtime) : graphAssetChips(node), current: runtime?.current }), runtime?.check.reworks ? _jsxs("span", { className: "rv-chip", "data-tone": "fault", children: ["\u8FD4\u5DE5 ", runtime.check.reworks, " \u6B21"] }) : null, node.manual ? _jsx("span", { className: "rv-chip", "data-tone": "wait", children: "\u4EBA\u5DE5\u95E8" }) : null, node.execution === "main" ? _jsx("span", { className: "rv-chip", "data-tone": "off", children: "\u4E3B\u4F1A\u8BDD" }) : null] }), _jsx("p", { className: "rv-outline-deps", children: node.dependsOn.length ? `依赖:${node.dependsOn.map((dep) => asset.nodes.find((candidate) => candidate.id === dep)?.name ?? dep).join("、")}` : "起点节点" })] }, id);
394
+ }) });
395
+ }
396
+ return _jsxs("div", { children: [_jsxs("div", { className: "rv-section-head", children: [_jsx("span", { children: "\u4F9D\u8D56\u56FE" }), _jsx("span", { children: "\u8282\u70B9\u6309\u4F9D\u8D56\u5C42\u4ECE\u5DE6\u5230\u53F3\uFF1B\u70B9\u8282\u70B9\u67E5\u770B DO / CHECK" })] }), _jsx("div", { className: "rv-canvas-wrap", children: _jsxs("div", { className: "rv-canvas", "data-ralphflow-dag": true, style: { width: layout.width, height: layout.height }, children: [_jsx("svg", { width: layout.width, height: layout.height, "aria-hidden": "true", children: layout.edges.map((edge) => {
397
+ const fromColumn = layout.columnOf.get(edge.from) ?? 0;
398
+ const toColumn = layout.columnOf.get(edge.to) ?? 0;
399
+ const fromRow = layout.rowOf.get(edge.from) ?? 0;
400
+ const toRow = layout.rowOf.get(edge.to) ?? 0;
401
+ const x1 = fromColumn * layout.columnStep + layout.cardWidth;
402
+ const x2 = toColumn * layout.columnStep;
403
+ const y1 = CANVAS_TOP + fromRow * ROW_STEP + CARD_HEIGHT / 2;
404
+ const y2 = CANVAS_TOP + toRow * ROW_STEP + CARD_HEIGHT / 2;
405
+ const curve = Math.max(20, Math.min(56, (x2 - x1) * 0.45));
406
+ const tone = statusToneOf(nodeRuntimeOf(graph, edge.to)?.status ?? "pending");
407
+ return _jsx("path", { className: "rv-edge", "data-tone": tone, d: `M ${x1} ${y1} C ${x1 + curve} ${y1}, ${x2 - curve} ${y2}, ${x2} ${y2}` }, `${edge.from}->${edge.to}`);
408
+ }) }), layout.columns.map((column, columnIndex) => _jsxs("section", { className: "rv-column", style: { left: columnIndex * layout.columnStep, width: layout.cardWidth }, children: [_jsxs("div", { className: "rv-column-head", children: ["\u4F9D\u8D56\u5C42 ", String(columnIndex + 1).padStart(2, "0")] }), column.ids.map((id, row) => {
409
+ const node = asset.nodes.find((candidate) => candidate.id === id);
410
+ const index = asset.nodes.findIndex((candidate) => candidate.id === id);
411
+ return _jsx("div", { style: { position: "absolute", top: CANVAS_TOP + row * ROW_STEP }, children: _jsx(GraphCard, { node: node, graph: graph, index: index, width: layout.cardWidth, onOpen: () => onOpen(id) }) }, id);
412
+ })] }, column.rank))] }) }), layout.scrollable ? _jsx("div", { className: "rv-canvas-hint", children: "\u2190 \u5DE6\u53F3\u6EDA\u52A8\u67E5\u770B\u5B8C\u6574\u4F9D\u8D56\u56FE \u2192" }) : null] });
413
+ }
414
+ function FlowList({ asset, flow, onOpen }) {
415
+ const currentIndex = flow ? asset.steps.findIndex((step) => step.id === flow.step) : -1;
416
+ return _jsxs("div", { children: [_jsxs("div", { className: "rv-section-head", children: [_jsx("span", { children: "\u6B65\u9AA4\u94FE" }), _jsx("span", { children: "on_pass \u63A8\u8FDB \u00B7 on_fail \u56DE\u9000" })] }), _jsx("div", { className: "rv-flow", children: asset.steps.map((step, index) => {
417
+ const current = step.id === flow?.step;
418
+ const passed = flow?.stage === "done" || (currentIndex >= 0 && index < currentIndex);
419
+ const runtime = flow?.steps.find((candidate) => candidate.id === step.id);
420
+ const failed = (runtime?.failures ?? 0) > 0;
421
+ return _jsxs("div", { className: "rv-flow-item", "data-current": current ? "true" : "false", "data-done": passed ? "true" : "false", children: [_jsx("span", { className: "rv-flow-dot", "aria-hidden": "true" }), _jsxs("button", { type: "button", className: "rv-step", "data-ralphflow-step": step.id, "data-current": current ? "true" : "false", "data-done": passed ? "true" : "false", "data-failed": failed ? "true" : "false", "aria-label": `查看步骤 ${step.description || step.id}`, onClick: () => onOpen(step.id), children: [_jsxs("div", { className: "rv-node-top", children: [_jsxs("span", { children: ["\u6B65\u9AA4 ", String(index + 1).padStart(2, "0"), " \u00B7 ", step.id] }), _jsx("span", { children: step.manual ? "人工门" : step.checks.length > 1 ? `${step.checks.length} 票 CHECK` : step.checks.length === 1 ? "有 CHECK" : "无 CHECK" })] }), _jsx("h3", { children: step.description || step.id }), _jsx("p", { className: "rv-step-preview", children: step.checks.length ? `${step.checks[0].replace(/\s+/g, " ").trim()}${step.checks.length > 1 ? ` 等 ${step.checks.length} 条` : ""}` : "跳过对抗性验证,完成即推进。" }), _jsxs("div", { className: "rv-card-badges", children: [flow && current ? _jsx(Chips, { chips: flowPhaseChips(flow) })
422
+ : _jsx("span", { className: "rv-chip", "data-tone": flow ? passed ? "done" : "off" : "off", children: flow ? passed ? "已通过" : "未开始" : "静态浏览" }), failed ? _jsxs("span", { className: "rv-chip", "data-tone": "fault", children: ["\u8FD4\u5DE5 ", runtime?.failures, " \u6B21"] }) : null, step.manual ? _jsx("span", { className: "rv-chip", "data-tone": "wait", children: "\u4EBA\u5DE5\u95E8" }) : null] }), _jsxs("div", { className: "rv-node-foot", children: [_jsxs("span", { children: ["\u901A\u8FC7 \u2192 ", step.onPass === "done" ? "结束" : step.onPass || "下一步"] }), _jsx("span", { children: "\u8BE6\u60C5 \u2192" })] })] })] }, step.id);
423
+ }) })] });
424
+ }
425
+ function Section({ label, children }) {
426
+ return _jsxs("section", { className: "rv-section", children: [_jsx("div", { className: "rv-label", children: label }), children] });
427
+ }
428
+ function GraphInspector({ asset, graph, node, onClose }) {
429
+ const runtime = nodeRuntimeOf(graph, node.id);
430
+ const status = runtime?.status ?? "pending";
431
+ const checkMode = runtime?.check.mode ?? node.checkMode;
432
+ const dependencies = node.dependsOn.map((id) => asset.nodes.find((candidate) => candidate.id === id)?.name ?? id);
433
+ return _jsxs("aside", { className: "rv-inspector", "data-ralphflow-inspector": node.id, "data-status": status, "aria-label": `节点详情:${node.name}`, children: [_jsxs("div", { className: "rv-inspector-head", children: [_jsxs("div", { children: [_jsxs("div", { className: "rv-eyebrow", children: ["NODE \u00B7 ", node.id] }), _jsx("h2", { className: "rv-inspector-title", children: node.name }), _jsxs("div", { className: "rv-inspector-sub", children: [_jsx(Chips, { chips: runtime ? graphPhaseChips(runtime) : graphAssetChips(node), current: runtime?.current }), _jsxs("span", { children: ["\u00B7 ", node.execution === "main" ? "主会话执行" : "后台执行", node.manual ? " · 人工门" : ""] })] })] }), _jsx("button", { type: "button", className: "rv-back", onClick: onClose, "aria-label": "\u8FD4\u56DE\u5DE5\u4F5C\u56FE", children: "\u2190 \u5DE5\u4F5C\u56FE" })] }), _jsx(Section, { label: "DO \u00B7 \u8282\u70B9\u4EFB\u52A1", children: _jsx("pre", { className: "rv-pre", "data-ralphflow-inspector-prompt": true, children: node.do || "(未声明 DO)" }) }), _jsxs(Section, { label: "CHECK \u00B7 \u72EC\u7ACB\u9A8C\u6536", children: [_jsxs("div", { className: "rv-meta-row", children: [_jsx("span", { className: "rv-chip", "data-tone": checkMode === "disabled" ? "off" : "run", children: checkMode === "disabled" ? "CHECK 关闭" : "自定义 CHECK" }), runtime?.check.status && runtime.check.status !== "skipped" ? _jsx("span", { className: "rv-chip", "data-tone": CHECK_TONES[runtime.check.status] ?? "off", children: CHECK_LABELS[runtime.check.status] ?? runtime.check.status }) : null] }), checkMode === "disabled" ? _jsx("p", { className: "rv-note", children: "\u8BE5\u8282\u70B9\u8DF3\u8FC7\u72EC\u7ACB CHECK\uFF1B\u8FD9\u8868\u793A\u672A\u9A8C\u6536\uFF0C\u4E0D\u7B49\u4E8E\u9A8C\u6536\u901A\u8FC7\u3002" }) : _jsx("pre", { className: "rv-pre", "data-ralphflow-inspector-check": true, children: node.check || "(未声明判据)" })] }), runtime ? _jsxs(Section, { label: "\u8FD0\u884C\u72B6\u6001", children: [_jsxs("p", { className: "rv-note", children: ["\u6267\u884C ", runtime.attempts, " \u6B21", runtime.check.reworks ? ` · 返工 ${runtime.check.reworks} 次` : "", runtime.check.reason ? ` · ${runtime.check.reason}` : ""] }), runtime.artifact ? _jsxs("p", { className: "rv-note", children: ["\u4EA7\u7269\uFF1A", _jsx("code", { className: "rv-code", children: runtime.artifact.path })] }) : null, runtime.manual !== "not_required" ? _jsxs("p", { className: "rv-note", children: ["\u4EBA\u5DE5\u95E8\uFF1A", MANUAL_LABELS[runtime.manual] ?? runtime.manual] }) : null, runtime.integration !== "not_required" ? _jsxs("p", { className: "rv-note", children: ["\u5408\u5165\uFF1A", INTEGRATION_LABELS[runtime.integration] ?? runtime.integration, runtime.integrationCommit ? ` · ${runtime.integrationCommit.slice(0, 12)}…` : ""] }) : null] }) : null, _jsx(Section, { label: "\u4F9D\u8D56", children: dependencies.length ? _jsx("ul", { className: "rv-list", children: dependencies.map((name) => _jsx("li", { children: name }, name)) }) : _jsx("p", { className: "rv-note", children: "\u65E0\u4F9D\u8D56\uFF0C\u8D77\u70B9\u8282\u70B9\u3002" }) }), _jsx(Section, { label: "\u8F93\u5165\u4E0E\u8D44\u6599", children: node.inputs.length ? _jsx("ul", { className: "rv-list", children: node.inputs.map((input) => _jsx("li", { children: _jsxs("code", { className: "rv-code", children: [input.fromNode, "/", input.artifact] }) }, `${input.fromNode}:${input.artifact}`)) }) : _jsx("p", { className: "rv-note", children: "\u65E0\u4E0A\u6E38\u4EA7\u7269\u8F93\u5165\u3002" }) }), _jsxs(Section, { label: "\u4EA4\u4ED8\u7269", children: [_jsx("code", { className: "rv-code", children: node.artifact }), _jsx("p", { className: "rv-foot", children: "\u53EA\u8BFB\u67E5\u770B\uFF1B\u542F\u52A8\u3001\u7EE7\u7EED\u4E0E\u5BA1\u6279\u90FD\u5728\u804A\u5929\u91CC\u5B8C\u6210\u3002" })] })] });
434
+ }
435
+ function StepInspector({ asset, flow, step, onClose }) {
436
+ const runtime = flow?.steps.find((candidate) => candidate.id === step.id);
437
+ const index = asset.steps.findIndex((candidate) => candidate.id === step.id);
438
+ const current = flow?.step === step.id;
439
+ return _jsxs("aside", { className: "rv-inspector", "data-status": flowPanelStatus(flow, current), "data-ralphflow-step-inspector": step.id, "aria-label": `步骤详情:${step.description || step.id}`, children: [_jsxs("div", { className: "rv-inspector-head", children: [_jsxs("div", { children: [_jsxs("div", { className: "rv-eyebrow", children: ["STEP \u00B7 ", String(index + 1).padStart(2, "0"), " \u00B7 ", step.id] }), _jsx("h2", { className: "rv-inspector-title", children: step.description || step.id }), _jsxs("div", { className: "rv-inspector-sub", children: [current && flow ? _jsx(Chips, { chips: flowPhaseChips(flow) })
440
+ : _jsx("span", { className: "rv-chip", "data-tone": current ? "run" : "off", children: current ? "当前步骤" : "静态浏览" }), _jsxs("span", { children: ["\u00B7 ", step.manual ? "人工审查门" : "自动推进"] })] })] }), _jsx("button", { type: "button", className: "rv-back", onClick: onClose, "aria-label": "\u8FD4\u56DE\u6B65\u9AA4\u94FE", children: "\u2190 \u6B65\u9AA4\u94FE" })] }), _jsx(Section, { label: "DO \u00B7 \u6B65\u9AA4\u4EFB\u52A1", children: _jsx("pre", { className: "rv-pre", children: step.do || "(未声明 DO)" }) }), _jsx(Section, { label: "CHECK \u00B7 \u72EC\u7ACB\u9A8C\u6536", children: step.checks.length === 0 ? _jsx("p", { className: "rv-note", children: "\uFF08\u8DF3\u8FC7\u5BF9\u6297\u6027\u9A8C\u8BC1\uFF09" })
441
+ : step.checks.length === 1 ? _jsx("pre", { className: "rv-pre", children: step.checks[0] })
442
+ : _jsx("div", { className: "rv-check-list", children: step.checks.map((criterion, index) => _jsxs("div", { className: "rv-check", children: [_jsxs("div", { className: "rv-label", children: ["\u9A8C\u8BC1\u8005 ", index + 1, "/", step.checks.length] }), _jsx("pre", { className: "rv-pre", children: criterion })] }, index)) }) }), _jsxs(Section, { label: "\u6D41\u8F6C", children: [_jsxs("p", { className: "rv-note", children: ["\u901A\u8FC7 \u2192 ", step.onPass === "done" ? "结束" : step.onPass || "下一步"] }), _jsxs("p", { className: "rv-note", children: ["\u5931\u8D25 \u2192 ", step.onFail === "done" ? "结束" : step.onFail || "自身"] })] }), _jsxs(Section, { label: "\u8F93\u5165 / \u4EA4\u4ED8\u7269", children: [_jsxs("p", { className: "rv-note", children: ["\u8F93\u5165\uFF1A", step.input || "(无)"] }), _jsxs("p", { className: "rv-note", children: ["\u4EA4\u4ED8\u7269\uFF1A", step.output || "(无)"] }), runtime ? _jsxs("p", { className: "rv-note", children: ["\u672C\u6B65\u8FD4\u5DE5\u6B21\u6570\uFF1A", runtime.failures] }) : null] })] });
443
+ }
444
+ export function ViewerPage(props) {
445
+ injectViewerCss();
446
+ const status = useSyncExternalStore(props.source.subscribe, props.source.getSnapshot, props.source.getSnapshot);
447
+ const [chosenName, setChosenName] = useState(null);
448
+ const [pinnedName, setPinnedName] = useState(() => readStored(ASSET_STORAGE_KEY));
449
+ const [selectedNode, setSelectedNode] = useState(null);
450
+ const [selectedStep, setSelectedStep] = useState(null);
451
+ const [preferredMode, setPreferredMode] = useState(() => {
452
+ const stored = readStored(VIEW_STORAGE_KEY);
453
+ return stored === "columns" || stored === "outline" ? stored : null;
454
+ });
455
+ const [width, setWidth] = useState(0);
456
+ const rootRef = useRef(null);
457
+ const catalog = status.catalog;
458
+ const currentName = status.status?.workflow ?? null;
459
+ const running = currentName && catalog.some((asset) => asset.name === currentName) ? currentName : null;
460
+ // 跑着的那个优先于上次浏览偏好:打开工作图先看到正在跑的;手动切换在本次打开内仍然有效。
461
+ const name = pickAssetName({ catalogNames: catalog.map((asset) => asset.name), running, chosen: chosenName, pinned: pinnedName });
462
+ const asset = catalog.find((candidate) => candidate.name === name) ?? null;
463
+ const graph = asset ? graphRuntimeOf(status, asset) : null;
464
+ const flow = asset ? flowRuntimeOf(status, asset) : null;
465
+ // 默认列表:DAG 画布在窄栏里要横向滚动,列表更适合「先看清楚有哪些节点」。用户主动选过图,就记住。
466
+ const mode = preferredMode ?? "outline";
467
+ // 运行中的工作流换了身份(新一轮 / 换成别的 / 状态消失)→ 作废手动选择,重新跟随运行。
468
+ useEffect(() => { setChosenName(null); }, [running]);
469
+ useEffect(() => {
470
+ const element = rootRef.current;
471
+ if (!element)
472
+ return;
473
+ const measure = () => setWidth(element.clientWidth);
474
+ measure();
475
+ if (typeof ResizeObserver === "undefined")
476
+ return;
477
+ const observer = new ResizeObserver(measure);
478
+ observer.observe(element);
479
+ return () => observer.disconnect();
480
+ }, []);
481
+ // 换资产 / 换视图 / 打开或关闭详情后回到顶部:滚动容器是查看器自己,
482
+ // 上一个长详情留下的 scrollTop 会盖住新面板的标题。
483
+ useEffect(() => {
484
+ const element = rootRef.current;
485
+ if (element)
486
+ element.scrollTop = 0;
487
+ }, [name, mode, selectedNode, selectedStep]);
488
+ const choose = (next) => {
489
+ setChosenName(next);
490
+ setPinnedName(next);
491
+ storeStored(ASSET_STORAGE_KEY, next);
492
+ setSelectedNode(null);
493
+ setSelectedStep(null);
494
+ };
495
+ const chooseMode = (next) => {
496
+ setPreferredMode(next);
497
+ storeStored(VIEW_STORAGE_KEY, next);
498
+ };
499
+ const selectedGraphNode = selectedNode && asset?.kind === "graph" ? asset.nodes.find((node) => node.id === selectedNode) ?? null : null;
500
+ const selectedFlowStep = selectedStep && asset?.kind === "flow" ? asset.steps.find((step) => step.id === selectedStep) ?? null : null;
501
+ return _jsxs("div", { ref: rootRef, className: "ralphflow-viewer", "data-ralphflow-viewer": true, children: [_jsx(Header, { asset: asset, graph: graph, flow: flow, catalog: catalog, name: name, running: running, onChoose: choose, mode: mode, onMode: chooseMode }), status.connection !== "live" ? _jsx("div", { className: "rv-banner", "data-kind": status.error ? "error" : undefined, children: status.error ?? "正在重新同步,显示最后状态。" }) : null, catalog.length === 0 ? _jsxs("div", { className: "rv-empty", children: [_jsx("strong", { children: "\u8FD8\u6CA1\u6709\u53EF\u663E\u793A\u7684\u5DE5\u4F5C\u6D41" }), _jsx("span", { children: "\u5728\u804A\u5929\u91CC\u521B\u5EFA\u6216\u542F\u52A8\u4E00\u4E2A Flow / Graph \u5DE5\u4F5C\u6D41\u540E\uFF0C\u8FD9\u91CC\u4F1A\u663E\u793A\u53EA\u8BFB\u7ED3\u6784\u3002" })] }) : null, asset?.invalid ? _jsx("div", { className: "rv-banner", "data-kind": "error", children: asset.problems.join("\n") }) : null, asset && !asset.invalid ? selectedGraphNode ? _jsx(GraphInspector, { asset: asset, graph: graph, node: selectedGraphNode, onClose: () => setSelectedNode(null) })
502
+ : selectedFlowStep ? _jsx(StepInspector, { asset: asset, flow: flow, step: selectedFlowStep, onClose: () => setSelectedStep(null) })
503
+ : asset.kind === "graph" ? _jsx(GraphCanvas, { asset: asset, graph: graph, mode: mode, width: Math.max(0, width - 28), onOpen: setSelectedNode })
504
+ : _jsx(FlowList, { asset: asset, flow: flow, onOpen: setSelectedStep }) : null] });
505
+ }
506
+ /** 注册只读 tab:类型 + 右侧栏 seat;数据走调用方给的共享 status source。 */
507
+ export function registerViewerTab(ctx, sourceOf) {
508
+ const face = ctx;
509
+ const rightTabs = ctx.get?.("sidebarRightTabs");
510
+ if (!rightTabs || !face.slots)
511
+ return;
512
+ try {
513
+ face.effect?.(() => rightTabs.register({
514
+ id: VIEWER_TAB_ID,
515
+ kind: VIEWER_KIND,
516
+ title: () => "RalphFlow 工作图(只读)",
517
+ guide: [{
518
+ id: VIEWER_TAB_ID,
519
+ order: 10,
520
+ title: () => "RalphFlow 工作图(只读)",
521
+ description: () => "查看 Flow 步骤链与 Graph DAG、节点 DO/CHECK 和当前状态;启动、继续与审批都在聊天里完成。",
522
+ }],
523
+ }), "ralphflow viewer tab type");
524
+ face.slots.inject("sidebar.right.pane.tab", () => {
525
+ try {
526
+ return face.slots.register({
527
+ name: "sidebar.right.pane.tab",
528
+ key: VIEWER_TAB_ID,
529
+ inject: (sessionId) => ({ sessionId, source: sourceOf(sessionId) }),
530
+ }, ViewerPage);
531
+ }
532
+ catch {
533
+ return () => { };
534
+ }
535
+ });
536
+ }
537
+ catch {
538
+ // 只读查看器是可降级能力:宿主右侧栏版本不匹配时不能拖垮整个客户端插件。
539
+ }
540
+ }