ralphflow-dsh 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +47 -21
  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 +482 -334
  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.js +150 -47
  46. package/lib/owner.d.ts +34 -0
  47. package/lib/owner.js +49 -0
  48. package/lib/paths.d.ts +12 -0
  49. package/lib/paths.js +44 -0
  50. package/lib/pause.d.ts +12 -0
  51. package/lib/pause.js +19 -0
  52. package/lib/skills.d.ts +18 -31
  53. package/lib/skills.js +88 -44
  54. package/lib/status-contract.d.ts +114 -1
  55. package/lib/status-contract.js +106 -4
  56. package/lib/status-service.d.ts +5 -1
  57. package/lib/status-service.js +8 -1
  58. package/lib/tools.d.ts +14 -6
  59. package/lib/tools.js +90 -62
  60. package/lib/unfinished.d.ts +11 -0
  61. package/lib/unfinished.js +18 -0
  62. package/lib/verifier-preset.d.ts +40 -0
  63. package/lib/verifier-preset.js +126 -0
  64. package/lib/verify.d.ts +64 -10
  65. package/lib/verify.js +287 -77
  66. package/package.json +51 -38
  67. package/skills/ralphflow-create/SKILL.md +32 -0
  68. package/skills/ralphflow-create/graph-authoring.md +85 -0
  69. package/skills/ralphflow-create/matt/LICENSE +21 -0
  70. package/skills/ralphflow-create/matt/SHA256SUMS +6 -0
  71. package/skills/ralphflow-create/matt/SKILL-MECHANICS.md +22 -0
  72. package/skills/ralphflow-create/matt/SOURCE.md +12 -0
  73. package/skills/ralphflow-create/matt/grilling.md +30 -0
  74. package/skills/ralphflow-create/matt/to-spec.md +75 -0
  75. package/skills/ralphflow-create/matt/to-tickets.md +105 -0
  76. package/skills/ralphflow-create/matt/writing-for-agents.md +81 -0
  77. package/skills/ralphflow-create/ralphflow-authoring.md +31 -0
  78. package/skills/ralphflow-create/testing-workflow.md +60 -0
  79. package/skills/ralphflow-create/workflow-authoring.md +137 -0
  80. package/workflows/create-graph/steps/graph.md +17 -0
  81. package/workflows/create-graph/workflow.yaml +77 -0
  82. package/workflows/loop/workflow.yaml +23 -0
  83. package/workflows/spec/workflow.yaml +105 -0
  84. package/lib/create.d.ts +0 -10
  85. package/lib/create.js +0 -147
  86. package/workflows/loop.yaml +0 -45
  87. package/workflows/spec.yaml +0 -110
package/lib/client.js CHANGED
@@ -27,7 +27,7 @@ __export(index_exports, {
27
27
  inject: () => inject
28
28
  });
29
29
  module.exports = __toCommonJS(index_exports);
30
- var import_react2 = require("react");
30
+ var import_react3 = require("react");
31
31
 
32
32
  // src/message-source.ts
33
33
  var RALPHFLOW_SOURCE_KIND = "ralphflow";
@@ -68,9 +68,884 @@ var noticeDefinition = {
68
68
  };
69
69
 
70
70
  // src/client/status.tsx
71
+ var import_react2 = require("react");
72
+ var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
73
+
74
+ // src/client/viewer.tsx
71
75
  var import_react = require("react");
72
76
  var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
73
77
 
78
+ // src/client/phase.ts
79
+ var DO_RUNNING = { label: "DO \xB7 \u6267\u884C\u4E2D", tone: "run" };
80
+ var DO_SUBMITTED = { label: "DO \xB7 \u5DF2\u4EA4\u5377", tone: "done" };
81
+ var CHECK_IDLE = { label: "CHECK \xB7 \u5F85\u9A8C\u8BC1", tone: "off" };
82
+ var CHECK_OFF = { label: "CHECK \xB7 \u5173\u95ED", tone: "off" };
83
+ var CHECK_CUSTOM = { label: "CHECK \xB7 \u81EA\u5B9A\u4E49", tone: "off" };
84
+ var CHECK_RUNNING = { label: "CHECK \xB7 \u9A8C\u8BC1\u4E2D", tone: "run" };
85
+ var CHECK_PASSED = { label: "CHECK \xB7 \u5DF2\u901A\u8FC7", tone: "done" };
86
+ var CHECK_FAILED = { label: "CHECK \xB7 \u672A\u901A\u8FC7", tone: "fault" };
87
+ function statusToneOf(status) {
88
+ if (status === "completed" || status === "done" || status === "passed") return "done";
89
+ if (["running", "verifying", "reworking", "integrating", "accepting", "switching"].includes(status)) return "run";
90
+ if (["waiting", "waiting_review", "gate", "paused"].includes(status)) return "wait";
91
+ if (["failed", "cancelled", "interrupted", "infra"].includes(status)) return "fault";
92
+ return "off";
93
+ }
94
+ function flowPhaseChips(flow) {
95
+ const total = flow.votes.length;
96
+ const returned = flow.votes.filter((vote) => vote.status === "passed" || vote.status === "failed" || vote.status === "infra").length;
97
+ switch (flow.stage) {
98
+ case "executing":
99
+ return total > 0 ? [DO_RUNNING, CHECK_IDLE] : [DO_RUNNING];
100
+ case "verifying":
101
+ return [DO_SUBMITTED, total > 1 ? { ...CHECK_RUNNING, label: `CHECK \xB7 \u9A8C\u8BC1\u4E2D ${returned}/${total}` } : CHECK_RUNNING];
102
+ case "gate":
103
+ return total > 0 ? [DO_SUBMITTED, CHECK_PASSED, { label: "\u7B49\u5F85\u4F60\u653E\u884C", tone: "wait" }] : [DO_SUBMITTED, { label: "\u7B49\u5F85\u4F60\u653E\u884C", tone: "wait" }];
104
+ // switching 既可能是「本步刚拿到 DO 投递」,也可能是「判定齐了正在推进」:
105
+ // 只有票已存在才敢说 DO 已交卷,否则只说切换中。
106
+ case "switching":
107
+ return total > 0 ? [DO_SUBMITTED, CHECK_PASSED] : [{ label: "\u5207\u6362\u6B65\u9AA4\u4E2D", tone: "run" }];
108
+ case "paused":
109
+ return [{ label: "\u5DF2\u6682\u505C", tone: "wait" }];
110
+ case "done":
111
+ return [{ label: "\u5DF2\u5B8C\u6210", tone: "done" }];
112
+ case "cancelled":
113
+ return [{ label: "\u5DF2\u53D6\u6D88", tone: "off" }];
114
+ case "failed":
115
+ return [{ label: "\u5931\u8D25", tone: "fault" }];
116
+ default:
117
+ return [{ label: "\u72B6\u6001\u4E0D\u53EF\u7528", tone: "off" }];
118
+ }
119
+ }
120
+ function graphPhaseChips(node) {
121
+ const check = node.check.mode === "disabled" ? CHECK_OFF : null;
122
+ switch (node.status) {
123
+ case "running":
124
+ return [DO_RUNNING, check ?? CHECK_IDLE];
125
+ case "verifying":
126
+ return [DO_SUBMITTED, CHECK_RUNNING];
127
+ case "reworking":
128
+ return [DO_SUBMITTED, CHECK_FAILED, { label: node.label, tone: "wait" }];
129
+ case "waiting_review":
130
+ return [DO_SUBMITTED, CHECK_PASSED, { label: node.label, tone: "wait" }];
131
+ case "integrating":
132
+ case "accepting":
133
+ return [CHECK_PASSED, { label: node.label, tone: "run" }];
134
+ case "completed":
135
+ return check ? [{ label: node.label, tone: "done" }] : [{ label: node.label, tone: "done" }, CHECK_PASSED];
136
+ default:
137
+ return [{ label: node.label, tone: statusToneOf(node.status) }];
138
+ }
139
+ }
140
+ function graphAssetChips(node) {
141
+ return [{ label: "\u5F85\u5F00\u59CB", tone: "off" }, node.checkMode === "disabled" ? CHECK_OFF : CHECK_CUSTOM];
142
+ }
143
+ function flowPanelStatus(flow, current) {
144
+ if (!current || !flow) return "pending";
145
+ switch (flow.stage) {
146
+ case "verifying":
147
+ return "verifying";
148
+ case "gate":
149
+ case "paused":
150
+ return "waiting";
151
+ case "done":
152
+ return "completed";
153
+ case "failed":
154
+ return "failed";
155
+ case "cancelled":
156
+ return "cancelled";
157
+ default:
158
+ return "running";
159
+ }
160
+ }
161
+
162
+ // src/client/selection.ts
163
+ function pickAssetName(input) {
164
+ const known = (name) => name !== null && input.catalogNames.includes(name) ? name : null;
165
+ return known(input.chosen) ?? known(input.running) ?? known(input.pinned) ?? input.catalogNames[0] ?? "";
166
+ }
167
+ function assetMenuLabel(asset, running) {
168
+ const size = asset.kind === "flow" ? `${asset.steps.length} \u6B65` : `${asset.nodes.length} \u8282\u70B9`;
169
+ return `${asset.name} \xB7 ${size}${asset.invalid ? "\uFF08\u5B9A\u4E49\u65E0\u6548\uFF09" : ""}${asset.name === running ? " \xB7 \u8FD0\u884C\u4E2D" : ""}`;
170
+ }
171
+
172
+ // src/client/viewer.tsx
173
+ var import_jsx_runtime = require("react/jsx-runtime");
174
+ var VIEWER_TAB_ID = "ralphflow-viewer";
175
+ var VIEWER_KIND = "ralphflow-viewer";
176
+ var ASSET_STORAGE_KEY = "ralphflow:viewer:asset";
177
+ var VIEW_STORAGE_KEY = "ralphflow:viewer:view";
178
+ var COLUMN_GAP = 16;
179
+ var MIN_CARD_WIDTH = 190;
180
+ var MAX_CARD_WIDTH = 252;
181
+ var CARD_HEIGHT = 168;
182
+ var ROW_STEP = 184;
183
+ var CANVAS_TOP = 36;
184
+ var STAGE_LABELS = {
185
+ executing: "\u6267\u884C\u4E2D",
186
+ verifying: "\u72EC\u7ACB\u9A8C\u8BC1\u4E2D",
187
+ gate: "\u7B49\u5F85\u4F60\u5BA1\u67E5",
188
+ paused: "\u5DF2\u6682\u505C",
189
+ switching: "\u5207\u6362\u4E2D",
190
+ done: "\u5DF2\u5B8C\u6210",
191
+ cancelled: "\u5DF2\u53D6\u6D88",
192
+ failed: "\u5931\u8D25",
193
+ unavailable: "\u4E0D\u53EF\u7528"
194
+ };
195
+ var css = `
196
+ .ralphflow-viewer {
197
+ --rv-ink: var(--dsw-alias-label-primary);
198
+ --rv-muted: var(--dsw-alias-label-secondary);
199
+ --rv-faint: var(--dsw-alias-label-tertiary);
200
+ --rv-line: var(--dsw-alias-border-l1);
201
+ --rv-line-strong: var(--dsw-alias-border-l2);
202
+ /* \u54C1\u724C\u8272\u662F\u9ED1\u767D\u4E2D\u6027\u8272\uFF1A\u62FF\u5B83\u5F53\u4E3B\u8272\uFF0C\u6574\u5F20\u5DE5\u4F5C\u56FE\u4F1A\u9000\u5316\u6210\u9ED1\u767D\u7EBF\u7A3F\u3002\u7126\u70B9\u8272\u7528\u4E1A\u52A1\u84DD\u3002 */
203
+ --rv-run: var(--dsw-alias-state-business-primary);
204
+ --rv-wait: var(--dsw-alias-state-warn-primary);
205
+ --rv-fault: var(--dsw-alias-state-error-primary);
206
+ --rv-done: var(--dsw-alias-state-success-primary);
207
+ --rv-accent: var(--rv-run);
208
+ --rv-track: color-mix(in srgb, var(--rv-muted) 11%, transparent);
209
+ --rv-panel: var(--dsw-alias-bg-layer-1);
210
+ --rv-card: var(--dsw-alias-bg-layer-2);
211
+ --rv-shadow: color-mix(in srgb, var(--rv-ink) 10%, transparent);
212
+ /* \u72B6\u6001\u5E95\u8272\uFF1A\u548C\u4E3B\u9898\u5361\u7247\u6DF7\u8272\uFF0C\u4EAE/\u6697\u4E24\u5957\u4E3B\u9898\u5404\u81EA\u6210\u7ACB\uFF0C\u4E0D\u5199\u6B7B\u9ED1\u767D\u8272\u503C\u3002 */
213
+ --rv-run-wash: color-mix(in srgb, var(--rv-run) 15%, var(--rv-card));
214
+ --rv-wait-wash: color-mix(in srgb, var(--rv-wait) 14%, var(--rv-card));
215
+ --rv-done-wash: color-mix(in srgb, var(--rv-done) 11%, var(--rv-card));
216
+ --rv-fault-wash: color-mix(in srgb, var(--rv-fault) 13%, var(--rv-card));
217
+ --rv-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
218
+ box-sizing: border-box;
219
+ display: grid;
220
+ align-content: start;
221
+ gap: 14px;
222
+ width: 100%;
223
+ max-width: 100%;
224
+ min-width: 0;
225
+ min-height: 100%;
226
+ padding: 16px 14px 28px;
227
+ overflow-x: hidden;
228
+ background: linear-gradient(180deg, color-mix(in srgb, var(--rv-run) 5%, transparent), transparent 240px);
229
+ color: var(--rv-ink);
230
+ font-size: var(--dsh-content-font-size-secondary, 12.5px);
231
+ line-height: 1.55;
232
+ -webkit-font-smoothing: antialiased;
233
+ }
234
+ .ralphflow-viewer * { box-sizing: border-box; }
235
+ .ralphflow-viewer .rv-mono { font-family: var(--rv-mono); }
236
+ .ralphflow-viewer .rv-head { display: grid; gap: 8px; min-width: 0; max-width: 100%; }
237
+ .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; }
238
+ .ralphflow-viewer .rv-kicker::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--rv-accent); }
239
+ .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)); }
240
+ .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; }
241
+ .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; }
242
+ .ralphflow-viewer .rv-meta { margin: 0; color: var(--rv-muted); font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
243
+ .ralphflow-viewer .rv-desc { margin: 0; color: var(--rv-muted); font-size: 11.5px; line-height: 1.6; text-wrap: pretty; overflow-wrap: anywhere; }
244
+ .ralphflow-viewer .rv-summary { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 1px; }
245
+ .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; }
246
+ .ralphflow-viewer .rv-summary-item strong { color: var(--rv-ink); font-weight: 700; font-variant-numeric: tabular-nums; }
247
+ .ralphflow-viewer .rv-summary-item[data-tone="done"] { background: color-mix(in srgb, var(--rv-done) 14%, transparent); color: var(--rv-done); }
248
+ .ralphflow-viewer .rv-summary-item[data-tone="done"] strong { color: var(--rv-done); }
249
+ .ralphflow-viewer .rv-summary-item[data-tone="run"] { background: color-mix(in srgb, var(--rv-run) 13%, transparent); color: var(--rv-run); }
250
+ .ralphflow-viewer .rv-summary-item[data-tone="run"] strong { color: var(--rv-run); }
251
+ .ralphflow-viewer .rv-summary-item[data-tone="wait"] { background: color-mix(in srgb, var(--rv-wait) 15%, transparent); color: var(--rv-wait); }
252
+ .ralphflow-viewer .rv-summary-item[data-tone="wait"] strong { color: var(--rv-wait); }
253
+ .ralphflow-viewer .rv-summary-item[data-tone="fault"] { background: color-mix(in srgb, var(--rv-fault) 13%, transparent); color: var(--rv-fault); }
254
+ .ralphflow-viewer .rv-summary-item[data-tone="fault"] strong { color: var(--rv-fault); }
255
+ .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; }
256
+ .ralphflow-viewer .rv-callout strong { color: var(--rv-wait); font-weight: 650; }
257
+ .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); }
258
+ .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; }
259
+ .ralphflow-viewer .rv-picker { display: flex; flex: 1; min-width: 0; }
260
+ .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; }
261
+ .ralphflow-viewer .rv-picker-trigger:hover { background: var(--rv-track); }
262
+ .ralphflow-viewer .rv-picker-trigger:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 1px; }
263
+ .ralphflow-viewer .rv-picker-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
264
+ .ralphflow-viewer .rv-picker-chevron { flex: none; color: var(--rv-muted); }
265
+ .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); }
266
+ .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; }
267
+ .ralphflow-viewer .rv-switch button:hover { background: var(--rv-track); color: var(--rv-ink); }
268
+ .ralphflow-viewer .rv-switch button:active { transform: scale(.96); }
269
+ .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)); }
270
+ .ralphflow-viewer .rv-switch button:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 1px; }
271
+ .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; }
272
+ .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)); }
273
+ .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; }
274
+ .ralphflow-viewer .rv-empty strong { color: var(--rv-ink); font-size: 12.5px; font-weight: 650; }
275
+ .ralphflow-viewer .rv-canvas-wrap, .ralphflow-viewer .rv-toolbar, .ralphflow-viewer .rv-inspector, .ralphflow-viewer .rv-flow { min-width: 0; max-width: 100%; }
276
+ .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; }
277
+ .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); }
278
+ .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; }
279
+ .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; }
280
+ .ralphflow-viewer .rv-edge[data-tone="run"] { stroke: color-mix(in srgb, var(--rv-run) 58%, var(--rv-line)); stroke-width: 2; }
281
+ .ralphflow-viewer .rv-edge[data-tone="done"] { stroke: color-mix(in srgb, var(--rv-done) 48%, var(--rv-line)); }
282
+ .ralphflow-viewer .rv-edge[data-tone="wait"] { stroke: color-mix(in srgb, var(--rv-wait) 55%, var(--rv-line)); stroke-dasharray: 5 5; }
283
+ .ralphflow-viewer .rv-edge[data-tone="fault"] { stroke: color-mix(in srgb, var(--rv-fault) 55%, var(--rv-line)); }
284
+ .ralphflow-viewer .rv-column { position: absolute; top: 0; display: grid; align-content: start; gap: 14px; }
285
+ .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; }
286
+ .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; }
287
+ .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); }
288
+ .ralphflow-viewer .rv-node:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 2px; }
289
+ .ralphflow-viewer .rv-node[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--rv-accent), 0 8px 20px var(--rv-shadow); }
290
+ .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%); }
291
+ .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%); }
292
+ .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%); }
293
+ .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%); }
294
+ .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; }
295
+ .ralphflow-viewer .rv-node-top span:first-child { color: color-mix(in srgb, var(--rv-run) 55%, var(--rv-muted)); font-weight: 600; }
296
+ .ralphflow-viewer .rv-node-top span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
297
+ .ralphflow-viewer .rv-node > *, .ralphflow-viewer .rv-step > *, .ralphflow-viewer .rv-outline-row > * { min-width: 0; }
298
+ .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; }
299
+ .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; }
300
+ .ralphflow-viewer .rv-node-foot span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
301
+ .ralphflow-viewer .rv-node-foot span:last-child { flex: none; white-space: nowrap; }
302
+ .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; }
303
+ .ralphflow-viewer .rv-chip::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .9; }
304
+ .ralphflow-viewer .rv-chip[data-tone="run"] { background: color-mix(in srgb, var(--rv-run) 13%, transparent); color: var(--rv-run); }
305
+ .ralphflow-viewer .rv-chip[data-tone="done"] { background: color-mix(in srgb, var(--rv-done) 14%, transparent); color: var(--rv-done); }
306
+ .ralphflow-viewer .rv-chip[data-tone="wait"] { background: color-mix(in srgb, var(--rv-wait) 15%, transparent); color: var(--rv-wait); }
307
+ .ralphflow-viewer .rv-chip[data-tone="fault"] { background: color-mix(in srgb, var(--rv-fault) 13%, transparent); color: var(--rv-fault); }
308
+ .ralphflow-viewer .rv-chip[data-tone="off"] { opacity: .65; }
309
+ .ralphflow-viewer .rv-card-badges { display: flex; flex-wrap: wrap; gap: 4px; align-content: start; }
310
+ .ralphflow-viewer .rv-flow { display: grid; gap: 10px; }
311
+ .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; }
312
+ .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; }
313
+ .ralphflow-viewer .rv-section-head span:last-child { text-transform: none; letter-spacing: 0; font-family: inherit; font-size: 10px; }
314
+ .ralphflow-viewer .rv-flow-item { position: relative; padding-left: 22px; }
315
+ .ralphflow-viewer .rv-flow-item::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: -10px; width: 1px; background: var(--rv-line); }
316
+ .ralphflow-viewer .rv-flow-item:last-child::before { bottom: auto; height: 20px; }
317
+ .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); }
318
+ .ralphflow-viewer .rv-flow-item[data-current="true"] .rv-flow-dot { background: var(--rv-run); }
319
+ .ralphflow-viewer .rv-flow-item[data-done="true"] .rv-flow-dot { background: var(--rv-done); }
320
+ .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; }
321
+ .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); }
322
+ .ralphflow-viewer .rv-step:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 2px; }
323
+ .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%); }
324
+ .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%); }
325
+ .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%); }
326
+ .ralphflow-viewer .rv-step h3 { margin: 0; font-size: 13px; line-height: 1.4; font-weight: 650; overflow-wrap: anywhere; }
327
+ .ralphflow-viewer .rv-step p { margin: 0; color: var(--rv-muted); font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
328
+ .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; }
329
+ .ralphflow-viewer .rv-outline { display: grid; gap: 8px; padding: 10px; }
330
+ .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; }
331
+ .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); }
332
+ .ralphflow-viewer .rv-outline-row:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 2px; }
333
+ .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%); }
334
+ .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%); }
335
+ .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%); }
336
+ .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%); }
337
+ .ralphflow-viewer .rv-outline-name { font-size: 12.5px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
338
+ .ralphflow-viewer .rv-outline-meta { color: var(--rv-faint); font: 9.5px/1.5 var(--rv-mono); overflow-wrap: anywhere; }
339
+ .ralphflow-viewer .rv-outline-deps { margin: 0; color: var(--rv-muted); font-size: 10.5px; line-height: 1.5; overflow-wrap: anywhere; }
340
+ .ralphflow-viewer .rv-inspector { overflow: clip; border-radius: 14px; background: var(--rv-panel); box-shadow: inset 0 0 0 1px var(--rv-line); }
341
+ .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); }
342
+ .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); }
343
+ .ralphflow-viewer .rv-inspector[data-status="completed"] { box-shadow: inset 0 3px 0 var(--rv-done), inset 0 0 0 1px var(--rv-line); }
344
+ .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); }
345
+ .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); }
346
+ .ralphflow-viewer .rv-eyebrow { color: var(--rv-faint); font: 9px/1.4 var(--rv-mono); letter-spacing: .07em; text-transform: uppercase; }
347
+ .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; }
348
+ .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; }
349
+ .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; }
350
+ .ralphflow-viewer .rv-back:hover { background: color-mix(in srgb, var(--rv-muted) 18%, transparent); }
351
+ .ralphflow-viewer .rv-back:active { transform: scale(.96); }
352
+ .ralphflow-viewer .rv-back:focus-visible { outline: 2px solid var(--rv-accent); outline-offset: 1px; }
353
+ .ralphflow-viewer .rv-section { display: grid; gap: 7px; padding: 13px 14px; border-top: 1px solid var(--rv-line); }
354
+ .ralphflow-viewer .rv-inspector-head + .rv-section { border-top: 0; }
355
+ .ralphflow-viewer .rv-label { color: var(--rv-faint); font-size: 9.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
356
+ .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; }
357
+ .ralphflow-viewer .rv-note { margin: 0; color: var(--rv-muted); font-size: 11.5px; line-height: 1.6; overflow-wrap: anywhere; }
358
+ .ralphflow-viewer .rv-meta-row { display: flex; flex-wrap: wrap; gap: 5px; }
359
+ .ralphflow-viewer .rv-check-list { display: grid; gap: 8px; }
360
+ .ralphflow-viewer .rv-check { display: grid; gap: 5px; }
361
+ .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; }
362
+ .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; }
363
+ .ralphflow-viewer .rv-foot { padding-top: 2px; color: var(--rv-faint); font-size: 10px; line-height: 1.5; }
364
+ @media (max-width: 560px) {
365
+ .ralphflow-viewer { padding: 12px 10px 22px; gap: 11px; }
366
+ .ralphflow-viewer .rv-title { font-size: 18px; }
367
+ .ralphflow-viewer .rv-toolbar { flex-wrap: wrap; }
368
+ .ralphflow-viewer .rv-select { flex-basis: 150px; }
369
+ }
370
+ @media (prefers-reduced-motion: reduce) {
371
+ .ralphflow-viewer .rv-node, .ralphflow-viewer .rv-step, .ralphflow-viewer .rv-outline-row, .ralphflow-viewer .rv-switch button, .ralphflow-viewer .rv-back { transition: none; }
372
+ .ralphflow-viewer .rv-node:hover, .ralphflow-viewer .rv-step:hover, .ralphflow-viewer .rv-outline-row:hover { transform: none; }
373
+ }
374
+ `;
375
+ function injectViewerCss() {
376
+ if (typeof document === "undefined" || document.querySelector("style[data-ralphflow-viewer-css]") !== null) return;
377
+ const style = document.createElement("style");
378
+ style.dataset.ralphflowViewerCss = "";
379
+ style.textContent = css;
380
+ document.head.appendChild(style);
381
+ }
382
+ function readStored(key) {
383
+ try {
384
+ return typeof window === "undefined" ? null : window.localStorage.getItem(key);
385
+ } catch {
386
+ return null;
387
+ }
388
+ }
389
+ function storeStored(key, value) {
390
+ try {
391
+ if (typeof window === "undefined") return;
392
+ if (value === null) window.localStorage.removeItem(key);
393
+ else window.localStorage.setItem(key, value);
394
+ } catch {
395
+ }
396
+ }
397
+ var CHECK_LABELS = { passed: "\u5DF2\u901A\u8FC7", failed: "\u672A\u901A\u8FC7", infra: "\u9A8C\u8BC1\u672A\u8DD1\u6210", pending: "\u5F85\u9A8C\u8BC1", skipped: "\u5DF2\u8DF3\u8FC7" };
398
+ var CHECK_TONES = { passed: "done", failed: "fault", infra: "fault", pending: "off", skipped: "off" };
399
+ var MANUAL_LABELS = { pending: "\u5F85\u5904\u7406", waiting: "\u7B49\u5F85\u4F60\u5BA1\u6838", approved: "\u5DF2\u6279\u51C6", revise: "\u8981\u6C42\u6539\u7A3F", stale: "\u5DF2\u8FC7\u671F", cancelled: "\u5DF2\u53D6\u6D88" };
400
+ var INTEGRATION_LABELS = { accepted: "\u5DF2\u5408\u5165", pending: "\u5F85\u5408\u5165" };
401
+ function graphRuntimeOf(status, asset) {
402
+ if (!status.status || status.status.workflow !== asset.name || status.status.kind !== "graph" || !status.status.graph) return null;
403
+ return status.status.graph;
404
+ }
405
+ function flowRuntimeOf(status, asset) {
406
+ if (!status.status || status.status.workflow !== asset.name || status.status.kind !== "flow") return null;
407
+ return status.status;
408
+ }
409
+ function nodeRuntimeOf(graph, id) {
410
+ return graph?.nodes.find((node) => node.id === id) ?? null;
411
+ }
412
+ function layoutGraph(nodes, availableWidth) {
413
+ const byId = new Map(nodes.map((node) => [node.id, node]));
414
+ const ranks = /* @__PURE__ */ new Map();
415
+ const visiting = /* @__PURE__ */ new Set();
416
+ const rankOf = (id) => {
417
+ const known = ranks.get(id);
418
+ if (known !== void 0) return known;
419
+ if (visiting.has(id)) return 0;
420
+ visiting.add(id);
421
+ const node = byId.get(id);
422
+ let rank = 0;
423
+ for (const dependency of node?.dependsOn ?? []) rank = Math.max(rank, rankOf(dependency) + 1);
424
+ visiting.delete(id);
425
+ ranks.set(id, rank);
426
+ return rank;
427
+ };
428
+ for (const node of nodes) rankOf(node.id);
429
+ const unique = [.../* @__PURE__ */ new Set([...ranks.values()])].sort((a, b) => a - b);
430
+ const columnIndex = new Map(unique.map((rank, index) => [rank, index]));
431
+ const columns = unique.map((rank) => ({ rank, ids: [] }));
432
+ for (const node of nodes) {
433
+ const index = columnIndex.get(ranks.get(node.id) ?? 0) ?? 0;
434
+ columns[index]?.ids.push(node.id);
435
+ }
436
+ const columnOf = /* @__PURE__ */ new Map();
437
+ const rowOf = /* @__PURE__ */ new Map();
438
+ for (const [index, column] of columns.entries()) {
439
+ for (const [row, id] of column.ids.entries()) {
440
+ columnOf.set(id, index);
441
+ rowOf.set(id, row);
442
+ }
443
+ }
444
+ const edges = [];
445
+ for (const node of nodes) for (const dependency of node.dependsOn) if (byId.has(dependency)) edges.push({ from: dependency, to: node.id });
446
+ const maxRows = Math.max(1, ...columns.map((column) => column.ids.length));
447
+ const room = availableWidth > 0 ? Math.floor((availableWidth - COLUMN_GAP * (columns.length - 1)) / columns.length) : MAX_CARD_WIDTH;
448
+ const cardWidth = Math.min(MAX_CARD_WIDTH, Math.max(MIN_CARD_WIDTH, room));
449
+ const naturalWidth = columns.length * cardWidth + COLUMN_GAP * (columns.length - 1);
450
+ const fits = availableWidth <= 0 || naturalWidth <= availableWidth;
451
+ const width = fits && availableWidth > 0 ? availableWidth : naturalWidth;
452
+ return {
453
+ columns,
454
+ columnOf,
455
+ rowOf,
456
+ edges,
457
+ cardWidth,
458
+ columnStep: cardWidth + COLUMN_GAP,
459
+ width,
460
+ height: CANVAS_TOP + maxRows * ROW_STEP,
461
+ scrollable: !fits
462
+ };
463
+ }
464
+ function Chips({ chips, current }) {
465
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: chips.map((chip, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "rv-chip", "data-tone": chip.tone, children: [
466
+ current && index === 0 ? "\u5F53\u524D \xB7 " : "",
467
+ chip.label
468
+ ] }, `${index}-${chip.label}`)) });
469
+ }
470
+ function Summary({ items }) {
471
+ if (items.length === 0) return null;
472
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rv-summary", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "rv-summary-item", "data-tone": item.tone, children: [
473
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: item.value }),
474
+ item.label
475
+ ] }, item.key)) });
476
+ }
477
+ function assetKey(asset) {
478
+ return `${asset.kind}:${asset.name}`;
479
+ }
480
+ function WorkflowPicker({ catalog, name, running, onChoose }) {
481
+ const [open, setOpen] = (0, import_react.useState)(false);
482
+ const selected = catalog.find((asset) => asset.name === name);
483
+ const items = [];
484
+ for (const kind of ["flow", "graph"]) {
485
+ const assets = catalog.filter((asset) => asset.kind === kind);
486
+ if (assets.length === 0) continue;
487
+ items.push({ type: "label", id: `label-${kind}`, text: kind === "flow" ? "Flow" : "Graph" });
488
+ for (const asset of assets) {
489
+ items.push({
490
+ id: assetKey(asset),
491
+ label: assetMenuLabel(asset, running)
492
+ });
493
+ }
494
+ if (kind === "flow" && catalog.some((asset) => asset.kind === "graph")) items.push({ type: "separator", id: "separator" });
495
+ }
496
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
497
+ import_dsh_client_ui_primitives.Menu,
498
+ {
499
+ open,
500
+ anchor: /* @__PURE__ */ (0, import_jsx_runtime.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: [
501
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-picker-text", children: selected ? `${selected.name} \xB7 ${selected.kind === "graph" ? `${selected.nodes.length} \u8282\u70B9` : `${selected.steps.length} \u6B65`}` : "\u9009\u62E9\u5DE5\u4F5C\u6D41" }),
502
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "rv-picker-chevron", width: "10", height: "10", viewBox: "0 0 10 10", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M2 3.5 5 6.5 8 3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }) })
503
+ ] }),
504
+ items,
505
+ selectedId: selected ? assetKey(selected) : void 0,
506
+ onSelect: (id) => {
507
+ const next = catalog.find((asset) => assetKey(asset) === id);
508
+ setOpen(false);
509
+ if (next) onChoose(next.name);
510
+ },
511
+ onClose: () => setOpen(false),
512
+ portal: true,
513
+ compact: true,
514
+ className: "rv-picker",
515
+ listClassName: "rv-picker-menu"
516
+ }
517
+ );
518
+ }
519
+ function Header({
520
+ asset,
521
+ graph,
522
+ flow,
523
+ catalog,
524
+ name,
525
+ running,
526
+ onChoose,
527
+ mode,
528
+ onMode
529
+ }) {
530
+ const summary = graph ? [
531
+ graph.counts.completed > 0 ? { key: "completed", label: "\u5B8C\u6210", value: graph.counts.completed, tone: "done" } : null,
532
+ graph.counts.running > 0 ? { key: "running", label: "\u6267\u884C", value: graph.counts.running, tone: "run" } : null,
533
+ graph.counts.waiting > 0 ? { key: "waiting", label: "\u7B49\u5F85", value: graph.counts.waiting, tone: "wait" } : null,
534
+ graph.counts.pending > 0 ? { key: "pending", label: "\u5F85\u5F00\u59CB", value: graph.counts.pending, tone: "off" } : null,
535
+ graph.counts.blocked > 0 ? { key: "blocked", label: "\u963B\u585E", value: graph.counts.blocked, tone: "fault" } : null
536
+ ].filter((item) => item !== null) : [];
537
+ const flowIndex = flow && asset ? asset.steps.findIndex((step) => step.id === flow.step) : -1;
538
+ const votesReturned = flow ? flow.votes.filter((vote) => vote.status === "passed" || vote.status === "failed" || vote.status === "infra").length : 0;
539
+ const baseMeta = !asset ? "\u9009\u62E9\u4E00\u4E2A\u5DE5\u4F5C\u6D41\u67E5\u770B\u53EA\u8BFB\u7ED3\u6784" : asset.invalid ? `\u5B9A\u4E49\u65E0\u6548 \xB7 ${asset.problems[0] ?? "\u6821\u9A8C\u5931\u8D25"}` : asset.kind === "graph" ? graph ? `${graph.phase} \xB7 ${graph.counts.completed}/${graph.counts.total} \u8282\u70B9\u5B8C\u6210 \xB7 \u53EA\u8BFB\u6D4F\u89C8` : `Graph \xB7 ${asset.nodes.length} \u4E2A\u8282\u70B9 \xB7 \u53EA\u8BFB\u6D4F\u89C8` : flow ? `${STAGE_LABELS[flow.stage]}${flow.stage === "verifying" && flow.votes.length > 1 ? ` ${votesReturned}/${flow.votes.length} \u7968` : ""}${flowIndex >= 0 ? ` \xB7 \u7B2C ${flowIndex + 1}/${asset.steps.length} \u6B65` : ""} \xB7 \u53EA\u8BFB\u6D4F\u89C8` : `Flow \xB7 ${asset.steps.length} \u4E2A\u6B65\u9AA4 \xB7 \u53EA\u8BFB\u6D4F\u89C8`;
540
+ const meta = running && asset && asset.name !== running ? `${baseMeta} \xB7 \u8FD0\u884C\u4E2D\uFF1A${running}` : baseMeta;
541
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "rv-head", children: [
542
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-kicker", children: [
543
+ "RalphFlow ",
544
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", children: "/" }),
545
+ " \u53EA\u8BFB\u5DE5\u4F5C\u56FE"
546
+ ] }),
547
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-title-row", children: [
548
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "rv-title", children: asset?.name ?? "\u5DE5\u4F5C\u6D41\u6D4F\u89C8" }),
549
+ asset ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-kind", children: asset.kind === "graph" ? "Graph" : "Flow" }) : null
550
+ ] }),
551
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "rv-meta", children: meta }),
552
+ asset?.description ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "rv-desc", children: asset.description }) : null,
553
+ summary.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Summary, { items: summary }) : null,
554
+ graph?.nextAction ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-callout", children: [
555
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: graph.nextAction.label }),
556
+ " \xB7 ",
557
+ graph.nextAction.message,
558
+ " ",
559
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-foot", children: "\u5728\u804A\u5929\u91CC\u5904\u7406\u3002" })
560
+ ] }) : null,
561
+ !graph && flow && (flow.stage === "gate" || flow.stage === "paused") ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-callout", children: [
562
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: STAGE_LABELS[flow.stage] }),
563
+ " \xB7 ",
564
+ flow.hint,
565
+ " ",
566
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-foot", children: "\u5728\u804A\u5929\u91CC\u7EE7\u7EED\u6216\u5BA1\u6279\u3002" })
567
+ ] }) : null,
568
+ catalog.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-toolbar", children: [
569
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "rv-select-label", children: "\u5DE5\u4F5C\u6D41" }),
570
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WorkflowPicker, { catalog, name, running, onChoose }),
571
+ asset?.kind === "graph" && !asset.invalid ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-switch", role: "group", "aria-label": "\u89C6\u56FE", children: [
572
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-pressed": mode === "columns", onClick: () => onMode("columns"), title: "\u4F9D\u8D56\u56FE\u753B\u5E03", children: "\u56FE" }),
573
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-pressed": mode === "outline", onClick: () => onMode("outline"), title: "\u4F9D\u8D56\u5217\u8868", children: "\u5217\u8868" })
574
+ ] }) : null
575
+ ] }) : null
576
+ ] });
577
+ }
578
+ function GraphCard({ node, graph, index, width, onOpen }) {
579
+ const runtime = nodeRuntimeOf(graph, node.id);
580
+ const status = runtime?.status ?? "pending";
581
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "rv-node", "data-ralphflow-node": node.id, "data-status": status, "aria-label": `\u67E5\u770B\u8282\u70B9 ${node.name}`, onClick: onOpen, style: { width }, children: [
582
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-node-top", children: [
583
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
584
+ "\u8282\u70B9 ",
585
+ String(index + 1).padStart(2, "0")
586
+ ] }),
587
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: node.id })
588
+ ] }),
589
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: node.name }),
590
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-card-badges", children: [
591
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chips, { chips: runtime ? graphPhaseChips(runtime) : graphAssetChips(node), current: runtime?.current }),
592
+ runtime?.check.reworks ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "rv-chip", "data-tone": "fault", children: [
593
+ "\u8FD4\u5DE5 ",
594
+ runtime.check.reworks,
595
+ " \u6B21"
596
+ ] }) : null,
597
+ node.manual ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-chip", "data-tone": "wait", children: "\u4EBA\u5DE5\u95E8" }) : null,
598
+ node.execution === "main" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-chip", "data-tone": "off", children: "\u4E3B\u4F1A\u8BDD" }) : null
599
+ ] }),
600
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-node-foot", children: [
601
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
602
+ "\u4F9D\u8D56\uFF1A",
603
+ node.dependsOn.length ? node.dependsOn.join("\u3001") : "\u8D77\u70B9\u8282\u70B9"
604
+ ] }),
605
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u8BE6\u60C5 \u2192" })
606
+ ] })
607
+ ] });
608
+ }
609
+ function GraphCanvas({ asset, graph, mode, width: availableWidth, onOpen }) {
610
+ const layout = layoutGraph(asset.nodes, availableWidth);
611
+ if (mode === "outline") {
612
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rv-outline", "data-ralphflow-outline": true, children: layout.columns.flatMap((column) => column.ids).map((id, index) => {
613
+ const node = asset.nodes.find((candidate) => candidate.id === id);
614
+ const runtime = nodeRuntimeOf(graph, node.id);
615
+ const status = runtime?.status ?? "pending";
616
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "rv-outline-row", "data-ralphflow-node": id, "data-status": status, "aria-label": `\u67E5\u770B\u8282\u70B9 ${node.name}`, onClick: () => onOpen(id), children: [
617
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-outline-name", children: [
618
+ String(index + 1).padStart(2, "0"),
619
+ " \xB7 ",
620
+ node.name
621
+ ] }),
622
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-outline-meta", children: [
623
+ "id ",
624
+ id,
625
+ " \xB7 \u4F9D\u8D56\u5C42 ",
626
+ String((layout.columnOf.get(id) ?? 0) + 1).padStart(2, "0")
627
+ ] }),
628
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-card-badges", children: [
629
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chips, { chips: runtime ? graphPhaseChips(runtime) : graphAssetChips(node), current: runtime?.current }),
630
+ runtime?.check.reworks ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "rv-chip", "data-tone": "fault", children: [
631
+ "\u8FD4\u5DE5 ",
632
+ runtime.check.reworks,
633
+ " \u6B21"
634
+ ] }) : null,
635
+ node.manual ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-chip", "data-tone": "wait", children: "\u4EBA\u5DE5\u95E8" }) : null,
636
+ node.execution === "main" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-chip", "data-tone": "off", children: "\u4E3B\u4F1A\u8BDD" }) : null
637
+ ] }),
638
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "rv-outline-deps", children: node.dependsOn.length ? `\u4F9D\u8D56\uFF1A${node.dependsOn.map((dep) => asset.nodes.find((candidate) => candidate.id === dep)?.name ?? dep).join("\u3001")}` : "\u8D77\u70B9\u8282\u70B9" })
639
+ ] }, id);
640
+ }) });
641
+ }
642
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
643
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-section-head", children: [
644
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u4F9D\u8D56\u56FE" }),
645
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u8282\u70B9\u6309\u4F9D\u8D56\u5C42\u4ECE\u5DE6\u5230\u53F3\uFF1B\u70B9\u8282\u70B9\u67E5\u770B DO / CHECK" })
646
+ ] }),
647
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rv-canvas-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-canvas", "data-ralphflow-dag": true, style: { width: layout.width, height: layout.height }, children: [
648
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: layout.width, height: layout.height, "aria-hidden": "true", children: layout.edges.map((edge) => {
649
+ const fromColumn = layout.columnOf.get(edge.from) ?? 0;
650
+ const toColumn = layout.columnOf.get(edge.to) ?? 0;
651
+ const fromRow = layout.rowOf.get(edge.from) ?? 0;
652
+ const toRow = layout.rowOf.get(edge.to) ?? 0;
653
+ const x1 = fromColumn * layout.columnStep + layout.cardWidth;
654
+ const x2 = toColumn * layout.columnStep;
655
+ const y1 = CANVAS_TOP + fromRow * ROW_STEP + CARD_HEIGHT / 2;
656
+ const y2 = CANVAS_TOP + toRow * ROW_STEP + CARD_HEIGHT / 2;
657
+ const curve = Math.max(20, Math.min(56, (x2 - x1) * 0.45));
658
+ const tone = statusToneOf(nodeRuntimeOf(graph, edge.to)?.status ?? "pending");
659
+ return /* @__PURE__ */ (0, import_jsx_runtime.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}`);
660
+ }) }),
661
+ layout.columns.map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "rv-column", style: { left: columnIndex * layout.columnStep, width: layout.cardWidth }, children: [
662
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-column-head", children: [
663
+ "\u4F9D\u8D56\u5C42 ",
664
+ String(columnIndex + 1).padStart(2, "0")
665
+ ] }),
666
+ column.ids.map((id, row) => {
667
+ const node = asset.nodes.find((candidate) => candidate.id === id);
668
+ const index = asset.nodes.findIndex((candidate) => candidate.id === id);
669
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { position: "absolute", top: CANVAS_TOP + row * ROW_STEP }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphCard, { node, graph, index, width: layout.cardWidth, onOpen: () => onOpen(id) }) }, id);
670
+ })
671
+ ] }, column.rank))
672
+ ] }) }),
673
+ layout.scrollable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rv-canvas-hint", children: "\u2190 \u5DE6\u53F3\u6EDA\u52A8\u67E5\u770B\u5B8C\u6574\u4F9D\u8D56\u56FE \u2192" }) : null
674
+ ] });
675
+ }
676
+ function FlowList({ asset, flow, onOpen }) {
677
+ const currentIndex = flow ? asset.steps.findIndex((step) => step.id === flow.step) : -1;
678
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
679
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-section-head", children: [
680
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u6B65\u9AA4\u94FE" }),
681
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "on_pass \u63A8\u8FDB \xB7 on_fail \u56DE\u9000" })
682
+ ] }),
683
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rv-flow", children: asset.steps.map((step, index) => {
684
+ const current = step.id === flow?.step;
685
+ const passed = flow?.stage === "done" || currentIndex >= 0 && index < currentIndex;
686
+ const runtime = flow?.steps.find((candidate) => candidate.id === step.id);
687
+ const failed = (runtime?.failures ?? 0) > 0;
688
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-flow-item", "data-current": current ? "true" : "false", "data-done": passed ? "true" : "false", children: [
689
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-flow-dot", "aria-hidden": "true" }),
690
+ /* @__PURE__ */ (0, import_jsx_runtime.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": `\u67E5\u770B\u6B65\u9AA4 ${step.description || step.id}`, onClick: () => onOpen(step.id), children: [
691
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-node-top", children: [
692
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
693
+ "\u6B65\u9AA4 ",
694
+ String(index + 1).padStart(2, "0"),
695
+ " \xB7 ",
696
+ step.id
697
+ ] }),
698
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: step.manual ? "\u4EBA\u5DE5\u95E8" : step.checks.length > 1 ? `${step.checks.length} \u7968 CHECK` : step.checks.length === 1 ? "\u6709 CHECK" : "\u65E0 CHECK" })
699
+ ] }),
700
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: step.description || step.id }),
701
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "rv-step-preview", children: step.checks.length ? `${step.checks[0].replace(/\s+/g, " ").trim()}${step.checks.length > 1 ? `\u3000\u7B49 ${step.checks.length} \u6761` : ""}` : "\u8DF3\u8FC7\u5BF9\u6297\u6027\u9A8C\u8BC1\uFF0C\u5B8C\u6210\u5373\u63A8\u8FDB\u3002" }),
702
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-card-badges", children: [
703
+ flow && current ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chips, { chips: flowPhaseChips(flow) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-chip", "data-tone": flow ? passed ? "done" : "off" : "off", children: flow ? passed ? "\u5DF2\u901A\u8FC7" : "\u672A\u5F00\u59CB" : "\u9759\u6001\u6D4F\u89C8" }),
704
+ failed ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "rv-chip", "data-tone": "fault", children: [
705
+ "\u8FD4\u5DE5 ",
706
+ runtime?.failures,
707
+ " \u6B21"
708
+ ] }) : null,
709
+ step.manual ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-chip", "data-tone": "wait", children: "\u4EBA\u5DE5\u95E8" }) : null
710
+ ] }),
711
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-node-foot", children: [
712
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
713
+ "\u901A\u8FC7 \u2192 ",
714
+ step.onPass === "done" ? "\u7ED3\u675F" : step.onPass || "\u4E0B\u4E00\u6B65"
715
+ ] }),
716
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u8BE6\u60C5 \u2192" })
717
+ ] })
718
+ ] })
719
+ ] }, step.id);
720
+ }) })
721
+ ] });
722
+ }
723
+ function Section({ label, children }) {
724
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "rv-section", children: [
725
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rv-label", children: label }),
726
+ children
727
+ ] });
728
+ }
729
+ function GraphInspector({ asset, graph, node, onClose }) {
730
+ const runtime = nodeRuntimeOf(graph, node.id);
731
+ const status = runtime?.status ?? "pending";
732
+ const checkMode = runtime?.check.mode ?? node.checkMode;
733
+ const dependencies = node.dependsOn.map((id) => asset.nodes.find((candidate) => candidate.id === id)?.name ?? id);
734
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", { className: "rv-inspector", "data-ralphflow-inspector": node.id, "data-status": status, "aria-label": `\u8282\u70B9\u8BE6\u60C5\uFF1A${node.name}`, children: [
735
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-inspector-head", children: [
736
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
737
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-eyebrow", children: [
738
+ "NODE \xB7 ",
739
+ node.id
740
+ ] }),
741
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "rv-inspector-title", children: node.name }),
742
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-inspector-sub", children: [
743
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chips, { chips: runtime ? graphPhaseChips(runtime) : graphAssetChips(node), current: runtime?.current }),
744
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
745
+ "\xB7 ",
746
+ node.execution === "main" ? "\u4E3B\u4F1A\u8BDD\u6267\u884C" : "\u540E\u53F0\u6267\u884C",
747
+ node.manual ? " \xB7 \u4EBA\u5DE5\u95E8" : ""
748
+ ] })
749
+ ] })
750
+ ] }),
751
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "rv-back", onClick: onClose, "aria-label": "\u8FD4\u56DE\u5DE5\u4F5C\u56FE", children: "\u2190 \u5DE5\u4F5C\u56FE" })
752
+ ] }),
753
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { label: "DO \xB7 \u8282\u70B9\u4EFB\u52A1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "rv-pre", "data-ralphflow-inspector-prompt": true, children: node.do || "\uFF08\u672A\u58F0\u660E DO\uFF09" }) }),
754
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { label: "CHECK \xB7 \u72EC\u7ACB\u9A8C\u6536", children: [
755
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-meta-row", children: [
756
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-chip", "data-tone": checkMode === "disabled" ? "off" : "run", children: checkMode === "disabled" ? "CHECK \u5173\u95ED" : "\u81EA\u5B9A\u4E49 CHECK" }),
757
+ runtime?.check.status && runtime.check.status !== "skipped" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-chip", "data-tone": CHECK_TONES[runtime.check.status] ?? "off", children: CHECK_LABELS[runtime.check.status] ?? runtime.check.status }) : null
758
+ ] }),
759
+ checkMode === "disabled" ? /* @__PURE__ */ (0, import_jsx_runtime.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" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "rv-pre", "data-ralphflow-inspector-check": true, children: node.check || "\uFF08\u672A\u58F0\u660E\u5224\u636E\uFF09" })
760
+ ] }),
761
+ runtime ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { label: "\u8FD0\u884C\u72B6\u6001", children: [
762
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "rv-note", children: [
763
+ "\u6267\u884C ",
764
+ runtime.attempts,
765
+ " \u6B21",
766
+ runtime.check.reworks ? ` \xB7 \u8FD4\u5DE5 ${runtime.check.reworks} \u6B21` : "",
767
+ runtime.check.reason ? ` \xB7 ${runtime.check.reason}` : ""
768
+ ] }),
769
+ runtime.artifact ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "rv-note", children: [
770
+ "\u4EA7\u7269\uFF1A",
771
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: "rv-code", children: runtime.artifact.path })
772
+ ] }) : null,
773
+ runtime.manual !== "not_required" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "rv-note", children: [
774
+ "\u4EBA\u5DE5\u95E8\uFF1A",
775
+ MANUAL_LABELS[runtime.manual] ?? runtime.manual
776
+ ] }) : null,
777
+ runtime.integration !== "not_required" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "rv-note", children: [
778
+ "\u5408\u5165\uFF1A",
779
+ INTEGRATION_LABELS[runtime.integration] ?? runtime.integration,
780
+ runtime.integrationCommit ? ` \xB7 ${runtime.integrationCommit.slice(0, 12)}\u2026` : ""
781
+ ] }) : null
782
+ ] }) : null,
783
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { label: "\u4F9D\u8D56", children: dependencies.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "rv-list", children: dependencies.map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: name }, name)) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "rv-note", children: "\u65E0\u4F9D\u8D56\uFF0C\u8D77\u70B9\u8282\u70B9\u3002" }) }),
784
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { label: "\u8F93\u5165\u4E0E\u8D44\u6599", children: node.inputs.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "rv-list", children: node.inputs.map((input) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("code", { className: "rv-code", children: [
785
+ input.fromNode,
786
+ "/",
787
+ input.artifact
788
+ ] }) }, `${input.fromNode}:${input.artifact}`)) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "rv-note", children: "\u65E0\u4E0A\u6E38\u4EA7\u7269\u8F93\u5165\u3002" }) }),
789
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { label: "\u4EA4\u4ED8\u7269", children: [
790
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: "rv-code", children: node.artifact }),
791
+ /* @__PURE__ */ (0, import_jsx_runtime.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" })
792
+ ] })
793
+ ] });
794
+ }
795
+ function StepInspector({ asset, flow, step, onClose }) {
796
+ const runtime = flow?.steps.find((candidate) => candidate.id === step.id);
797
+ const index = asset.steps.findIndex((candidate) => candidate.id === step.id);
798
+ const current = flow?.step === step.id;
799
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", { className: "rv-inspector", "data-status": flowPanelStatus(flow, current), "data-ralphflow-step-inspector": step.id, "aria-label": `\u6B65\u9AA4\u8BE6\u60C5\uFF1A${step.description || step.id}`, children: [
800
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-inspector-head", children: [
801
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
802
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-eyebrow", children: [
803
+ "STEP \xB7 ",
804
+ String(index + 1).padStart(2, "0"),
805
+ " \xB7 ",
806
+ step.id
807
+ ] }),
808
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "rv-inspector-title", children: step.description || step.id }),
809
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-inspector-sub", children: [
810
+ current && flow ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chips, { chips: flowPhaseChips(flow) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rv-chip", "data-tone": current ? "run" : "off", children: current ? "\u5F53\u524D\u6B65\u9AA4" : "\u9759\u6001\u6D4F\u89C8" }),
811
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
812
+ "\xB7 ",
813
+ step.manual ? "\u4EBA\u5DE5\u5BA1\u67E5\u95E8" : "\u81EA\u52A8\u63A8\u8FDB"
814
+ ] })
815
+ ] })
816
+ ] }),
817
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "rv-back", onClick: onClose, "aria-label": "\u8FD4\u56DE\u6B65\u9AA4\u94FE", children: "\u2190 \u6B65\u9AA4\u94FE" })
818
+ ] }),
819
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { label: "DO \xB7 \u6B65\u9AA4\u4EFB\u52A1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "rv-pre", children: step.do || "\uFF08\u672A\u58F0\u660E DO\uFF09" }) }),
820
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { label: "CHECK \xB7 \u72EC\u7ACB\u9A8C\u6536", children: step.checks.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "rv-note", children: "\uFF08\u8DF3\u8FC7\u5BF9\u6297\u6027\u9A8C\u8BC1\uFF09" }) : step.checks.length === 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "rv-pre", children: step.checks[0] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rv-check-list", children: step.checks.map((criterion, index2) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-check", children: [
821
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-label", children: [
822
+ "\u9A8C\u8BC1\u8005 ",
823
+ index2 + 1,
824
+ "/",
825
+ step.checks.length
826
+ ] }),
827
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "rv-pre", children: criterion })
828
+ ] }, index2)) }) }),
829
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { label: "\u6D41\u8F6C", children: [
830
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "rv-note", children: [
831
+ "\u901A\u8FC7 \u2192 ",
832
+ step.onPass === "done" ? "\u7ED3\u675F" : step.onPass || "\u4E0B\u4E00\u6B65"
833
+ ] }),
834
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "rv-note", children: [
835
+ "\u5931\u8D25 \u2192 ",
836
+ step.onFail === "done" ? "\u7ED3\u675F" : step.onFail || "\u81EA\u8EAB"
837
+ ] })
838
+ ] }),
839
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { label: "\u8F93\u5165 / \u4EA4\u4ED8\u7269", children: [
840
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "rv-note", children: [
841
+ "\u8F93\u5165\uFF1A",
842
+ step.input || "\uFF08\u65E0\uFF09"
843
+ ] }),
844
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "rv-note", children: [
845
+ "\u4EA4\u4ED8\u7269\uFF1A",
846
+ step.output || "\uFF08\u65E0\uFF09"
847
+ ] }),
848
+ runtime ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "rv-note", children: [
849
+ "\u672C\u6B65\u8FD4\u5DE5\u6B21\u6570\uFF1A",
850
+ runtime.failures
851
+ ] }) : null
852
+ ] })
853
+ ] });
854
+ }
855
+ function ViewerPage(props) {
856
+ injectViewerCss();
857
+ const status = (0, import_react.useSyncExternalStore)(props.source.subscribe, props.source.getSnapshot, props.source.getSnapshot);
858
+ const [chosenName, setChosenName] = (0, import_react.useState)(null);
859
+ const [pinnedName, setPinnedName] = (0, import_react.useState)(() => readStored(ASSET_STORAGE_KEY));
860
+ const [selectedNode, setSelectedNode] = (0, import_react.useState)(null);
861
+ const [selectedStep, setSelectedStep] = (0, import_react.useState)(null);
862
+ const [preferredMode, setPreferredMode] = (0, import_react.useState)(() => {
863
+ const stored = readStored(VIEW_STORAGE_KEY);
864
+ return stored === "columns" || stored === "outline" ? stored : null;
865
+ });
866
+ const [width, setWidth] = (0, import_react.useState)(0);
867
+ const rootRef = (0, import_react.useRef)(null);
868
+ const catalog = status.catalog;
869
+ const currentName = status.status?.workflow ?? null;
870
+ const running = currentName && catalog.some((asset2) => asset2.name === currentName) ? currentName : null;
871
+ const name = pickAssetName({ catalogNames: catalog.map((asset2) => asset2.name), running, chosen: chosenName, pinned: pinnedName });
872
+ const asset = catalog.find((candidate) => candidate.name === name) ?? null;
873
+ const graph = asset ? graphRuntimeOf(status, asset) : null;
874
+ const flow = asset ? flowRuntimeOf(status, asset) : null;
875
+ const mode = preferredMode ?? "outline";
876
+ (0, import_react.useEffect)(() => {
877
+ setChosenName(null);
878
+ }, [running]);
879
+ (0, import_react.useEffect)(() => {
880
+ const element = rootRef.current;
881
+ if (!element) return;
882
+ const measure = () => setWidth(element.clientWidth);
883
+ measure();
884
+ if (typeof ResizeObserver === "undefined") return;
885
+ const observer = new ResizeObserver(measure);
886
+ observer.observe(element);
887
+ return () => observer.disconnect();
888
+ }, []);
889
+ (0, import_react.useEffect)(() => {
890
+ const element = rootRef.current;
891
+ if (element) element.scrollTop = 0;
892
+ }, [name, mode, selectedNode, selectedStep]);
893
+ const choose = (next) => {
894
+ setChosenName(next);
895
+ setPinnedName(next);
896
+ storeStored(ASSET_STORAGE_KEY, next);
897
+ setSelectedNode(null);
898
+ setSelectedStep(null);
899
+ };
900
+ const chooseMode = (next) => {
901
+ setPreferredMode(next);
902
+ storeStored(VIEW_STORAGE_KEY, next);
903
+ };
904
+ const selectedGraphNode = selectedNode && asset?.kind === "graph" ? asset.nodes.find((node) => node.id === selectedNode) ?? null : null;
905
+ const selectedFlowStep = selectedStep && asset?.kind === "flow" ? asset.steps.find((step) => step.id === selectedStep) ?? null : null;
906
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: rootRef, className: "ralphflow-viewer", "data-ralphflow-viewer": true, children: [
907
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, { asset, graph, flow, catalog, name, running, onChoose: choose, mode, onMode: chooseMode }),
908
+ status.connection !== "live" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rv-banner", "data-kind": status.error ? "error" : void 0, children: status.error ?? "\u6B63\u5728\u91CD\u65B0\u540C\u6B65\uFF0C\u663E\u793A\u6700\u540E\u72B6\u6001\u3002" }) : null,
909
+ catalog.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rv-empty", children: [
910
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "\u8FD8\u6CA1\u6709\u53EF\u663E\u793A\u7684\u5DE5\u4F5C\u6D41" }),
911
+ /* @__PURE__ */ (0, import_jsx_runtime.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" })
912
+ ] }) : null,
913
+ asset?.invalid ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rv-banner", "data-kind": "error", children: asset.problems.join("\n") }) : null,
914
+ asset && !asset.invalid ? selectedGraphNode ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphInspector, { asset, graph, node: selectedGraphNode, onClose: () => setSelectedNode(null) }) : selectedFlowStep ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StepInspector, { asset, flow, step: selectedFlowStep, onClose: () => setSelectedStep(null) }) : asset.kind === "graph" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphCanvas, { asset, graph, mode, width: Math.max(0, width - 28), onOpen: setSelectedNode }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FlowList, { asset, flow, onOpen: setSelectedStep }) : null
915
+ ] });
916
+ }
917
+ function registerViewerTab(ctx, sourceOf) {
918
+ const face = ctx;
919
+ const rightTabs = ctx.get?.("sidebarRightTabs");
920
+ if (!rightTabs || !face.slots) return;
921
+ try {
922
+ face.effect?.(() => rightTabs.register({
923
+ id: VIEWER_TAB_ID,
924
+ kind: VIEWER_KIND,
925
+ title: () => "RalphFlow \u5DE5\u4F5C\u56FE\uFF08\u53EA\u8BFB\uFF09",
926
+ guide: [{
927
+ id: VIEWER_TAB_ID,
928
+ order: 10,
929
+ title: () => "RalphFlow \u5DE5\u4F5C\u56FE\uFF08\u53EA\u8BFB\uFF09",
930
+ description: () => "\u67E5\u770B Flow \u6B65\u9AA4\u94FE\u4E0E Graph DAG\u3001\u8282\u70B9 DO/CHECK \u548C\u5F53\u524D\u72B6\u6001\uFF1B\u542F\u52A8\u3001\u7EE7\u7EED\u4E0E\u5BA1\u6279\u90FD\u5728\u804A\u5929\u91CC\u5B8C\u6210\u3002"
931
+ }]
932
+ }), "ralphflow viewer tab type");
933
+ face.slots.inject("sidebar.right.pane.tab", () => {
934
+ try {
935
+ return face.slots.register({
936
+ name: "sidebar.right.pane.tab",
937
+ key: VIEWER_TAB_ID,
938
+ inject: (sessionId) => ({ sessionId, source: sourceOf(sessionId) })
939
+ }, ViewerPage);
940
+ } catch {
941
+ return () => {
942
+ };
943
+ }
944
+ });
945
+ } catch {
946
+ }
947
+ }
948
+
74
949
  // src/status-contract.ts
75
950
  function record(value) {
76
951
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("expected status object");
@@ -96,17 +971,136 @@ function choice(value, values) {
96
971
  if (!values.includes(value)) throw new TypeError("unknown status variant");
97
972
  return value;
98
973
  }
974
+ function nullableString(value) {
975
+ return value === null || value === void 0 ? null : string(value);
976
+ }
977
+ function parseGraphStatus(value) {
978
+ const view = record(value);
979
+ const counts = record(view.counts);
980
+ const currentRaw = view.current;
981
+ const nextRaw = view.nextAction;
982
+ const integrationRaw = view.integration;
983
+ const delivery = record(view.delivery);
984
+ return {
985
+ phase: string(view.phase),
986
+ status: string(view.status),
987
+ counts: {
988
+ total: count(counts.total),
989
+ completed: count(counts.completed),
990
+ running: count(counts.running),
991
+ waiting: count(counts.waiting),
992
+ pending: count(counts.pending),
993
+ blocked: count(counts.blocked)
994
+ },
995
+ current: currentRaw === null || currentRaw === void 0 ? null : (() => {
996
+ const item = record(currentRaw);
997
+ return { nodeId: string(item.nodeId), name: string(item.name), status: string(item.status) };
998
+ })(),
999
+ nextAction: nextRaw === null || nextRaw === void 0 ? null : (() => {
1000
+ const item = record(nextRaw);
1001
+ return {
1002
+ kind: string(item.kind),
1003
+ label: string(item.label),
1004
+ message: string(item.message),
1005
+ ...item.todoId === void 0 ? {} : { todoId: string(item.todoId) },
1006
+ ...item.nodeId === void 0 ? {} : { nodeId: string(item.nodeId) }
1007
+ };
1008
+ })(),
1009
+ nodes: array(view.nodes, (node) => {
1010
+ const item = record(node);
1011
+ const artifact = item.artifact;
1012
+ const check = record(item.check);
1013
+ return {
1014
+ id: string(item.id),
1015
+ name: string(item.name),
1016
+ status: string(item.status),
1017
+ label: string(item.label),
1018
+ dependsOn: array(item.dependsOn, string),
1019
+ attempts: count(item.attempts),
1020
+ current: bool(item.current),
1021
+ execution: choice(item.execution, ["background", "main"]),
1022
+ artifact: artifact === null || artifact === void 0 ? null : (() => {
1023
+ const a = record(artifact);
1024
+ return { path: string(a.path), sha256: string(a.sha256) };
1025
+ })(),
1026
+ check: { mode: string(check.mode), status: string(check.status), reason: string(check.reason), reworks: count(check.reworks) },
1027
+ manual: string(item.manual),
1028
+ integration: string(item.integration),
1029
+ integrationCommit: nullableString(item.integrationCommit),
1030
+ todoId: nullableString(item.todoId)
1031
+ };
1032
+ }),
1033
+ integration: integrationRaw === null || integrationRaw === void 0 ? null : (() => {
1034
+ const item = record(integrationRaw);
1035
+ return { branch: string(item.branch), currentCommit: string(item.currentCommit), accepted: count(item.accepted) };
1036
+ })(),
1037
+ delivery: {
1038
+ success: bool(delivery.success),
1039
+ outcome: string(delivery.outcome),
1040
+ delivered: count(delivery.delivered),
1041
+ unaccepted: count(delivery.unaccepted),
1042
+ unverified: count(delivery.unverified),
1043
+ unfinished: count(delivery.unfinished),
1044
+ ...delivery.reason === void 0 ? {} : { reason: string(delivery.reason) }
1045
+ }
1046
+ };
1047
+ }
1048
+ function parseViewerAsset(value) {
1049
+ const asset = record(value);
1050
+ const kind = choice(asset.kind, ["flow", "graph"]);
1051
+ return {
1052
+ name: string(asset.name),
1053
+ kind,
1054
+ description: string(asset.description),
1055
+ invalid: bool(asset.invalid),
1056
+ problems: array(asset.problems, string),
1057
+ steps: array(asset.steps, (step) => {
1058
+ const item = record(step);
1059
+ return {
1060
+ id: string(item.id),
1061
+ description: string(item.description),
1062
+ do: string(item.do),
1063
+ checks: array(item.checks, string),
1064
+ input: string(item.input),
1065
+ output: string(item.output),
1066
+ onPass: string(item.onPass),
1067
+ onFail: string(item.onFail),
1068
+ manual: bool(item.manual)
1069
+ };
1070
+ }),
1071
+ nodes: array(asset.nodes, (node) => {
1072
+ const item = record(node);
1073
+ return {
1074
+ id: string(item.id),
1075
+ name: string(item.name),
1076
+ do: string(item.do),
1077
+ artifact: string(item.artifact),
1078
+ dependsOn: array(item.dependsOn, string),
1079
+ inputs: array(item.inputs, (input) => {
1080
+ const x = record(input);
1081
+ return { fromNode: string(x.fromNode), artifact: string(x.artifact) };
1082
+ }),
1083
+ execution: choice(item.execution, ["background", "main"]),
1084
+ check: string(item.check),
1085
+ checkMode: item.checkMode === void 0 ? "custom" : choice(item.checkMode, ["custom", "disabled"]),
1086
+ manual: bool(item.manual)
1087
+ };
1088
+ })
1089
+ };
1090
+ }
99
1091
  function parseStatusFrame(value) {
100
1092
  const frame = record(value);
101
1093
  let status = null;
102
1094
  if (frame.status !== null) {
103
1095
  const s = record(frame.status);
1096
+ const kind = s.kind === "graph" ? "graph" : "flow";
104
1097
  status = {
105
1098
  id: string(s.id),
1099
+ kind,
106
1100
  workflow: string(s.workflow),
107
1101
  task: string(s.task),
108
1102
  step: string(s.step),
109
- stage: choice(s.stage, ["executing", "verifying", "gate", "paused", "switching", "done", "cancelled", "unavailable"]),
1103
+ stage: choice(s.stage, ["executing", "verifying", "gate", "paused", "switching", "done", "cancelled", "failed", "unavailable"]),
110
1104
  hint: string(s.hint),
111
1105
  failures: count(s.failures),
112
1106
  maxFailures: count(s.maxFailures),
@@ -118,23 +1112,30 @@ function parseStatusFrame(value) {
118
1112
  }),
119
1113
  votes: array(s.votes, (v) => {
120
1114
  const x = record(v);
121
- return { index: count(x.index), status: choice(x.status, ["pending", "running", "passed", "failed", "infra"]), reason: string(x.reason) };
1115
+ return { index: count(x.index), status: choice(x.status, ["pending", "running", "passed", "failed", "infra"]), reason: string(x.reason), ...x.check === void 0 ? {} : { check: string(x.check) } };
122
1116
  }),
123
1117
  recent: array(s.recent, (v) => {
124
1118
  const x = record(v);
125
1119
  return { step: string(x.step), event: string(x.event), detail: string(x.detail) };
126
- })
1120
+ }),
1121
+ ...kind === "graph" || s.graph !== void 0 ? { graph: parseGraphStatus(s.graph) } : {}
127
1122
  };
128
1123
  }
129
1124
  return {
130
1125
  kind: choice(frame.kind, ["snapshot", "update"]),
131
1126
  sessionId: string(frame.sessionId),
132
1127
  status,
133
- error: frame.error === null ? null : string(frame.error)
1128
+ error: frame.error === null ? null : string(frame.error),
1129
+ catalog: frame.catalog === void 0 ? [] : array(frame.catalog, parseViewerAsset)
134
1130
  };
135
1131
  }
1132
+ function parsePauseResult(value) {
1133
+ const result = record(value);
1134
+ return { ok: bool(result.ok), text: string(result.text) };
1135
+ }
136
1136
  var sessionCodec = { mode: "strict", typeSymbol: "@deepseek-ai/dsh-session/types#SessionId", create: () => ({ parse: string }) };
137
1137
  var frameCodec = { mode: "strict", typeSymbol: "ralphflow-dsh#StatusFrame", create: () => ({ parse: parseStatusFrame }) };
1138
+ var pauseCodec = { mode: "strict", typeSymbol: "ralphflow-dsh#PauseResult", create: () => ({ parse: parsePauseResult }) };
138
1139
  var statusDescriptors = [{
139
1140
  id: "ralphflow-dsh#ralphflowStatus/watch",
140
1141
  service: "ralphflowStatus",
@@ -145,13 +1146,21 @@ var statusDescriptors = [{
145
1146
  parameters: [{ name: "session", wire: "sessionId", source: "lookup", lookup: "session", codec: sessionCodec }],
146
1147
  cancellation: { parameter: "signal" },
147
1148
  result: frameCodec
1149
+ }, {
1150
+ id: "ralphflow-dsh#ralphflowStatus/pause",
1151
+ service: "ralphflowStatus",
1152
+ namespace: "ralphflowStatus",
1153
+ method: "pause",
1154
+ invocation: { kind: "direct" },
1155
+ parameters: [{ name: "session", wire: "sessionId", source: "lookup", lookup: "session", codec: sessionCodec }],
1156
+ result: pauseCodec
148
1157
  }];
149
1158
  var statusRemote = { package: "ralphflow-dsh", descriptors: statusDescriptors };
150
1159
 
151
1160
  // src/client/status-source.ts
152
1161
  var import_client = require("@deepseek-ai/dsh-api-gateway/client");
153
1162
  function createStatusSource(ctx, sessionId) {
154
- let snapshot = { status: null, connection: "connecting", error: null };
1163
+ let snapshot = { status: null, connection: "connecting", error: null, catalog: [] };
155
1164
  const listeners = /* @__PURE__ */ new Set();
156
1165
  let stream;
157
1166
  let token = 0;
@@ -170,7 +1179,7 @@ function createStatusSource(ctx, sessionId) {
170
1179
  if (incarnation !== token) return;
171
1180
  const frame = parseStatusFrame(raw);
172
1181
  if (frame.sessionId !== sessionId) throw new Error("status stream crossed Session binding");
173
- publish({ status: frame.status, connection: "live", error: frame.error });
1182
+ publish({ status: frame.status, connection: "live", error: frame.error, catalog: frame.catalog });
174
1183
  };
175
1184
  const carrier = ctx.remote.$stream({
176
1185
  name: `ralphflow status ${sessionId}`,
@@ -195,6 +1204,7 @@ function createStatusSource(ctx, sessionId) {
195
1204
  };
196
1205
  return {
197
1206
  getSnapshot: () => snapshot,
1207
+ pause: () => ctx.remote.ralphflowStatus.pause(sessionId),
198
1208
  subscribe(listener) {
199
1209
  listeners.add(listener);
200
1210
  if (listeners.size === 1) start();
@@ -211,7 +1221,7 @@ function createStatusSource(ctx, sessionId) {
211
1221
  }
212
1222
 
213
1223
  // src/client/status.tsx
214
- var import_jsx_runtime = require("react/jsx-runtime");
1224
+ var import_jsx_runtime2 = require("react/jsx-runtime");
215
1225
  var labels = {
216
1226
  executing: "\u5F85\u4EA4\u5377",
217
1227
  verifying: "\u72EC\u7ACB\u9A8C\u8BC1\u4E2D",
@@ -220,16 +1230,19 @@ var labels = {
220
1230
  switching: "\u5207\u6362\u6B65\u9AA4\u4E2D",
221
1231
  done: "\u5DF2\u5B8C\u6210",
222
1232
  cancelled: "\u5DF2\u53D6\u6D88",
1233
+ failed: "\u5931\u8D25",
223
1234
  unavailable: "\u72B6\u6001\u4E0D\u53EF\u7528"
224
1235
  };
225
1236
  var votes = { pending: "\u7B49\u5F85\u9A8C\u8BC1", running: "\u9A8C\u8BC1\u4E2D", passed: "\u901A\u8FC7", failed: "\u672A\u901A\u8FC7", infra: "\u9A8C\u8BC1\u8005\u6545\u969C" };
1237
+ var checks = { passed: "\u5DF2\u901A\u8FC7", failed: "\u672A\u901A\u8FC7", infra: "\u9A8C\u8BC1\u672A\u8DD1\u6210", pending: "\u5F85\u9A8C\u8BC1", skipped: "\u5DF2\u8DF3\u8FC7" };
226
1238
  var actionStages = /* @__PURE__ */ new Set(["gate", "paused"]);
227
- var terminalStages = /* @__PURE__ */ new Set(["done", "cancelled"]);
1239
+ var terminalStages = /* @__PURE__ */ new Set(["done", "cancelled", "failed"]);
228
1240
  var whole = (s) => s;
229
- var css = `
1241
+ var css2 = `
230
1242
  .ralphflow-status { position: relative; display: inline-flex; align-items: center; gap: 4px; max-width: min(320px, 38vw); min-height: 28px; padding: 3px 2px; border: 0; background: none; color: var(--dsw-alias-label-tertiary); font: inherit; font-size: var(--dsw-font-xxs-12-font-size); line-height: var(--dsw-font-xxs-12-line-height); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
231
1243
  .ralphflow-status:hover, .ralphflow-status:focus-visible { color: var(--dsw-alias-label-secondary); }
232
1244
  .ralphflow-status-dot { flex: none; }
1245
+ .ralphflow-status > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
233
1246
  .ralphflow-status-popover { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, calc(100vw - 32px)); max-height: min(480px, 100vh - 140px); z-index: 100; box-sizing: border-box; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 12px; overflow: auto; --dsw-elevation-stroke-color: var(--dsw-alias-border-l1); border: 0; border-radius: var(--dsw-radius-lg); background: var(--dsw-alias-bg-layer-2); box-shadow: var(--dsw-elevation-prominent); color: var(--dsw-alias-label-primary); font-size: var(--dsh-content-font-size-secondary); line-height: var(--dsw-font-xs-13-line-height); }
234
1247
  .ralphflow-status-popover-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
235
1248
  .ralphflow-status-popover-title { min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -243,6 +1256,7 @@ var css = `
243
1256
  .ralphflow-status-steps li { overflow-wrap: anywhere; }
244
1257
  .ralphflow-status-votes { margin: 4px 0; padding-left: 20px; }
245
1258
  .ralphflow-status-votes li { overflow-wrap: anywhere; }
1259
+ .ralphflow-status-vote-check { color: var(--dsw-alias-label-tertiary); }
246
1260
  .ralphflow-status-recent { margin: 4px 0; padding-left: 20px; }
247
1261
  .ralphflow-status-recent li { overflow-wrap: anywhere; }
248
1262
  .ralphflow-status-report { margin: 0; overflow-wrap: anywhere; }
@@ -250,6 +1264,9 @@ var css = `
250
1264
  .ralphflow-status-action-dock { width: calc(100% - 2 * var(--dsh-composer-side-clearance) - 4 * var(--dsh-composer-dock-inset)); margin: 0 auto; }
251
1265
  .ralphflow-status-action { box-sizing: border-box; width: 100%; max-width: calc(var(--dsh-composer-card-max-width) - 4 * var(--dsh-composer-dock-inset)); margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 4px 12px; border: 0; border-radius: var(--dsw-radius-md); background: var(--dsw-alias-bg-layer-2); box-shadow: var(--dsw-elevation-panel); color: var(--dsw-alias-label-primary); font-size: var(--dsh-content-font-size-secondary); line-height: var(--dsw-font-xs-13-line-height); min-height: 36px; --dsw-elevation-stroke-color: var(--dsw-alias-border-l1); }
252
1266
  .ralphflow-status-action-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1267
+ .ralphflow-status-pause { flex: none; margin-left: auto; padding: 3px 10px; border: 1px solid var(--dsw-alias-border-l1); border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; cursor: pointer; }
1268
+ .ralphflow-status-pause:hover:not(:disabled) { background: var(--dsw-alias-bg-module-platform); }
1269
+ .ralphflow-status-pause:disabled { opacity: .6; cursor: default; }
253
1270
  /* The timeline broadcast row keeps its record role; only its radius/font move to tokens. */
254
1271
  .ralphflow-notice { margin: 8px 0; padding: 8px 12px; border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-bg-module-platform); color: inherit; font-size: var(--dsh-content-font-size-secondary); line-height: 1.6; overflow-wrap: anywhere; }
255
1272
  .ralphflow-notice > summary { cursor: pointer; }
@@ -259,31 +1276,31 @@ function injectStatusCss() {
259
1276
  if (typeof document === "undefined" || document.querySelector("style[data-ralphflow-status-css]") !== null) return;
260
1277
  const style = document.createElement("style");
261
1278
  style.dataset.ralphflowStatusCss = "";
262
- style.textContent = css;
1279
+ style.textContent = css2;
263
1280
  document.head.appendChild(style);
264
1281
  }
265
1282
  injectStatusCss();
266
1283
  function StatusDot({ stage }) {
267
- const state = stage === "done" ? "done" : stage === "gate" || stage === "paused" ? "warning" : stage === "unavailable" ? "error" : stage === "cancelled" ? "idle" : "ongoing";
268
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.StateDot, { state, className: "ralphflow-status-dot" });
1284
+ const state = stage === "done" ? "done" : stage === "gate" || stage === "paused" ? "warning" : stage === "unavailable" || stage === "failed" ? "error" : stage === "cancelled" ? "idle" : "ongoing";
1285
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.StateDot, { state, className: "ralphflow-status-dot" });
269
1286
  }
270
1287
  function WorkflowStatusControl({ useWorkflowStatus }) {
271
1288
  const { status, connection } = useWorkflowStatus(whole);
272
- const [opened, setOpened] = (0, import_react.useState)(false);
273
- const id = (0, import_react.useId)();
274
- const root = (0, import_react.useRef)(null);
275
- const trigger = (0, import_react.useRef)(null);
276
- (0, import_dsh_client_ui_primitives.useDismissOnOutsidePointer)(root, opened, setOpened);
1289
+ const [opened, setOpened] = (0, import_react2.useState)(false);
1290
+ const id = (0, import_react2.useId)();
1291
+ const root = (0, import_react2.useRef)(null);
1292
+ const trigger = (0, import_react2.useRef)(null);
1293
+ (0, import_dsh_client_ui_primitives2.useDismissOnOutsidePointer)(root, opened, setOpened);
277
1294
  if (!status) return null;
278
1295
  const terminal = terminalStages.has(status.stage);
279
1296
  const label = labels[status.stage];
280
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: root, style: { position: "relative" }, onKeyDown: (e) => {
1297
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: root, style: { position: "relative" }, onKeyDown: (e) => {
281
1298
  if (e.key === "Escape") {
282
1299
  setOpened(false);
283
1300
  trigger.current?.focus();
284
1301
  }
285
1302
  }, children: [
286
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1303
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
287
1304
  "button",
288
1305
  {
289
1306
  ref: trigger,
@@ -296,17 +1313,17 @@ function WorkflowStatusControl({ useWorkflowStatus }) {
296
1313
  "aria-controls": opened ? id : void 0,
297
1314
  "aria-label": "\u67E5\u770B\u5DE5\u4F5C\u6D41\u72B6\u6001",
298
1315
  onClick: () => setOpened((v) => !v),
299
- title: `${status.workflow} \xB7 ${status.step} \xB7 ${label}`,
1316
+ title: `${status.workflow} \xB7 ${status.kind === "graph" ? status.graph?.current?.name ?? status.graph?.phase ?? "Graph" : status.step} \xB7 ${label}`,
300
1317
  children: [
301
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDot, { stage: status.stage }),
302
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
303
- terminal ? `${label} \xB7 \u62A5\u544A` : `${status.step} \xB7 ${status.stage === "paused" ? `\u5931\u8D25 ${status.failures} \u6B21` : `\u7B2C ${status.failures + 1} \u8F6E`} \xB7 ${label}`,
1318
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StatusDot, { stage: status.stage }),
1319
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1320
+ status.kind === "graph" ? `${status.graph?.phase ?? label}${status.graph?.counts ? ` \xB7 ${status.graph.counts.completed}/${status.graph.counts.total}` : ""}${connection === "live" ? "" : " \xB7 \u540C\u6B65\u4E2D"}` : terminal ? `${label} \xB7 \u62A5\u544A` : `${status.step} \xB7 ${status.stage === "paused" ? `\u8FD4\u5DE5 ${status.failures} \u6B21` : `\u7B2C ${status.failures + 1} \u8F6E`} \xB7 ${label}`,
304
1321
  connection === "live" ? "" : " \xB7 \u540C\u6B65\u4E2D"
305
1322
  ] })
306
1323
  ]
307
1324
  }
308
1325
  ),
309
- opened ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WorkflowStatusPopover, { id, useWorkflowStatus }) : null
1326
+ opened ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WorkflowStatusPopover, { id, useWorkflowStatus }) : null
310
1327
  ] });
311
1328
  }
312
1329
  function WorkflowStatusPopover({ id, useWorkflowStatus }) {
@@ -315,89 +1332,162 @@ function WorkflowStatusPopover({ id, useWorkflowStatus }) {
315
1332
  const terminal = terminalStages.has(status.stage);
316
1333
  const returned = status.votes.filter((v) => v.status === "passed" || v.status === "failed" || v.status === "infra").length;
317
1334
  const nearLimit = status.maxFailures > 0 && status.failures > 0 && status.failures >= status.maxFailures * 0.8;
318
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { id, className: "ralphflow-status-popover", "data-ralphflow-status-popover": true, role: "status", children: [
319
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ralphflow-status-popover-head", children: [
320
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ralphflow-status-popover-title", children: [
1335
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { id, className: "ralphflow-status-popover", "data-ralphflow-status-popover": true, role: "status", children: [
1336
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-popover-head", children: [
1337
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "ralphflow-status-popover-title", children: [
321
1338
  "Ralph Flow \xB7 ",
322
1339
  status.workflow
323
1340
  ] }),
324
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ralphflow-status-popover-stage", children: [
1341
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "ralphflow-status-popover-stage", children: [
325
1342
  labels[status.stage],
326
1343
  connection === "live" ? "" : " \xB7 \u540C\u6B65\u4E2D"
327
1344
  ] })
328
1345
  ] }),
329
- error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ralphflow-status-banner", "data-kind": "error", role: "status", children: [
1346
+ error ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-banner", "data-kind": "error", role: "status", children: [
330
1347
  "Ralph Flow \xB7 ",
331
1348
  error
332
1349
  ] }) : null,
333
- connection !== "live" && !error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ralphflow-status-banner", role: "status", children: "\u6B63\u5728\u91CD\u65B0\u540C\u6B65\uFF0C\u663E\u793A\u6700\u540E\u72B6\u6001\u3002" }) : null,
334
- !terminal && nearLimit ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ralphflow-status-banner", role: "status", children: [
335
- "\u672C\u6B65\u5931\u8D25\u63A5\u8FD1\u4E0A\u9650 \xB7 ",
1350
+ connection !== "live" && !error ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ralphflow-status-banner", role: "status", children: "\u6B63\u5728\u91CD\u65B0\u540C\u6B65\uFF0C\u663E\u793A\u6700\u540E\u72B6\u6001\u3002" }) : null,
1351
+ !terminal && nearLimit ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-banner", role: "status", children: [
1352
+ "\u672C\u6B65\u8FD4\u5DE5\u63A5\u8FD1\u4E0A\u9650 \xB7 ",
336
1353
  status.failures,
337
1354
  "/",
338
1355
  status.maxFailures
339
1356
  ] }) : null,
340
- !terminal && status.hint ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ralphflow-status-hint", children: status.hint }) : null,
341
- !terminal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "ralphflow-status-task", children: status.task }) : null,
342
- !terminal ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ralphflow-status-label", children: [
343
- "\u672C\u6B65\u5931\u8D25 ",
1357
+ !terminal && status.hint ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ralphflow-status-hint", children: status.hint }) : null,
1358
+ !terminal ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "ralphflow-status-task", children: status.task }) : null,
1359
+ status.kind === "graph" && status.graph ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1360
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-label", children: [
1361
+ "\u8282\u70B9 \xB7 ",
1362
+ status.graph.counts.completed,
1363
+ "/",
1364
+ status.graph.counts.total,
1365
+ " \u5DF2\u5B8C\u6210",
1366
+ status.graph.counts.running ? ` \xB7 ${status.graph.counts.running} \u5728\u98DE` : ""
1367
+ ] }),
1368
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ol", { className: "ralphflow-status-steps", "aria-label": "Graph \u8282\u70B9", children: status.graph.nodes.map((node) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { "aria-current": node.current ? "step" : void 0, children: [
1369
+ node.current ? "\u2192 " : "",
1370
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: node.id }),
1371
+ " \xB7 ",
1372
+ node.name,
1373
+ " \xB7 ",
1374
+ node.label,
1375
+ node.check.mode !== "disabled" ? ` \xB7 CHECK ${checks[node.check.status] ?? node.check.status}` : "",
1376
+ node.check.reworks ? ` \xB7 \u8FD4\u5DE5 ${node.check.reworks} \u6B21` : ""
1377
+ ] }, node.id)) }),
1378
+ status.graph.integration ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-label", children: [
1379
+ "\u96C6\u6210\u5206\u652F ",
1380
+ status.graph.integration.branch,
1381
+ " \xB7 \u5DF2\u63A5\u7EB3 ",
1382
+ status.graph.integration.accepted
1383
+ ] }) : null,
1384
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-label", children: [
1385
+ "\u4EA4\u4ED8 \xB7 \u5DF2\u4EA4\u4ED8 ",
1386
+ status.graph.delivery.delivered,
1387
+ " \xB7 \u672A\u63A5\u7EB3 ",
1388
+ status.graph.delivery.unaccepted,
1389
+ " \xB7 \u672A\u9A8C\u8BC1 ",
1390
+ status.graph.delivery.unverified,
1391
+ " \xB7 \u672A\u5B8C\u6210 ",
1392
+ status.graph.delivery.unfinished
1393
+ ] })
1394
+ ] }) : null,
1395
+ status.kind !== "graph" && !terminal ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-label", children: [
1396
+ "\u672C\u6B65\u8FD4\u5DE5 ",
344
1397
  status.failures,
345
1398
  " \u6B21"
346
1399
  ] }) : null,
347
- !terminal && status.steps.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
348
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ralphflow-status-label", children: "\u6B65\u9AA4" }),
349
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", { className: "ralphflow-status-steps", "aria-label": "\u5DE5\u4F5C\u6D41\u6B65\u9AA4", children: status.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { "aria-current": step.current ? "step" : void 0, children: [
1400
+ status.kind !== "graph" && !terminal && status.steps.length ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1401
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ralphflow-status-label", children: "\u6B65\u9AA4" }),
1402
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ol", { className: "ralphflow-status-steps", "aria-label": "\u5DE5\u4F5C\u6D41\u6B65\u9AA4", children: status.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { "aria-current": step.current ? "step" : void 0, children: [
350
1403
  step.current ? "\u2192 " : "",
351
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: step.id }),
1404
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: step.id }),
352
1405
  " \xB7 ",
353
1406
  step.description,
354
1407
  step.failures ? ` \xB7 \u5931\u8D25 ${step.failures} \u6B21` : ""
355
1408
  ] }, step.id)) })
356
1409
  ] }) : null,
357
- !terminal && status.votes.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
358
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ralphflow-status-label", children: [
1410
+ status.kind !== "graph" && !terminal && status.votes.length ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1411
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-label", children: [
359
1412
  "\u672C\u8F6E\u9A8C\u8BC1 \xB7 ",
360
1413
  returned,
361
1414
  "/",
362
1415
  status.votes.length,
363
1416
  " \u5DF2\u8FD4\u56DE"
364
1417
  ] }),
365
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "ralphflow-status-votes", "aria-label": `\u672C\u8F6E\u9A8C\u8BC1 \xB7 ${returned}/${status.votes.length} \u5DF2\u8FD4\u56DE`, children: status.votes.map((vote) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
1418
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "ralphflow-status-votes", "aria-label": `\u672C\u8F6E\u9A8C\u8BC1 \xB7 ${returned}/${status.votes.length} \u5DF2\u8FD4\u56DE`, children: status.votes.map((vote) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { children: [
366
1419
  "\u9A8C\u8BC1\u8005 ",
367
1420
  vote.index,
368
1421
  "/",
369
1422
  status.votes.length,
370
1423
  " \xB7 ",
371
1424
  votes[vote.status],
372
- vote.reason ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: vote.reason }) : null
1425
+ vote.check ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-vote-check", children: [
1426
+ "\u68C0\u67E5\u4F9D\u636E\uFF1A",
1427
+ vote.check
1428
+ ] }) : null,
1429
+ vote.reason ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: vote.reason }) : null
373
1430
  ] }, vote.index)) })
374
1431
  ] }) : null,
375
- !terminal && status.recent.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", { children: [
376
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { className: "ralphflow-status-label", children: "\u6700\u8FD1\u8F68\u8FF9" }),
377
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "ralphflow-status-recent", children: status.recent.map((event, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
1432
+ !terminal && status.recent.length ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("details", { children: [
1433
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("summary", { className: "ralphflow-status-label", children: "\u6700\u8FD1\u8F68\u8FF9" }),
1434
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "ralphflow-status-recent", children: status.recent.map((event, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { children: [
378
1435
  event.step,
379
1436
  " \xB7 ",
380
1437
  event.event,
381
1438
  event.detail ? `\uFF1A${event.detail}` : ""
382
1439
  ] }, index)) })
383
1440
  ] }) : null,
384
- status.report ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "ralphflow-status-report", children: [
1441
+ status.report ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "ralphflow-status-report", children: [
385
1442
  "\u62A5\u544A\uFF1A",
386
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: status.report })
1443
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: status.report })
387
1444
  ] }) : null
388
1445
  ] });
389
1446
  }
390
- function WorkflowStatusAction({ useWorkflowStatus }) {
1447
+ function WorkflowStatusAction({ useWorkflowStatus, pause }) {
391
1448
  const { status } = useWorkflowStatus(whole);
392
- if (!status || !actionStages.has(status.stage)) return null;
393
- const reason = status.stage === "gate" ? "\u7B49\u5F85\u4F60\u653E\u884C" : status.maxFailures > 0 && status.failures >= status.maxFailures ? "\u5931\u8D25\u5DF2\u5230\u4E0A\u9650" : "\u5DF2\u6682\u505C";
394
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ralphflow-status-action-dock", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ralphflow-status-action", "data-ralphflow-status-action": status.id, "data-stage": status.stage, role: "status", children: [
395
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDot, { stage: status.stage }),
396
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ralphflow-status-action-text", children: [
1449
+ const [pending, setPending] = (0, import_react2.useState)(false);
1450
+ const [error, setError] = (0, import_react2.useState)(null);
1451
+ if (!status) return null;
1452
+ const graph = status.kind === "graph" ? status.graph : void 0;
1453
+ const running = graph?.status === "running" ? graph.nodes.filter((node) => node.status === "running") : [];
1454
+ const backgroundRunning = running.filter((node) => node.execution === "background").length;
1455
+ const mainRunning = running.some((node) => node.execution === "main");
1456
+ if (backgroundRunning > 0 && !mainRunning && !actionStages.has(status.stage)) {
1457
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ralphflow-status-action-dock", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-action", "data-ralphflow-status-pause": status.id, children: [
1458
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StatusDot, { stage: status.stage }),
1459
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "ralphflow-status-action-text", children: [
1460
+ "Graph \u6267\u884C\u4E2D \xB7 ",
1461
+ backgroundRunning,
1462
+ " \u4E2A\u8282\u70B9\u5728\u98DE",
1463
+ error ? ` \xB7 ${error}` : ""
1464
+ ] }),
1465
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "ralphflow-status-pause", disabled: pending, onClick: () => {
1466
+ setPending(true);
1467
+ setError(null);
1468
+ void pause().then(
1469
+ (result) => {
1470
+ if (!result.ok) setError(result.text);
1471
+ },
1472
+ (cause) => {
1473
+ setError(cause instanceof Error ? cause.message : String(cause));
1474
+ }
1475
+ ).finally(() => setPending(false));
1476
+ }, children: pending ? "\u6682\u505C\u4E2D\u2026" : "\u6682\u505C" })
1477
+ ] }) });
1478
+ }
1479
+ if (!actionStages.has(status.stage)) return null;
1480
+ const reason = status.stage === "gate" ? "\u7B49\u5F85\u4F60\u653E\u884C" : status.maxFailures > 0 && status.failures >= status.maxFailures ? "\u8FD4\u5DE5\u5DF2\u5230\u4E0A\u9650" : "\u5DF2\u6682\u505C";
1481
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ralphflow-status-action-dock", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ralphflow-status-action", "data-ralphflow-status-action": status.id, "data-stage": status.stage, role: "status", children: [
1482
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StatusDot, { stage: status.stage }),
1483
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "ralphflow-status-action-text", children: [
397
1484
  reason,
398
- " \xB7 \u8F93\u5165 ",
399
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "/ralphflow-continue" }),
400
- " \u7EE7\u7EED"
1485
+ " \xB7 ",
1486
+ status.kind === "graph" && status.stage === "gate" ? "\u76F4\u63A5\u56DE\u590D\u4F60\u7684\u51B3\u5B9A\uFF08\u201C\u6279\u51C6\u6B64\u7248\u672C\u201D\u6216\u8981\u6539\u4EC0\u4E48\uFF09" : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1487
+ "\u8F93\u5165 ",
1488
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: "/ralphflow-continue" }),
1489
+ " \u7EE7\u7EED"
1490
+ ] })
401
1491
  ] })
402
1492
  ] }) });
403
1493
  }
@@ -407,14 +1497,18 @@ async function registerWorkflowStatus(ctx) {
407
1497
  }
408
1498
  function registerUi(ctx) {
409
1499
  const sources = /* @__PURE__ */ new Map();
410
- const sourceOf = (sessionId) => {
1500
+ const sourceFor = (sessionId) => {
411
1501
  let source = sources.get(sessionId);
412
1502
  if (!source) {
413
1503
  source = createStatusSource(ctx, sessionId);
414
1504
  sources.set(sessionId, source);
415
1505
  }
416
- return { hooks: { workflowStatus: source } };
1506
+ return source;
417
1507
  };
1508
+ const sourceOf = (sessionId) => ({
1509
+ hooks: { workflowStatus: sourceFor(sessionId) },
1510
+ pause: () => sourceFor(sessionId).pause()
1511
+ });
418
1512
  ctx.effect(() => () => {
419
1513
  for (const source of sources.values()) source.dispose();
420
1514
  sources.clear();
@@ -431,17 +1525,18 @@ function registerUi(ctx) {
431
1525
  order: 15,
432
1526
  inject: sourceOf
433
1527
  }, WorkflowStatusControl));
1528
+ registerViewerTab(ctx, sourceFor);
434
1529
  }
435
1530
 
436
1531
  // src/client/index.ts
437
1532
  var inject = ["uiConversation", "slots"];
438
1533
  function NoticeRow({ node }) {
439
1534
  injectStatusCss();
440
- return (0, import_react2.createElement)(
1535
+ return (0, import_react3.createElement)(
441
1536
  "details",
442
1537
  { "data-ralphflow-notice": String(node.anchorSeq), className: "ralphflow-notice" },
443
- (0, import_react2.createElement)("summary", null, node.data.summary),
444
- (0, import_react2.createElement)("div", { className: "ralphflow-notice-text" }, node.data.text)
1538
+ (0, import_react3.createElement)("summary", null, node.data.summary),
1539
+ (0, import_react3.createElement)("div", { className: "ralphflow-notice-text" }, node.data.text)
445
1540
  );
446
1541
  }
447
1542
  function apply(ctx) {